Add indicator for failed temperature fetching

This commit is contained in:
2026-06-04 19:57:48 -04:00
parent 1c25daac8d
commit cbdfa740a8
5 changed files with 33 additions and 17 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
"CLAY_BAR_HOT_COLOR",
"CLAY_TIME_MG_COLOR",
"CLAY_FG_COLOR",
"CLAY_LOW_FUEL_COLOR"
"CLAY_WARNING_COLOR"
],
"resources": {
"media": [
+24 -8
View File
@@ -45,6 +45,7 @@ static AppTimer *s_date_timer = NULL;
static bool s_pkjs_ready = false;
static bool s_low_fuel_indicator = false;
static int s_batt_level;
static bool s_temp_is_warning = false;
static uint8_t s_temp_level;
// bar statics
@@ -56,10 +57,10 @@ 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 && settings.LowFuelBars != 21) {
replace_gbitmap_color(s_applied_fg, settings.ColorLowFuel, s_e_icon, s_e_layer);
replace_gbitmap_color(s_applied_fg, settings.ColorWarning, s_e_icon, s_e_layer);
s_low_fuel_indicator = true;
} else if (s_low_fuel_indicator && s_batt_level > settings.LowFuelBars) {
replace_gbitmap_color(settings.ColorLowFuel, s_applied_fg, s_e_icon, s_e_layer);
replace_gbitmap_color(settings.ColorWarning, s_applied_fg, s_e_icon, s_e_layer);
s_low_fuel_indicator = false;
}
}
@@ -113,19 +114,34 @@ static void fuel_mg_update_proc(Layer *layer, GContext *ctx) {
temp_fuel_mg_update_proc_helper(layer, ctx, true);
}
static void toggle_temp_warning_state(bool enable_warning) {
if (enable_warning == s_temp_is_warning) {
return;
}
GColor src = enable_warning ? s_applied_fg : settings.ColorWarning;
GColor dst = enable_warning ? settings.ColorWarning : s_applied_fg;
replace_gbitmap_color(src, dst, s_c_icon, s_c_layer);
replace_gbitmap_color(src, dst, s_h_icon, s_h_layer);
s_temp_is_warning = enable_warning;
}
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?
toggle_temp_warning_state(true);
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?
toggle_temp_warning_state(true);
return;
}
toggle_temp_warning_state(false);
}
static void update_minute_1() {
@@ -345,7 +361,7 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *color_hot_bar_tuple = dict_find(iter, MESSAGE_KEY_CLAY_BAR_HOT_COLOR);
Tuple *color_mg_time_tuple = dict_find(iter, MESSAGE_KEY_CLAY_TIME_MG_COLOR);
Tuple *color_fg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_FG_COLOR);
Tuple *color_low_fuel_tuple = dict_find(iter, MESSAGE_KEY_CLAY_LOW_FUEL_COLOR);
Tuple *color_warning_tuple = dict_find(iter, MESSAGE_KEY_CLAY_WARNING_COLOR);
if (date_timeout_tuple) {
settings.DateTimeoutSecs = date_timeout_tuple->value->uint8;
}
@@ -376,8 +392,8 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
if (color_fg_tuple) {
settings.ColorFG = GColorFromHEX(color_fg_tuple->value->int32);
}
if (color_low_fuel_tuple) {
settings.ColorLowFuel = GColorFromHEX(color_low_fuel_tuple->value->int32);
if (color_warning_tuple) {
settings.ColorWarning = GColorFromHEX(color_warning_tuple->value->int32);
}
persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
apply_settings(false);
@@ -398,7 +414,7 @@ static void init() {
settings.ColorBarsHot = GColorRed;
settings.ColorMGTime = GColorDarkGray;
settings.ColorFG = GColorWhite;
settings.ColorLowFuel = GColorChromeYellow;
settings.ColorWarning = GColorChromeYellow;
}
// load bitmaps
+1 -1
View File
@@ -14,7 +14,7 @@ typedef struct ClaySettings {
GColor ColorBarsHot;
GColor ColorMGTime;
GColor ColorFG;
GColor ColorLowFuel;
GColor ColorWarning;
} __attribute__((__packed__)) ClaySettings;
_Static_assert(sizeof(ClaySettings) <= 256, "ClaySettings exceeds Pebble 256-byte persist limit!");
+3 -3
View File
@@ -161,11 +161,11 @@ module.exports = [
"sunlight": false,
},
{
"id": "custom_color_low_fuel",
"id": "custom_color_warning",
"type": "color",
"messageKey": "CLAY_LOW_FUEL_COLOR",
"messageKey": "CLAY_WARNING_COLOR",
"defaultValue": "ffaa00",
"label": "Low fuel indicator color",
"label": "Warning indicator color",
"sunlight": false,
}
]
+4 -4
View File
@@ -15,7 +15,7 @@ module.exports = function (minified) {
clayConfig.getItemById('custom_color_hot_bars').set('ff0000');
clayConfig.getItemById('custom_color_mg_time').set('555555');
clayConfig.getItemById('custom_color_fg').set('ff0000');
clayConfig.getItemById('custom_color_low_fuel').set('ffaa00');
clayConfig.getItemById('custom_color_warning').set('ffaa00');
break
default:
clayConfig.getItemById('custom_color_led').set('ffffff');
@@ -25,7 +25,7 @@ module.exports = function (minified) {
clayConfig.getItemById('custom_color_hot_bars').set('ff0000');
clayConfig.getItemById('custom_color_mg_time').set('555555');
clayConfig.getItemById('custom_color_fg').set('ffffff');
clayConfig.getItemById('custom_color_low_fuel').set('ffaa00');
clayConfig.getItemById('custom_color_warning').set('ffaa00');
}
}
@@ -39,7 +39,7 @@ module.exports = function (minified) {
clayConfig.getItemById('custom_color_hot_bars').show();
clayConfig.getItemById('custom_color_mg_time').show();
clayConfig.getItemById('custom_color_fg').show();
clayConfig.getItemById('custom_color_low_fuel').show();
clayConfig.getItemById('custom_color_warning').show();
} else {
setColorsToPreset();
clayConfig.getItemById('color_preset_selector').show();
@@ -50,7 +50,7 @@ module.exports = function (minified) {
clayConfig.getItemById('custom_color_hot_bars').hide();
clayConfig.getItemById('custom_color_mg_time').hide();
clayConfig.getItemById('custom_color_fg').hide();
clayConfig.getItemById('custom_color_low_fuel').hide();
clayConfig.getItemById('custom_color_warning').hide();
}
}