Initial weather support

This commit is contained in:
2026-06-01 08:37:33 -04:00
parent 1d4bcebfbb
commit a4c4047d96
3 changed files with 61 additions and 3 deletions
+17 -3
View File
@@ -41,6 +41,7 @@ static GBitmap *s_f_icon;
// tracking statics
static int s_batt_level;
static uint8_t s_temp_level;
// bar statics
static const uint8_t s_bar_height = 8;
@@ -56,7 +57,7 @@ static void batt_callback(BatteryChargeState state) {
// TODO use temperature (for now it updates with battery usage)
static void temp_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorWhite);
const uint8_t bar_count = s_batt_level / 5;
const uint8_t bar_count = s_temp_level;
uint16_t bar_bottom_pos = 195;
for (uint8_t i = 0; i < bar_count; ++i) {
@@ -258,14 +259,27 @@ static void minute_handler(struct tm *tick_time, TimeUnits units_changed) {
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
if (ready_tuple) {
// TODO request temp bars from PKJS
// 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;
}
return;
}
// TEMPERATURE DATA
Tuple *temp_bar_count = dict_find(iter, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT);
if (temp_bar_count) {
// TODO
s_temp_level = temp_bar_count->value->uint8;
layer_mark_dirty(s_temp_layer);
return;
}