fixes in calib

This commit is contained in:
2023-04-09 19:53:47 +02:00
parent 1331460ecb
commit dc445af419
6 changed files with 141 additions and 134 deletions
+7 -6
View File
@@ -118,21 +118,22 @@ void screen_calibration(GuiEvent event)
switch (s_calib.phase) {
case PH_HELLO:
if (event == GUI_EVENT_PAINT) {
fb_text(FBW/2, 14, "Vychlaď", TEXT_CENTER, 1);
fb_text(FBW/2, 24, "troubu", TEXT_CENTER, 1);
fb_text(FBW/2, 16, "Vychlaď", TEXT_CENTER, 1);
fb_text(FBW/2, 26, "troubu", TEXT_CENTER, 1);
}
screen_menu(event, calib0_opts, calib0_cb);
screen_menu_offset(event, calib0_opts, calib0_cb, 30);
break;
case PH_SAMPLE1: // Heater is active, waiting for mark
case PH_SAMPLE2:
if (event == GUI_EVENT_PAINT) {
fb_text(FBW/2, 14, "Zapiš teplotu", TEXT_CENTER, 1);
fb_text(FBW/2, 16, "Zapiš", TEXT_CENTER, 1);
fb_text(FBW/2, 26, "teplotu", TEXT_CENTER, 1);
}
if (s_calib.phase == PH_SAMPLE1) {
screen_menu(event, calib1_opts, calib1_cb);
screen_menu_offset(event, calib1_opts, calib1_cb, 30);
} else {
screen_menu(event, calib3_opts, calib3_cb);
screen_menu_offset(event, calib3_opts, calib3_cb, 30);
}
break;
+6 -1
View File
@@ -22,7 +22,12 @@ struct menu_state {
void * last_opts;
} s_menu;
void screen_menu(GuiEvent event, const char **options, menu_callback_t cb) {
screen_menu_offset(event, options, cb, 15);
}
void screen_menu_offset(GuiEvent event, const char **options, menu_callback_t cb, fbpos_t offset) {
if (event != GUI_EVENT_SCREEN_INIT && s_menu.last_opts != (void*) options) {
// ensure the menu is properly inited when the options list changes.
screen_menu(GUI_EVENT_SCREEN_INIT, options, cb);
@@ -71,7 +76,7 @@ void screen_menu(GuiEvent event, const char **options, menu_callback_t cb) {
// is the row currently rendered the selected row?
const bool is_selected = s_menu.pos == i;
const fbcolor_t color = !is_selected; // text color - black if selected, because it's inverted
const fbpos_t y = 27 + i * 10;
const fbpos_t y = 12 + offset + i * 10 ;
fb_rect(0, y, FBW, 10, !color);
fb_text(1 - (is_selected ? s_menu.text_slide : 0), y + 1, options[i], FONT_5X7, color);
// ensure the text doesn't touch the edge (looks ugly)
+3
View File
@@ -8,6 +8,7 @@
#define TOASTER_OVEN_BLUEPILL_SCREEN_MENU_H
#include "gui_event.h"
#include "ufb/framebuffer.h"
/**
* Choice callback for the generic menu screen. Options are indexed from zero
@@ -23,5 +24,7 @@ typedef void (*menu_callback_t)(int choice);
*/
void screen_menu(GuiEvent event, const char **options, menu_callback_t cb);
/** Menu with custom offset (default is 15) */
void screen_menu_offset(GuiEvent event, const char **options, menu_callback_t cb, fbpos_t offset);
#endif //TOASTER_OVEN_BLUEPILL_SCREEN_MENU_H