Add indicator for failed temperature fetching
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@
|
|||||||
"CLAY_BAR_HOT_COLOR",
|
"CLAY_BAR_HOT_COLOR",
|
||||||
"CLAY_TIME_MG_COLOR",
|
"CLAY_TIME_MG_COLOR",
|
||||||
"CLAY_FG_COLOR",
|
"CLAY_FG_COLOR",
|
||||||
"CLAY_LOW_FUEL_COLOR"
|
"CLAY_WARNING_COLOR"
|
||||||
],
|
],
|
||||||
"resources": {
|
"resources": {
|
||||||
"media": [
|
"media": [
|
||||||
|
|||||||
+24
-8
@@ -45,6 +45,7 @@ static AppTimer *s_date_timer = NULL;
|
|||||||
static bool s_pkjs_ready = false;
|
static bool s_pkjs_ready = false;
|
||||||
static bool s_low_fuel_indicator = false;
|
static bool s_low_fuel_indicator = false;
|
||||||
static int s_batt_level;
|
static int s_batt_level;
|
||||||
|
static bool s_temp_is_warning = false;
|
||||||
static uint8_t s_temp_level;
|
static uint8_t s_temp_level;
|
||||||
|
|
||||||
// bar statics
|
// bar statics
|
||||||
@@ -56,10 +57,10 @@ static void batt_callback(BatteryChargeState state) {
|
|||||||
s_batt_level = state.charge_percent / 5;
|
s_batt_level = state.charge_percent / 5;
|
||||||
layer_mark_dirty(s_fuel_layer);
|
layer_mark_dirty(s_fuel_layer);
|
||||||
if (!s_low_fuel_indicator && s_batt_level <= settings.LowFuelBars && settings.LowFuelBars != 21) {
|
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;
|
s_low_fuel_indicator = true;
|
||||||
} else if (s_low_fuel_indicator && s_batt_level > settings.LowFuelBars) {
|
} 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;
|
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);
|
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() {
|
static void update_temperature() {
|
||||||
DictionaryIterator *out;
|
DictionaryIterator *out;
|
||||||
AppMessageResult result = app_message_outbox_begin(&out);
|
AppMessageResult result = app_message_outbox_begin(&out);
|
||||||
if (result != APP_MSG_OK) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
dict_write_int8(out, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT, 1);
|
dict_write_int8(out, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT, 1);
|
||||||
result = app_message_outbox_send();
|
result = app_message_outbox_send();
|
||||||
if (result != APP_MSG_OK) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
toggle_temp_warning_state(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_minute_1() {
|
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_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_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_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) {
|
if (date_timeout_tuple) {
|
||||||
settings.DateTimeoutSecs = date_timeout_tuple->value->uint8;
|
settings.DateTimeoutSecs = date_timeout_tuple->value->uint8;
|
||||||
}
|
}
|
||||||
@@ -376,8 +392,8 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
|||||||
if (color_fg_tuple) {
|
if (color_fg_tuple) {
|
||||||
settings.ColorFG = GColorFromHEX(color_fg_tuple->value->int32);
|
settings.ColorFG = GColorFromHEX(color_fg_tuple->value->int32);
|
||||||
}
|
}
|
||||||
if (color_low_fuel_tuple) {
|
if (color_warning_tuple) {
|
||||||
settings.ColorLowFuel = GColorFromHEX(color_low_fuel_tuple->value->int32);
|
settings.ColorWarning = GColorFromHEX(color_warning_tuple->value->int32);
|
||||||
}
|
}
|
||||||
persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
|
persist_write_data(STORAGE_KEY_SETTINGS, &settings, sizeof(settings));
|
||||||
apply_settings(false);
|
apply_settings(false);
|
||||||
@@ -398,7 +414,7 @@ static void init() {
|
|||||||
settings.ColorBarsHot = GColorRed;
|
settings.ColorBarsHot = GColorRed;
|
||||||
settings.ColorMGTime = GColorDarkGray;
|
settings.ColorMGTime = GColorDarkGray;
|
||||||
settings.ColorFG = GColorWhite;
|
settings.ColorFG = GColorWhite;
|
||||||
settings.ColorLowFuel = GColorChromeYellow;
|
settings.ColorWarning = GColorChromeYellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load bitmaps
|
// load bitmaps
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ typedef struct ClaySettings {
|
|||||||
GColor ColorBarsHot;
|
GColor ColorBarsHot;
|
||||||
GColor ColorMGTime;
|
GColor ColorMGTime;
|
||||||
GColor ColorFG;
|
GColor ColorFG;
|
||||||
GColor ColorLowFuel;
|
GColor ColorWarning;
|
||||||
} __attribute__((__packed__)) ClaySettings;
|
} __attribute__((__packed__)) ClaySettings;
|
||||||
|
|
||||||
_Static_assert(sizeof(ClaySettings) <= 256, "ClaySettings exceeds Pebble 256-byte persist limit!");
|
_Static_assert(sizeof(ClaySettings) <= 256, "ClaySettings exceeds Pebble 256-byte persist limit!");
|
||||||
|
|||||||
+3
-3
@@ -161,11 +161,11 @@ module.exports = [
|
|||||||
"sunlight": false,
|
"sunlight": false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "custom_color_low_fuel",
|
"id": "custom_color_warning",
|
||||||
"type": "color",
|
"type": "color",
|
||||||
"messageKey": "CLAY_LOW_FUEL_COLOR",
|
"messageKey": "CLAY_WARNING_COLOR",
|
||||||
"defaultValue": "ffaa00",
|
"defaultValue": "ffaa00",
|
||||||
"label": "Low fuel indicator color",
|
"label": "Warning indicator color",
|
||||||
"sunlight": false,
|
"sunlight": false,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = function (minified) {
|
|||||||
clayConfig.getItemById('custom_color_hot_bars').set('ff0000');
|
clayConfig.getItemById('custom_color_hot_bars').set('ff0000');
|
||||||
clayConfig.getItemById('custom_color_mg_time').set('555555');
|
clayConfig.getItemById('custom_color_mg_time').set('555555');
|
||||||
clayConfig.getItemById('custom_color_fg').set('ff0000');
|
clayConfig.getItemById('custom_color_fg').set('ff0000');
|
||||||
clayConfig.getItemById('custom_color_low_fuel').set('ffaa00');
|
clayConfig.getItemById('custom_color_warning').set('ffaa00');
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
clayConfig.getItemById('custom_color_led').set('ffffff');
|
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_hot_bars').set('ff0000');
|
||||||
clayConfig.getItemById('custom_color_mg_time').set('555555');
|
clayConfig.getItemById('custom_color_mg_time').set('555555');
|
||||||
clayConfig.getItemById('custom_color_fg').set('ffffff');
|
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_hot_bars').show();
|
||||||
clayConfig.getItemById('custom_color_mg_time').show();
|
clayConfig.getItemById('custom_color_mg_time').show();
|
||||||
clayConfig.getItemById('custom_color_fg').show();
|
clayConfig.getItemById('custom_color_fg').show();
|
||||||
clayConfig.getItemById('custom_color_low_fuel').show();
|
clayConfig.getItemById('custom_color_warning').show();
|
||||||
} else {
|
} else {
|
||||||
setColorsToPreset();
|
setColorsToPreset();
|
||||||
clayConfig.getItemById('color_preset_selector').show();
|
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_hot_bars').hide();
|
||||||
clayConfig.getItemById('custom_color_mg_time').hide();
|
clayConfig.getItemById('custom_color_mg_time').hide();
|
||||||
clayConfig.getItemById('custom_color_fg').hide();
|
clayConfig.getItemById('custom_color_fg').hide();
|
||||||
clayConfig.getItemById('custom_color_low_fuel').hide();
|
clayConfig.getItemById('custom_color_warning').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user