From 410a5d4dd136fe9b139cc5f56d7f29e4c7f8c31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 22 May 2021 00:13:07 +0200 Subject: [PATCH 1/2] Change -Og to -O0 because it made a lot of problems when debugging --- stm-firmware/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/CMakeLists.txt b/stm-firmware/CMakeLists.txt index 37ccb9b..38ab3d5 100644 --- a/stm-firmware/CMakeLists.txt +++ b/stm-firmware/CMakeLists.txt @@ -61,7 +61,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) IF(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DDEBUGBUILD) - add_compile_options(-Og -g) + add_compile_options(-O0 -g) ELSE() add_compile_options(-O3 -g) add_link_options(-Wl,--gc-sections) From 71315b7c920022f8167828500f4717ca529f751f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 22 May 2021 00:14:56 +0200 Subject: [PATCH 2/2] Issue #28: Implement update successful notification. --- .../include/reflow-controller/ui/gui.h | 2 + stm-firmware/main.c | 3 + stm-firmware/ui/gui.c | 65 ++++++++++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/stm-firmware/include/reflow-controller/ui/gui.h b/stm-firmware/include/reflow-controller/ui/gui.h index 26c0ad2..6726a2e 100644 --- a/stm-firmware/include/reflow-controller/ui/gui.h +++ b/stm-firmware/include/reflow-controller/ui/gui.h @@ -29,4 +29,6 @@ int gui_handle(void); void gui_init(void); +void gui_root_menu_message_set(const char *heading, const char *text); + #endif /* _GUI_H_ */ diff --git a/stm-firmware/main.c b/stm-firmware/main.c index b60a97e..ce8325b 100644 --- a/stm-firmware/main.c +++ b/stm-firmware/main.c @@ -168,6 +168,9 @@ static inline void handle_boot_status(void) if (status.code_updated) { status.code_updated = 0x0UL; safety_memory_set_boot_status(&status); + + /* Display notification on GUI */ + gui_root_menu_message_set("Firmware updated", "[Press Key]"); } } diff --git a/stm-firmware/ui/gui.c b/stm-firmware/ui/gui.c index 5b79eb3..6465da6 100644 --- a/stm-firmware/ui/gui.c +++ b/stm-firmware/ui/gui.c @@ -686,6 +686,43 @@ static void gui_update_firmware(struct lcd_menu *menu, enum menu_entry_func_entr } } +static char *overlay_heading = NULL; +static char *overlay_text = NULL; + +static void gui_menu_overlay_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent) +{ + static void *my_parent; + enum button_state button; + + if (entry_type == MENU_ENTRY_FIRST_ENTER) { + my_parent = parent; + menu_display_clear(menu); + if (overlay_heading) + menu_lcd_output(menu, 0, overlay_heading); + if (overlay_text) { + menu_lcd_output(menu, 2, overlay_text); + if (strlen(overlay_text) > 16) { + menu_lcd_output(menu, 3, &overlay_text[16]); + } + } + } + + if (menu_get_button_ready_state(menu)) { + button = menu_get_button_state(menu); + menu_ack_rotary_delta(menu); + + if (button != BUTTON_IDLE) { + if (overlay_heading) + free(overlay_heading); + if (overlay_text) + free(overlay_text); + overlay_heading = NULL; + overlay_text = NULL; + menu_entry_dropback(menu, my_parent); + } + } +} + static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent) { (void)parent; @@ -745,8 +782,13 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr } } - if (menu_changed) + /* Display the message overlay in case it is set */ + if (overlay_heading || overlay_text) { + menu_entry_enter(menu, gui_menu_overlay_entry, true); + return; + } else if (menu_changed) { menu_list_display(&list, 1, 3); + } } int gui_handle() @@ -777,5 +819,26 @@ void gui_init() button_init(); lcd_init(); + if (overlay_heading) + free(overlay_heading); + if (overlay_text) + free(overlay_text); + + overlay_heading = NULL; + overlay_text = NULL; + menu_init(reflow_menu_ptr, gui_menu_root_entry, update_display_buffer); } + +void gui_root_menu_message_set(const char *heading, const char *text) +{ + if (heading) { + overlay_heading = (char *)malloc(strlen(heading) + 1); + strcpy(overlay_heading, heading); + } + + if (text) { + overlay_text = (char *)malloc(strlen(text) + 1); + strcpy(overlay_text, text); + } +}