diff --git a/stm-firmware/reflow-menu.c b/stm-firmware/reflow-menu.c index 637af11..0d3f4c9 100644 --- a/stm-firmware/reflow-menu.c +++ b/stm-firmware/reflow-menu.c @@ -222,6 +222,7 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en static void *my_parent = NULL; static uint8_t offset; static uint64_t timestamp; + static bool end_of_list_reached = true; bool state; enum button_state push_button; int16_t rot; @@ -232,6 +233,7 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en bool try_ack = false; enum safety_flag flag; bool button_ready; + const char *err_flag_prefix = "ERR_FLAG_"; push_button = menu_get_button_state(menu); rot = menu_get_rotary_delta(menu); @@ -240,6 +242,7 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en if (entry_type == MENU_ENTRY_FIRST_ENTER) { my_parent = parent; offset = 0; + end_of_list_reached = true; } } else { if (push_button == BUTTON_IDLE && rot == 0) { @@ -259,7 +262,8 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en if (rot >= 4 || rot <= -4) { menu_ack_rotary_delta(menu); if (rot > 0) { - offset++; + if (!end_of_list_reached) + offset++; } else { if (offset > 0) offset--; @@ -276,16 +280,20 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en if (state) { if (line_counter >= 0 && line_counter < 4) { safety_controller_get_flag_name_by_index(i, name, sizeof(name)); - if (!strncmp(name, "ERR_FLAG_", 9)) { + if (!strncmp(name, err_flag_prefix, 9)) { skip_err_flag_prefix = true; } else { skip_err_flag_prefix = false; } - menu_lcd_outputf(menu, line_counter, "%s", (skip_err_flag_prefix ? &name[9] : name)); + menu_lcd_outputf(menu, line_counter, "%s", + (skip_err_flag_prefix ? &name[9] : name)); } line_counter++; } } + + end_of_list_reached = (line_counter > 4 ? false : true); + timestamp = systick_get_global_tick(); }