Initial weather support

This commit is contained in:
2026-06-01 08:36:49 -04:00
parent 1d4bcebfbb
commit 8858ee2b98
2 changed files with 19 additions and 3 deletions
+17 -3
View File
@@ -41,6 +41,7 @@ static GBitmap *s_f_icon;
// tracking statics // tracking statics
static int s_batt_level; static int s_batt_level;
static uint8_t s_temp_level;
// bar statics // bar statics
static const uint8_t s_bar_height = 8; 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) // TODO use temperature (for now it updates with battery usage)
static void temp_update_proc(Layer *layer, GContext *ctx) { static void temp_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorWhite); 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; uint16_t bar_bottom_pos = 195;
for (uint8_t i = 0; i < bar_count; ++i) { 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) { 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) {
// 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; return;
} }
// TEMPERATURE DATA // TEMPERATURE DATA
Tuple *temp_bar_count = dict_find(iter, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT); Tuple *temp_bar_count = dict_find(iter, MESSAGE_KEY_PKJS_TEMP_BAR_COUNT);
if (temp_bar_count) { if (temp_bar_count) {
// TODO s_temp_level = temp_bar_count->value->uint8;
layer_mark_dirty(s_temp_layer);
return; return;
} }
+2
View File
@@ -1,6 +1,8 @@
var Clay = require('@rebble/clay'); var Clay = require('@rebble/clay');
var clayConfig = require('./config'); var clayConfig = require('./config');
var customClay = require('./customClay'); var customClay = require('./customClay');
require('./weather');
new Clay(clayConfig, customClay); new Clay(clayConfig, customClay);
Pebble.addEventListener("ready", function () { Pebble.addEventListener("ready", function () {