#include #include #include "graphics/nokia.h" #include "graphics/drawing.h" #include "scenes.h" #include "liquid.h" struct CarScene { struct Scene base; int32_t pos; }; static struct SceneEvent onInput(struct CarScene *self, struct InputEvent event) { switch (event.kind) { case InputEventKind_Wheel: self->pos += event.wheel.delta; if (self->pos < 0) self->pos = 0; if (self->pos > LCD_WIDTH-21) self->pos = LCD_WIDTH-21; return SceneEvent_Repaint(); case InputEventKind_Button: if (event.button.state) { return SceneEvent_Close(0, NULL); } // fall through default: return SceneEvent_None(); } } static void paint(struct CarScene *self) { LCD_clearDisplay(0); LCD_setRect(self->pos, LCD_HEIGHT/2-10, self->pos+20,LCD_HEIGHT/2+10,0,1); LCD_updateDisplay(); } struct Scene *NewScene_Car(void) { struct CarScene *scene = calloc(1, sizeof(struct CarScene)); if (!scene) return NULL; scene->base.onInput = (Scene_onInput_t) onInput; scene->base.paint = (Scene_paint_t) paint; return (struct Scene *) scene; }