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/liquid/scene_car.c

44 lines
1.1 KiB

#include "scenes.h"
#include "liquid.h"
#include "../graphics/nokia.h"
#include <malloc.h>
struct private {
int32_t pos;
};
static struct SceneEvent Car_onInput(struct Scene *scene, struct InputEvent event) {
struct private *priv = scene->private;
switch (event.kind) {
case InputEventKind_Wheel:
priv->pos += event.wheel.delta;
if (priv->pos < 0) priv->pos = 0;
if (priv->pos > LCD_WIDTH-21) priv->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 Car_paint(struct Scene *scene)
{
struct private *priv = scene->private;
LCD_clearDisplay(0);
LCD_setRect(priv->pos, LCD_HEIGHT/2-10, priv->pos+20,LCD_HEIGHT/2+10,0,1);
LCD_updateDisplay();
}
struct Scene *NewScene_Car(void) {
struct Scene *scene = SCENE_SAFE_ALLOC(struct private);
scene->onInput = Car_onInput;
scene->paint = Car_paint;
return scene;
}