esp32 firmware for a toaster reflow oven WIP!!!!!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
reflower/main/scenes/scene_car.c

44 lines
1.2 KiB

#include "scenes.h"
#include "liquid.h"
#include <malloc.h>
#include "graphics/nokia.h"
#include "graphics/drawing.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;
}