Show date on accel
This commit is contained in:
+29
-1
@@ -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);
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user