ui improvements

This commit is contained in:
2023-04-09 10:30:36 +02:00
parent ccce0ff72f
commit 18655e437f
9 changed files with 91 additions and 39 deletions
+6 -4
View File
@@ -14,6 +14,8 @@
#include "ufb/fb_text.h"
#include "app_safety.h"
struct State s_app = {};
/** Get push time (while held) */
uint32_t push_time() {
return s_app.pushed ? (xTaskGetTickCount() - s_app.push_time) : 0;
@@ -28,7 +30,7 @@ void request_paint() {
/** Draw the common overlay / HUD (with temperatures and heater status) */
static void draw_common_overlay();
static char tmp[100];
char stmp[100];
/** Main loop */
void app_task_gui(void *argument) {
@@ -132,11 +134,11 @@ void switch_screen(screen_t pScreen, bool init) {
/** Draw GUI common to all screens */
static void draw_common_overlay() {
SPRINTF(tmp, "%3.1f°C →%3d°C", s_app.oven_temp, s_app.set_temp);
fb_text(3, 3, tmp, FONT_3X5, 1);
SPRINTF(stmp, "%5.1f°C →%3d°C", s_app.oven_temp, s_app.set_temp);
fb_text(3, 3, stmp, FONT_3X5, 1);
if (s_app.heater_enabled) {
fb_frame(0, 0, FBW, 11, 2, 1);
fb_frame(0, 0, FBW, 11, 1, 1);
}
}
+6 -2
View File
@@ -9,6 +9,8 @@
#include <stdbool.h>
#include "gui_event.h"
extern char stmp[100];
void app_task_gui(void *argument);
@@ -40,7 +42,7 @@ void screen_home(GuiEvent event);
void screen_manual(GuiEvent event);
void screen_manual_menu(GuiEvent event);
static struct State {
struct State {
/// Latest oven temp readout
float oven_temp;
//float soc_temp;
@@ -89,6 +91,8 @@ static struct State {
uint8_t tick_counter;
} menu;
} page;
} s_app = {};
};
extern struct State s_app;
#endif //BLUEPILLTROUBA_APP_GUI_H
+14 -29
View File
@@ -10,6 +10,7 @@
#include "app_heater.h"
#include "ufb/fb_7seg.h"
#include "FreeRTOS.h"
#include "ufb/fb_text.h"
void screen_manual(GuiEvent event)
@@ -27,10 +28,22 @@ void screen_manual(GuiEvent event)
switch (event) {
case GUI_EVENT_PAINT:
fb_7seg_number(4, 40, 12, 20, 2, 2,
fb_7seg_number(FBW/2 - ((12+2) * 3 - 2)/2, 36,
12, 20, 2, 2,
1,
s_app.set_temp, 3, 0
);
fb_text(FBW/2, 25, "Teplota °C", TEXT_CENTER, 1);
fb_text(FBW/2, 64, s_app.heater_enabled ? "ZAPNUTO" : "Vypnuto", TEXT_CENTER, 1);
SPRINTF(stmp, "%.1f", s_app.oven_temp);
fb_text(FBW/2, 80, stmp, TEXT_CENTER | FONT_DOUBLE, 1);
fb_text(2, FBH - 8 * 3, "←→Nastav", 0, 1);
fb_text(2, FBH - 8 * 2, "> Zap/Vyp", 0, 1);
fb_text(2, FBH - 8 * 1, "» Menu", 0, 1);
break;
case GUI_EVENT_KNOB_RELEASE:
@@ -61,31 +74,3 @@ void screen_manual(GuiEvent event)
request_paint();
}
}
// ---------------------------
static const char* manual_menu_opts[] = {
"Zrušit",
"Hlavní menu",
NULL
};
static void manual_menu_cb(int opt) {
switch (opt) {
case 0:
// Close menu
switch_screen(screen_manual, false);
break;
case 1:
s_app.heater_enabled = false;
app_heater_enable(false);
switch_screen(screen_home, true);
break;
}
}
void screen_manual_menu(GuiEvent event)
{
screen_menu(event, manual_menu_opts, manual_menu_cb);
}
+35
View File
@@ -0,0 +1,35 @@
//
// Created by MightyPork on 2023/04/09.
//
#include <stddef.h>
#include "app_gui.h"
#include "app_heater.h"
#include "screen_menu.h"
static const char* manual_menu_opts[] = {
"Zrušit",
"Hlavní menu",
NULL
};
static void manual_menu_cb(int opt) {
switch (opt) {
case 0:
// Close menu
switch_screen(screen_manual, false);
break;
case 1:
s_app.heater_enabled = false;
app_heater_enable(false);
switch_screen(screen_home, true);
break;
}
}
void screen_manual_menu(GuiEvent event)
{
screen_menu(event, manual_menu_opts, manual_menu_cb);
}