ui: battery: add menu entry to select between icon or percentage
This commit is contained in:
parent
6aecd2b727
commit
3add35275c
|
|
@ -62,6 +62,7 @@ typedef struct
|
||||||
_reserved : 3;
|
_reserved : 3;
|
||||||
bool m17_can_rx; // Check M17 CAN on RX
|
bool m17_can_rx; // Check M17 CAN on RX
|
||||||
char m17_dest[10]; // M17 destination
|
char m17_dest[10]; // M17 destination
|
||||||
|
bool showBatteryIcon; // Battery display true: icon, false: percentage
|
||||||
}
|
}
|
||||||
__attribute__((packed)) settings_t;
|
__attribute__((packed)) settings_t;
|
||||||
|
|
||||||
|
|
@ -86,7 +87,8 @@ static const settings_t default_settings =
|
||||||
1, // Automatic latch of macro menu enabled
|
1, // Automatic latch of macro menu enabled
|
||||||
0, // not used
|
0, // not used
|
||||||
false, // Check M17 CAN on RX
|
false, // Check M17 CAN on RX
|
||||||
"" // Empty M17 destination
|
"", // Empty M17 destination
|
||||||
|
false, // Display battery icon
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SETTINGS_H */
|
#endif /* SETTINGS_H */
|
||||||
|
|
|
||||||
|
|
@ -96,5 +96,6 @@ const stringsTable_t englishStrings =
|
||||||
.frequencyOffset = "Frequency Offset",
|
.frequencyOffset = "Frequency Offset",
|
||||||
.macroLatching = "Macro Latching",
|
.macroLatching = "Macro Latching",
|
||||||
.noGps = "No GPS",
|
.noGps = "No GPS",
|
||||||
|
.batteryIcon = "Battery Icon",
|
||||||
};
|
};
|
||||||
#endif // ENGLISHSTRINGS_H
|
#endif // ENGLISHSTRINGS_H
|
||||||
|
|
|
||||||
|
|
@ -97,5 +97,6 @@ const stringsTable_t spanishStrings =
|
||||||
.frequencyOffset = "Offset de frecuencia",
|
.frequencyOffset = "Offset de frecuencia",
|
||||||
.macroLatching = "Macro Latching",
|
.macroLatching = "Macro Latching",
|
||||||
.noGps = "Ningún GPS",
|
.noGps = "Ningún GPS",
|
||||||
|
.batteryIcon = "Icon de batteria",
|
||||||
};
|
};
|
||||||
#endif // SPANISHSTRINGS_H
|
#endif // SPANISHSTRINGS_H
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ enum displayItems
|
||||||
D_CONTRAST,
|
D_CONTRAST,
|
||||||
#endif
|
#endif
|
||||||
D_TIMER,
|
D_TIMER,
|
||||||
|
D_BATTERY
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_GPS
|
#ifdef CONFIG_GPS
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ typedef struct
|
||||||
const char* frequencyOffset;
|
const char* frequencyOffset;
|
||||||
const char* macroLatching;
|
const char* macroLatching;
|
||||||
const char* noGps;
|
const char* noGps;
|
||||||
|
const char* batteryIcon;
|
||||||
}
|
}
|
||||||
stringsTable_t;
|
stringsTable_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,8 @@ const char *display_items[] =
|
||||||
#ifdef CONFIG_SCREEN_CONTRAST
|
#ifdef CONFIG_SCREEN_CONTRAST
|
||||||
"Contrast",
|
"Contrast",
|
||||||
#endif
|
#endif
|
||||||
"Timer"
|
"Timer",
|
||||||
|
"Battery Icon"
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_GPS
|
#ifdef CONFIG_GPS
|
||||||
|
|
@ -2069,6 +2070,9 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
_ui_changeTimer(-1);
|
_ui_changeTimer(-1);
|
||||||
vp_announceDisplayTimer();
|
vp_announceDisplayTimer();
|
||||||
break;
|
break;
|
||||||
|
case D_BATTERY:
|
||||||
|
state.settings.showBatteryIcon = !state.settings.showBatteryIcon;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
state.ui_screen = SETTINGS_DISPLAY;
|
state.ui_screen = SETTINGS_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,19 @@ void _ui_drawMainTop(ui_state_t * ui_state)
|
||||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_RIGHT,
|
||||||
color_white,"%.1fV", last_state.v_bat);
|
color_white,"%.1fV", last_state.v_bat);
|
||||||
#else
|
#else
|
||||||
// Otherwise print battery icon on top bar, use 4 px padding
|
if(last_state.settings.showBatteryIcon) {
|
||||||
uint16_t bat_width = CONFIG_SCREEN_WIDTH / 9;
|
// print battery icon on top bar, use 4 px padding
|
||||||
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
|
uint16_t bat_width = CONFIG_SCREEN_WIDTH / 9;
|
||||||
point_t bat_pos = {CONFIG_SCREEN_WIDTH - bat_width - layout.horizontal_pad,
|
uint16_t bat_height = layout.top_h - (layout.status_v_pad * 2);
|
||||||
layout.status_v_pad};
|
point_t bat_pos = {CONFIG_SCREEN_WIDTH - bat_width - layout.horizontal_pad,
|
||||||
gfx_drawBattery(bat_pos, bat_width, bat_height, last_state.charge);
|
layout.status_v_pad};
|
||||||
|
gfx_drawBattery(bat_pos, bat_width, bat_height, last_state.charge);
|
||||||
|
} else {
|
||||||
|
// print the battery percentage
|
||||||
|
point_t bat_pos = {layout.top_pos.x, layout.top_pos.y - 2};
|
||||||
|
gfx_print(bat_pos , FONT_SIZE_6PT, TEXT_ALIGN_RIGHT,
|
||||||
|
color_white,"%d%%", last_state.charge);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ui_state->input_locked == true)
|
if (ui_state->input_locked == true)
|
||||||
gfx_drawSymbol(layout.top_pos, layout.top_symbol_size, TEXT_ALIGN_LEFT,
|
gfx_drawSymbol(layout.top_pos, layout.top_symbol_size, TEXT_ALIGN_LEFT,
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,12 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||||
sniprintf(buf, max_len, "%s",
|
sniprintf(buf, max_len, "%s",
|
||||||
display_timer_values[last_state.settings.display_timer]);
|
display_timer_values[last_state.settings.display_timer]);
|
||||||
return 0;
|
return 0;
|
||||||
|
case D_BATTERY:
|
||||||
|
sniprintf(buf, max_len, "%s",
|
||||||
|
(last_state.settings.showBatteryIcon) ?
|
||||||
|
currentLanguage->on :
|
||||||
|
currentLanguage->off);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
sniprintf(buf, max_len, "%d", value);
|
sniprintf(buf, max_len, "%d", value);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue