From 8858ee2b9886a0de0ae0fe7ff34645bc67da099a Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 1 Jun 2026 08:36:49 -0400 Subject: [PATCH] Initial weather support --- src/c/main.c | 20 +++++++++++++++++--- src/pkjs/index.js | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/c/main.c b/src/c/main.c index 4e8f59f..fd45b7d 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -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; } diff --git a/src/pkjs/index.js b/src/pkjs/index.js index a7b5438..4b35b85 100644 --- a/src/pkjs/index.js +++ b/src/pkjs/index.js @@ -1,6 +1,8 @@ var Clay = require('@rebble/clay'); var clayConfig = require('./config'); var customClay = require('./customClay'); +require('./weather'); + new Clay(clayConfig, customClay); Pebble.addEventListener("ready", function () {