Make low fuel theshold configurable
This commit is contained in:
+10
-2
@@ -53,10 +53,10 @@ static const uint8_t s_bar_spacing = s_bar_height + 1;
|
||||
static void batt_callback(BatteryChargeState state) {
|
||||
s_batt_level = state.charge_percent / 5;
|
||||
layer_mark_dirty(s_fuel_layer);
|
||||
if (!s_low_fuel_indicator && s_batt_level < 5) {
|
||||
if (!s_low_fuel_indicator && s_batt_level <= settings.LowFuelBars) {
|
||||
replace_gbitmap_color(s_applied_fg, GColorChromeYellow, s_e_icon, s_e_layer);
|
||||
s_low_fuel_indicator = true;
|
||||
} else if (s_low_fuel_indicator && s_batt_level > 4) {
|
||||
} else if (s_low_fuel_indicator && s_batt_level > settings.LowFuelBars) {
|
||||
replace_gbitmap_color(GColorChromeYellow, s_applied_fg, s_e_icon, s_e_layer);
|
||||
s_low_fuel_indicator = false;
|
||||
}
|
||||
@@ -182,6 +182,9 @@ static void apply_settings(bool first_run) {
|
||||
replace_gbitmap_color(s_applied_fg, settings.ColorFG, s_f_icon, s_f_layer);
|
||||
s_applied_fg = settings.ColorFG;
|
||||
}
|
||||
|
||||
// changes to low fuel threshold
|
||||
batt_callback(battery_state_service_peek());
|
||||
}
|
||||
|
||||
static void main_window_load() {
|
||||
@@ -298,6 +301,7 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
|
||||
// CLAY SETTINGS
|
||||
Tuple *show_time_mg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_SHOW_TIME_MG);
|
||||
Tuple *low_fuel_bars_tuple = dict_find(iter, MESSAGE_KEY_CLAY_LOW_FUEL_BARS);
|
||||
Tuple *color_led_tuple = dict_find(iter, MESSAGE_KEY_CLAY_LED_COLOR);
|
||||
Tuple *color_bg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BG_COLOR);
|
||||
Tuple *color_mg_bar_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BAR_MG_COLOR);
|
||||
@@ -306,6 +310,9 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
if (show_time_mg_tuple) {
|
||||
settings.ShowTimeMG = show_time_mg_tuple->value->uint8;
|
||||
}
|
||||
if (low_fuel_bars_tuple) {
|
||||
settings.LowFuelBars = low_fuel_bars_tuple->value->uint8;
|
||||
}
|
||||
if (color_led_tuple) {
|
||||
settings.ColorLED = GColorFromHEX(color_led_tuple->value->int32);
|
||||
}
|
||||
@@ -331,6 +338,7 @@ static void init() {
|
||||
persist_read_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
|
||||
} else {
|
||||
settings.ShowTimeMG = false;
|
||||
settings.LowFuelBars = 2;
|
||||
settings.ColorLED = GColorWhite;
|
||||
settings.ColorBG = GColorBlue;
|
||||
settings.ColorMGBars = GColorDarkGray;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
typedef struct ClaySettings {
|
||||
bool ShowTimeMG;
|
||||
uint8_t LowFuelBars;
|
||||
GColor ColorLED;
|
||||
GColor ColorBG;
|
||||
GColor ColorMGBars;
|
||||
|
||||
@@ -17,6 +17,38 @@ module.exports = [
|
||||
"messageKey": "CLAY_SHOW_TIME_MG",
|
||||
"defaultValue": false,
|
||||
"label": "Show time segments midground"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"messageKey": "CLAY_LOW_FUEL_BARS",
|
||||
"defaultValue": 10,
|
||||
"label": "Low fuel percentage",
|
||||
"options": [
|
||||
{
|
||||
"label": "disabled",
|
||||
"value": 21,
|
||||
},
|
||||
{
|
||||
"label": "10%",
|
||||
"value": 2,
|
||||
},
|
||||
{
|
||||
"label": "20%",
|
||||
"value": 4,
|
||||
},
|
||||
{
|
||||
"label": "30%",
|
||||
"value": 6,
|
||||
},
|
||||
{
|
||||
"label": "40%",
|
||||
"value": 8,
|
||||
},
|
||||
{
|
||||
"label": "50%",
|
||||
"value": 10,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user