Add limit to scrolling of flag list in LCD gui
This commit is contained in:
parent
e60da5b23f
commit
d176389711
@ -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 void *my_parent = NULL;
|
||||||
static uint8_t offset;
|
static uint8_t offset;
|
||||||
static uint64_t timestamp;
|
static uint64_t timestamp;
|
||||||
|
static bool end_of_list_reached = true;
|
||||||
bool state;
|
bool state;
|
||||||
enum button_state push_button;
|
enum button_state push_button;
|
||||||
int16_t rot;
|
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;
|
bool try_ack = false;
|
||||||
enum safety_flag flag;
|
enum safety_flag flag;
|
||||||
bool button_ready;
|
bool button_ready;
|
||||||
|
const char *err_flag_prefix = "ERR_FLAG_";
|
||||||
|
|
||||||
push_button = menu_get_button_state(menu);
|
push_button = menu_get_button_state(menu);
|
||||||
rot = menu_get_rotary_delta(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) {
|
if (entry_type == MENU_ENTRY_FIRST_ENTER) {
|
||||||
my_parent = parent;
|
my_parent = parent;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
end_of_list_reached = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (push_button == BUTTON_IDLE && rot == 0) {
|
if (push_button == BUTTON_IDLE && rot == 0) {
|
||||||
@ -259,6 +262,7 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en
|
|||||||
if (rot >= 4 || rot <= -4) {
|
if (rot >= 4 || rot <= -4) {
|
||||||
menu_ack_rotary_delta(menu);
|
menu_ack_rotary_delta(menu);
|
||||||
if (rot > 0) {
|
if (rot > 0) {
|
||||||
|
if (!end_of_list_reached)
|
||||||
offset++;
|
offset++;
|
||||||
} else {
|
} else {
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
@ -276,16 +280,20 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en
|
|||||||
if (state) {
|
if (state) {
|
||||||
if (line_counter >= 0 && line_counter < 4) {
|
if (line_counter >= 0 && line_counter < 4) {
|
||||||
safety_controller_get_flag_name_by_index(i, name, sizeof(name));
|
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;
|
skip_err_flag_prefix = true;
|
||||||
} else {
|
} else {
|
||||||
skip_err_flag_prefix = false;
|
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++;
|
line_counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end_of_list_reached = (line_counter > 4 ? false : true);
|
||||||
|
|
||||||
timestamp = systick_get_global_tick();
|
timestamp = systick_get_global_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user