add bitmap conversion from aseprite ico, add boot animation

This commit is contained in:
2020-01-05 16:46:53 +01:00
parent 6db58e14a7
commit d7cd0e9cfa
37 changed files with 593 additions and 81 deletions
+2 -2
View File
@@ -53,11 +53,10 @@ static void __attribute__((noreturn)) gui_thread(void *arg) {
uint32_t last_wheel_time = 0;
while (1) {
bool want_repaint = false;
uint32_t value = 0;
xTaskNotifyWait(0, ULONG_MAX, &value, pdMS_TO_TICKS(10));
bool want_repaint = false;
if (value & 0b10000) {
// TICK
want_repaint |= Liquid_handleTick(liquid);
@@ -72,6 +71,7 @@ static void __attribute__((noreturn)) gui_thread(void *arg) {
if (value & 0b11) {
uint32_t time = xTaskGetTickCount();
uint32_t increment = 1;
// wheel delta changes with speed
if (last_wheel_time != 0) {
uint32_t ela = time - last_wheel_time;
if (ela < pdMS_TO_TICKS(20)) {
+26 -4
View File
@@ -9,6 +9,8 @@
static const char *TAG = "Liquid";
extern struct Scene *NewScene_Root(void);
static struct SceneEvent Liquid_initTopScene(struct Liquid *container);
static bool processReturnValue(struct Liquid *container, struct SceneEvent result);
struct RunningScene {
struct Scene *scene;
@@ -27,7 +29,6 @@ static struct SceneEvent Default_onChildReturn(struct Scene *scene, uint32_t tag
static void addChild(struct Liquid *container, struct Scene *child) {
struct RunningScene *elm = calloc(1, sizeof(struct RunningScene));
if (!child->onChildReturn) child->onChildReturn = Default_onChildReturn;
assert(child->paint != NULL);
elm->scene = child;
SLIST_INSERT_HEAD(&container->stack, elm, next);
}
@@ -36,7 +37,12 @@ struct Liquid *Liquid_start(void) {
struct Liquid *container = calloc(1, sizeof(struct Liquid));
addChild(container, NewScene_Root());
Liquid_paint(container);
struct SceneEvent result = Liquid_initTopScene(container);
if (processReturnValue(container, result)) {
Liquid_paint(container);
}
return container;
}
@@ -69,7 +75,7 @@ static struct SceneEvent handleSceneEvent(struct Liquid *container, struct Scene
newScene = event.open.scene;
newScene->tag = event.open.tag;
addChild(container, newScene);
return SceneEvent_Repaint();
return Liquid_initTopScene(container);
case SceneEventKind_RequestRepaint:
case SceneEventKind_None:
@@ -79,6 +85,9 @@ static struct SceneEvent handleSceneEvent(struct Liquid *container, struct Scene
}
}
/**
* returns true if repaint is requested
*/
static bool processReturnValue(struct Liquid *container, struct SceneEvent result) {
bool repaint = false;
while (result.kind != SceneEventKind_None) {
@@ -122,10 +131,23 @@ bool Liquid_handleTick(struct Liquid *container) {
}
}
static struct SceneEvent Liquid_initTopScene(struct Liquid *container) {
struct RunningScene *topmost = SLIST_FIRST(&container->stack);
assert(topmost != NULL);
assert(topmost->scene != NULL);
if (topmost->scene->init) {
return topmost->scene->init(topmost->scene);
} else {
return SceneEvent_Repaint();
}
}
void Liquid_paint(struct Liquid *container) {
struct RunningScene *topmost = SLIST_FIRST(&container->stack);
assert(topmost != NULL);
topmost->scene->paint(topmost->scene);
if (topmost->scene->paint) {
topmost->scene->paint(topmost->scene);
}
LCD_updateDisplay();
}
+15 -2
View File
@@ -40,6 +40,14 @@ typedef struct SceneEvent (*Scene_onChildReturn_t)(struct Scene *scene, uint32_t
*/
typedef struct SceneEvent (*Scene_onTick_t)(struct Scene *scene);
/**
* Scene::init fp type
*
* @param scene - self
* @return follow-up scene event, can be SceneEvent_None() if not used.
*/
typedef struct SceneEvent (*Scene_init_t)(struct Scene *scene);
/**
* Scene::paint fp type
*
@@ -65,6 +73,12 @@ struct Scene {
*/
uint32_t tag;
/**
* Init function, called once after the scene has been opened.
* Nullable field.
*/
Scene_init_t init;
/**
* Handle input event.
* Can return a follow-up scene event, e.g. repaint request.
@@ -90,8 +104,7 @@ struct Scene {
/**
* Draw the scene to the LCD buffer.
* DO NOT write to the display yet, it will be done by the GUI engine.
*
* MANDATORY FIELD
* Nullable field.
*/
Scene_paint_t paint;