From 381db14404ec8d54b5933278d41ba27258ed5929 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 1 Jun 2026 23:11:57 -0400 Subject: [PATCH] Show date on accel --- src/c/main.c | 30 +++++++++++++++++++++++++++++- src/pkjs/weather.js | 6 ------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/c/main.c b/src/c/main.c index 62c443b..e8b6b0e 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -40,6 +40,8 @@ static GBitmap *s_e_icon; static GBitmap *s_f_icon; // tracking statics +static bool s_showing_date = false; +static AppTimer *s_date_timer = NULL; static bool s_pkjs_ready = false; static bool s_low_fuel_indicator = false; static int s_batt_level; @@ -279,8 +281,32 @@ static void update_minute_1() { } } -static void minute_handler(struct tm *tick_time, TimeUnits units_changed) { +static void date_timeout(void *context) { + s_showing_date = false; + s_date_timer = NULL; update_minute_1(); +} + +static void accel_tap_handler(AccelAxisType axis, int32_t direction) { + time_t temp = time(NULL); + struct tm *tick_time = localtime(&temp); + static char s_date_buffer[16]; + strftime(s_date_buffer, sizeof(s_date_buffer), "%m%d", tick_time); + for (int i = 0; i < 4; ++i) { + bitmap_layer_set_bitmap(s_time_fg_layers[i], s_font_bitmaps[s_date_buffer[i] - '0']); + } + + s_showing_date = true; + if (s_date_timer) { + app_timer_cancel(s_date_timer); + } + s_date_timer = app_timer_register(3000, date_timeout, NULL); +} + +static void minute_handler(struct tm *tick_time, TimeUnits units_changed) { + if (!s_showing_date) { + update_minute_1(); + } if (s_pkjs_ready && tick_time->tm_min % 30 == 0) { update_temperature(); } @@ -402,9 +428,11 @@ static void init() { tick_timer_service_subscribe(MINUTE_UNIT, minute_handler); battery_state_service_subscribe(batt_callback); + accel_tap_service_subscribe(accel_tap_handler); } static void deinit() { + accel_data_service_unsubscribe(); battery_state_service_unsubscribe(); tick_timer_service_unsubscribe(); layer_destroy(s_fuel_layer); diff --git a/src/pkjs/weather.js b/src/pkjs/weather.js index f20884f..e4f79b8 100644 --- a/src/pkjs/weather.js +++ b/src/pkjs/weather.js @@ -23,12 +23,6 @@ function locationSuccess(pos) { const normalized_temp = clamped_temp - min_temp; const temp_bars = Math.round(normalized_temp / 4); - console.log("Current temp: " + current_temp); - console.log("Min temp: " + min_temp); - console.log("Max temp: " + max_temp); - console.log("Clamped temp: " + clamped_temp); - console.log("Bars " + temp_bars); - Pebble.sendAppMessage({ PKJS_TEMP_BAR_COUNT: temp_bars }); } );