From dc445af41920327e5a9962d901b810be688cc2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 9 Apr 2023 19:53:47 +0200 Subject: [PATCH] fixes in calib --- Core/Src/Gui/screen_calibration.c | 13 +- Core/Src/Gui/screen_menu.c | 7 +- Core/Src/Gui/screen_menu.h | 3 + Core/Src/app_temp.c | 14 +- Lib/ufb/Src/font_57.inc.c | 13 +- Lib/ufb/Src/fontedit_57.c | 225 ++++++++++++++++-------------- 6 files changed, 141 insertions(+), 134 deletions(-) diff --git a/Core/Src/Gui/screen_calibration.c b/Core/Src/Gui/screen_calibration.c index 64c90c1..765595e 100644 --- a/Core/Src/Gui/screen_calibration.c +++ b/Core/Src/Gui/screen_calibration.c @@ -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; diff --git a/Core/Src/Gui/screen_menu.c b/Core/Src/Gui/screen_menu.c index d92e312..8c4a47d 100644 --- a/Core/Src/Gui/screen_menu.c +++ b/Core/Src/Gui/screen_menu.c @@ -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) diff --git a/Core/Src/Gui/screen_menu.h b/Core/Src/Gui/screen_menu.h index 5d4d2c5..1c8008b 100644 --- a/Core/Src/Gui/screen_menu.h +++ b/Core/Src/Gui/screen_menu.h @@ -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 diff --git a/Core/Src/app_temp.c b/Core/Src/app_temp.c index 0f5aebc..1519709 100644 --- a/Core/Src/app_temp.c +++ b/Core/Src/app_temp.c @@ -272,12 +272,12 @@ void app_temp_sample() adc_averages[2] = (float) sums[2] / count; adc_averages[3] = (float) sums[3] / count; - PRINTF("%f\t%f\t%f\t%f\r\n", - adc_averages[0], - adc_averages[1], - adc_averages[2], - adc_averages[3] - ); +// PRINTF("%f\t%f\t%f\t%f\r\n", +// adc_averages[0], +// adc_averages[1], +// adc_averages[2], +// adc_averages[3] +// ); /* r_pt100, r_ref, internal_temp, v_ref_int */ float refint = adc_averages[3]; @@ -313,7 +313,7 @@ void app_temp_sample() float y = s_analog.cal_a * sum + s_analog.cal_b; float actual_temp = val_to_c(y); - PRINTF("Compensated x %f -> y %f, temp %f C\r\n", sum, y, actual_temp); +// PRINTF("Compensated x %f -> y %f, temp %f C\r\n", sum, y, actual_temp); s_analog.oven_temp = actual_temp; s_analog.oven_temp_raw = sum; diff --git a/Lib/ufb/Src/font_57.inc.c b/Lib/ufb/Src/font_57.inc.c index 2dac8e5..47cde97 100644 --- a/Lib/ufb/Src/font_57.inc.c +++ b/Lib/ufb/Src/font_57.inc.c @@ -98,24 +98,13 @@ static const font5x_bitmap_t PROGMEM font57_ascii[] = { static const struct utf_glyph5x PROGMEM font57_extra[] = { {.utf={.symbol="�"}, {{0x7f, 0x41, 0x41, 0x41, 0x7f}}}, - {.utf={.symbol="×"}, {{0x22, 0x14, 0x08, 0x14, 0x22}}}, - {.utf={.symbol="↑"}, {{0x08, 0x04, 0x3e, 0x04, 0x08}}}, - {.utf={.symbol="↓"}, {{0x08, 0x10, 0x3e, 0x10, 0x08}}}, {.utf={.symbol="←"}, {{0x08, 0x1c, 0x2a, 0x08, 0x08}}}, {.utf={.symbol="→"}, {{0x08, 0x08, 0x2a, 0x1c, 0x08}}}, - {.utf={.symbol="⏱"}, {{0x1c, 0x22, 0x2e, 0x2a, 0x1c}}}, - {.utf={.symbol="⌛"}, {{0x63, 0x55, 0x4d, 0x55, 0x63}}}, - {.utf={.symbol="☸"}, {{0x1c, 0x22, 0x2a, 0x22, 0x1c}}}, - {.utf={.symbol="⏎"}, {{0x10, 0x38, 0x54, 0x10, 0x1e}}}, - {.utf={.symbol="🌡"}, {{0x20, 0x7e, 0x79, 0x7e, 0x2a}}}, {.utf={.symbol="°"}, {{0x00, 0x07, 0x05, 0x07, 0x00}}}, - {.utf={.symbol="μ"}, {{0x7c, 0x20, 0x20, 0x10, 0x3c}}}, - {.utf={.symbol="⎌"}, {{0x04, 0x4e, 0x55, 0x44, 0x38}}}, - {.utf={.symbol="▶"}, {{0x7f, 0x3e, 0x1c, 0x08, 0x00}}}, - {.utf={.symbol="◀"}, {{0x00, 0x08, 0x1c, 0x3e, 0x7f}}}, {.utf={.symbol="č"}, {{0x38, 0x45, 0x46, 0x45, 0x20}}}, {.utf={.symbol="š"}, {{0x48, 0x55, 0x56, 0x55, 0x20}}}, {.utf={.symbol="í"}, {{0x00, 0x44, 0x7d, 0x41, 0x00}}}, {.utf={.symbol="ž"}, {{0x44, 0x65, 0x56, 0x4d, 0x44}}}, + {.utf={.symbol="ď"}, {{0x38, 0x44, 0x45, 0x48, 0x7f}}}, {.utf={.symbol="»"}, {{0x22, 0x14, 0x2a, 0x14, 0x08}}}, }; diff --git a/Lib/ufb/Src/fontedit_57.c b/Lib/ufb/Src/fontedit_57.c index f8c1be7..1545880 100644 --- a/Lib/ufb/Src/fontedit_57.c +++ b/Lib/ufb/Src/fontedit_57.c @@ -775,30 +775,30 @@ const char *font_extras[] = { "# #", "# #", "#####", - // Extra 1 - " ", - "# #", - " # # ", - " # ", - " # # ", - "# #", - " ", - // Extra 2 - " ", - " # ", - " ### ", - "# # #", - " # ", - " # ", - " ", - // Extra 3 - " ", - " # ", - " # ", - "# # #", - " ### ", - " # ", - " ", +// // Extra 1 +// " ", +// "# #", +// " # # ", +// " # ", +// " # # ", +// "# #", +// " ", +// // Extra 2 +// " ", +// " # ", +// " ### ", +// "# # #", +// " # ", +// " # ", +// " ", +// // Extra 3 +// " ", +// " # ", +// " # ", +// "# # #", +// " ### ", +// " # ", +// " ", // Extra 4 " ", " # ", @@ -815,46 +815,46 @@ const char *font_extras[] = { " # ", " # ", " ", - // Extra 6 - " ", - " ### ", - "# # #", - "# ###", - "# #", - " ### ", - " ", - // Extra 7 - "#####", - "# #", - " ### ", - " # ", - " # # ", - "# #", - "#####", - // Extra 8 - " ", - " ### ", - "# #", - "# # #", - "# #", - " ### ", - " ", - // Extra 9 - " ", - " #", - " # #", - " # #", - "#####", - " # ", - " # ", - // Extra 10 - " # ", - " # ##", - " # # ", - " ####", - " ### ", - "#####", - " ### ", +// // Extra 6 +// " ", +// " ### ", +// "# # #", +// "# ###", +// "# #", +// " ### ", +// " ", +// // Extra 7 +// "#####", +// "# #", +// " ### ", +// " # ", +// " # # ", +// "# #", +// "#####", +// // Extra 8 +// " ", +// " ### ", +// "# #", +// "# # #", +// "# #", +// " ### ", +// " ", +// // Extra 9 +// " ", +// " #", +// " # #", +// " # #", +// "#####", +// " # ", +// " # ", +// // Extra 10 +// " # ", +// " # ##", +// " # # ", +// " ####", +// " ### ", +// "#####", +// " ### ", // Extra 11 " ### ", " # # ", @@ -863,38 +863,38 @@ const char *font_extras[] = { " ", " ", " ", - // Extra 12 - " ", - " ", - "# #", - "# #", - "# ##", - "### #", - "# ", - // Extra 13 - " # ", - " # ", - "#### ", - " # #", - " # #", - " #", - " ### ", - // Extra 14 - "# ", - "## ", - "### ", - "#### ", - "### ", - "## ", - "# ", - // Extra 15 - " #", - " ##", - " ###", - " ####", - " ###", - " ##", - " #", +// // Extra 12 +// " ", +// " ", +// "# #", +// "# #", +// "# ##", +// "### #", +// "# ", +// // Extra 13 +// " # ", +// " # ", +// "#### ", +// " # #", +// " # #", +// " #", +// " ### ", +// // Extra 14 +// "# ", +// "## ", +// "### ", +// "#### ", +// "### ", +// "## ", +// "# ", +// // Extra 15 +// " #", +// " ##", +// " ###", +// " ####", +// " ###", +// " ##", +// " #", // 99 "č" " x x ", " x ", @@ -927,6 +927,14 @@ const char *font_extras[] = { " # ", " # ", "#####", + // 100 "d" + " x #", + " #", + " ## #", + "# ##", + "# #", + "# #", + " ####", // » " ", "x x ", @@ -939,25 +947,26 @@ const char *font_extras[] = { const char *font_extras_utf[] = { "�", - "×", - "↑", - "↓", +// "×", +// "↑", +// "↓", "←", "→", - "⏱", // clock - "⌛", - "☸", - "⏎", - "🌡", +// "⏱", // clock +// "⌛", +// "☸", +// "⏎", +// "🌡", "°", - "μ", - "⎌", // back - "▶", - "◀", +// "μ", +// "⎌", // back +// "▶", +// "◀", "č", "š", "í", "ž", + "ď", "»", };