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.
83 lines
1.7 KiB
83 lines
1.7 KiB
/**
|
|
* TODO file description
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#include "app_gui.h"
|
|
#include "../lcd/lcdbuf.h"
|
|
|
|
struct State s_app = {};
|
|
|
|
struct LcdBuffer lcd = {};
|
|
|
|
/** Schedule paint (the screen func will be called with the PAINT event argument */
|
|
void request_paint() {
|
|
s_app.paint_needed = true;
|
|
}
|
|
|
|
/** Draw the common overlay / HUD (with temperatures and heater status) */
|
|
static void draw_common_overlay();
|
|
|
|
char stmp[100];
|
|
|
|
/** Main loop */
|
|
void gui_init()
|
|
{
|
|
switch_screen(screen_home, true);
|
|
s_app.last_tick_time = timestamp();
|
|
|
|
LcdBuffer_Init(&lcd, CGROM_A00, CGRAM_CZ);
|
|
}
|
|
|
|
void gui_loop_iter(GuiEvent message) {
|
|
uint32_t tickNow = timestamp();
|
|
|
|
// 10ms tick event
|
|
if (tickNow - s_app.last_tick_time > 10) {
|
|
s_app.screen(GUI_EVENT_SCREEN_TICK);
|
|
s_app.last_tick_time = tickNow;
|
|
}
|
|
|
|
if (message != GUI_EVENT_NONE) {
|
|
s_app.screen(message);
|
|
}
|
|
|
|
if (message >= 32) { // lazy shortcut so we dont have to list all of them
|
|
// key was pressed
|
|
input_sound_effect();
|
|
}
|
|
|
|
if (s_app.paint_needed) {
|
|
s_app.paint_needed = false;
|
|
|
|
draw_common_overlay();
|
|
s_app.screen(GUI_EVENT_PAINT);
|
|
|
|
// If there is anything to print, do it
|
|
LcdBuffer_Flush(&lcd);
|
|
}
|
|
}
|
|
|
|
/** Switch to a different screen handler.
|
|
* If "init" is true, immediately call it with the init event. */
|
|
void switch_screen(screen_t pScreen, bool init) {
|
|
s_app.screen = pScreen;
|
|
|
|
LcdBuffer_Clear(&lcd);
|
|
request_paint();
|
|
|
|
if (init) {
|
|
pScreen(GUI_EVENT_SCREEN_INIT);
|
|
}
|
|
}
|
|
|
|
/** Draw GUI common to all screens */
|
|
static void draw_common_overlay() {
|
|
// TODO
|
|
}
|
|
|
|
/** Play input sound effect if this is an input event */
|
|
void input_sound_effect() {
|
|
// TODO
|
|
}
|
|
|