Issue #28: Implement update successful notification.

This commit is contained in:
Mario Hüttel 2021-05-22 00:14:56 +02:00
parent 410a5d4dd1
commit 71315b7c92
3 changed files with 69 additions and 1 deletions

View File

@ -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_ */

View File

@ -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]");
}
}

View File

@ -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);
}
}