Add indicator for failed temperature fetching
This commit is contained in:
+24
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user