Make temperature range configurable

This commit is contained in:
2026-06-01 22:28:54 -04:00
parent 8602952d58
commit e06617b431
5 changed files with 48 additions and 28 deletions
+20 -18
View File
@@ -53,7 +53,7 @@ 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 <= settings.LowFuelBars) {
if (!s_low_fuel_indicator && s_batt_level <= settings.LowFuelBars && settings.LowFuelBars != 21) {
replace_gbitmap_color(s_applied_fg, settings.ColorLowFuel, s_e_icon, s_e_layer);
s_low_fuel_indicator = true;
} else if (s_low_fuel_indicator && s_batt_level > settings.LowFuelBars) {
@@ -62,7 +62,6 @@ static void batt_callback(BatteryChargeState state) {
}
}
// TODO use temperature (for now it updates with battery usage)
static void temp_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorWhite);
const uint8_t bar_count = s_temp_level;
@@ -112,6 +111,21 @@ static void fuel_mg_update_proc(Layer *layer, GContext *ctx) {
temp_fuel_mg_update_proc_helper(layer, ctx, true);
}
static void update_temperature() {
DictionaryIterator *out;
AppMessageResult result = app_message_outbox_begin(&out);
if (result != APP_MSG_OK) {
s_temp_level = 0; // error; set to 0 bars to indicate TODO invert color and set to 20?
return;
}
dict_write_int8(out, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT, 1);
result = app_message_outbox_send();
if (result != APP_MSG_OK) {
s_temp_level = 0; // error; set to 0 bars to indicate TODO invert color and set to 20?
return;
}
}
static void apply_settings(bool first_run) {
// LED&BG
light_set_color(settings.ColorLED); // no-op on unsupported platforms
@@ -183,6 +197,9 @@ static void apply_settings(bool first_run) {
s_applied_fg = settings.ColorFG;
}
// changes to temperature range
update_temperature();
// changes to low fuel threshold
batt_callback(battery_state_service_peek());
}
@@ -262,21 +279,6 @@ static void update_minute_1() {
}
}
static void update_temperature() {
DictionaryIterator *out;
AppMessageResult result = app_message_outbox_begin(&out);
if (result != APP_MSG_OK) {
s_temp_level = 0; // error; set to 0 bars to indicate TODO invert color and set to 20?
return;
}
dict_write_int8(out, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT, 1);
result = app_message_outbox_send();
if (result != APP_MSG_OK) {
s_temp_level = 0; // error; set to 0 bars to indicate TODO invert color and set to 20?
return;
}
}
static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
update_minute_1();
if (s_pkjs_ready && tick_time->tm_min % 30 == 0) {
@@ -350,7 +352,7 @@ static void init() {
persist_read_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
} else {
settings.ShowTimeMG = false;
settings.LowFuelBars = 2;
settings.LowFuelBars = 21;
settings.ColorLED = GColorWhite;
settings.ColorBG = GColorBlue;
settings.ColorMGBars = GColorDarkGray;