Update temperature every half hour
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"civic",
|
"civic",
|
||||||
"segment",
|
"segment",
|
||||||
"display",
|
"display",
|
||||||
|
"led",
|
||||||
"speedometer"
|
"speedometer"
|
||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
+20
-13
@@ -40,6 +40,7 @@ static GBitmap *s_e_icon;
|
|||||||
static GBitmap *s_f_icon;
|
static GBitmap *s_f_icon;
|
||||||
|
|
||||||
// tracking statics
|
// tracking statics
|
||||||
|
static bool s_pkjs_ready = false;
|
||||||
static int s_batt_level;
|
static int s_batt_level;
|
||||||
static uint8_t s_temp_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) {
|
static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
|
||||||
update_minute_1();
|
update_minute_1();
|
||||||
|
if (s_pkjs_ready && tick_time->tm_min % 30 == 0) {
|
||||||
|
update_temperature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||||
if (ready_tuple) {
|
if (ready_tuple) {
|
||||||
// request temp bars from PKJS
|
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;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user