UI: Fixed zone menu bug causing last zone to be replicated

This commit is contained in:
Federico Amedeo Izzo 2021-02-01 21:47:10 +01:00
parent a81d02b470
commit 70bce5a5fc
1 changed files with 4 additions and 5 deletions

View File

@ -30,9 +30,8 @@ void _ui_drawMenuList(point_t pos, uint8_t selected, int (*getCurrentEntry)(char
uint8_t entries_in_screen = ((SCREEN_HEIGHT - pos.y) / layout.top_h) + 1; uint8_t entries_in_screen = ((SCREEN_HEIGHT - pos.y) / layout.top_h) + 1;
uint8_t scroll = 0; uint8_t scroll = 0;
char entry_buf[MAX_ENTRY_LEN] = ""; char entry_buf[MAX_ENTRY_LEN] = "";
int result = 0;
color_t text_color = color_white; color_t text_color = color_white;
for(int item=0; (result == 0) && (pos.y < SCREEN_HEIGHT); item++) for(int item=0, result=0; (result == 0) && (pos.y < SCREEN_HEIGHT); item++)
{ {
// If selection is off the screen, scroll screen // If selection is off the screen, scroll screen
if(selected >= entries_in_screen) if(selected >= entries_in_screen)
@ -64,9 +63,8 @@ void _ui_drawMenuListValue(point_t pos, uint8_t selected,
uint8_t scroll = 0; uint8_t scroll = 0;
char entry_buf[MAX_ENTRY_LEN] = ""; char entry_buf[MAX_ENTRY_LEN] = "";
char value_buf[MAX_ENTRY_LEN] = ""; char value_buf[MAX_ENTRY_LEN] = "";
int result = 0;
color_t text_color = color_white; color_t text_color = color_white;
for(int item=0; (result == 0) && (pos.y < SCREEN_HEIGHT); item++) for(int item=0, result=0; (result == 0) && (pos.y < SCREEN_HEIGHT); item++)
{ {
// If selection is off the screen, scroll screen // If selection is off the screen, scroll screen
if(selected >= entries_in_screen) if(selected >= entries_in_screen)
@ -145,6 +143,7 @@ int _ui_getInfoValueName(char *buf, uint8_t max_len, uint8_t index)
snprintf(buf, max_len, "%.1fdBm", last_state.rssi); snprintf(buf, max_len, "%.1fdBm", last_state.rssi);
return 0; return 0;
} }
int _ui_getZoneName(char *buf, uint8_t max_len, uint8_t index) int _ui_getZoneName(char *buf, uint8_t max_len, uint8_t index)
{ {
int result = 0; int result = 0;
@ -156,7 +155,7 @@ int _ui_getZoneName(char *buf, uint8_t max_len, uint8_t index)
else else
{ {
zone_t zone; zone_t zone;
int result = nvm_readZoneData(&zone, index - 1); result = nvm_readZoneData(&zone, index - 1);
if(result != -1) if(result != -1)
snprintf(buf, max_len, "%s", zone.name); snprintf(buf, max_len, "%s", zone.name);
} }