Update temperature every half hour
This commit is contained in:
+20
-13
@@ -40,6 +40,7 @@ static GBitmap *s_e_icon;
|
||||
static GBitmap *s_f_icon;
|
||||
|
||||
// tracking statics
|
||||
static bool s_pkjs_ready = false;
|
||||
static int s_batt_level;
|
||||
static uint8_t s_temp_level;
|
||||
|
||||
@@ -252,26 +253,32 @@ 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) {
|
||||
update_temperature();
|
||||
}
|
||||
}
|
||||
|
||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||
if (ready_tuple) {
|
||||
// request temp bars from PKJS
|
||||
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;
|
||||
}
|
||||
update_temperature();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user