mirror of
https://github.com/joeycastillo/second-movement.git
synced 2025-10-29 19:47:40 +00:00
migrate countdown to Second Movement
This commit is contained in:
parent
38189ad452
commit
4804b0bb38
1
Makefile
1
Makefile
@ -36,6 +36,7 @@ INCLUDES += \
|
||||
-I./watch-library/shared/watch \
|
||||
-I./watch-library/hardware/watch \
|
||||
-I./watch-faces/clock \
|
||||
-I./watch-faces/complication \
|
||||
-I./watch-faces/settings \
|
||||
|
||||
# Add your source files here.
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
const watch_face_t watch_faces[] = {
|
||||
simple_clock_face,
|
||||
world_clock_face,
|
||||
countdown_face,
|
||||
preferences_face,
|
||||
set_time_face,
|
||||
};
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include "simple_clock_face.h"
|
||||
#include "world_clock_face.h"
|
||||
#include "countdown_face.h"
|
||||
#include "set_time_face.h"
|
||||
#include "preferences_face.h"
|
||||
// New includes go above this line.
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
SRCS += \
|
||||
./watch-faces/clock/simple_clock_face.c \
|
||||
./watch-faces/clock/world_clock_face.c \
|
||||
./watch-faces/complication/countdown_face.c \
|
||||
./watch-faces/settings/set_time_face.c \
|
||||
./watch-faces/settings/preferences_face.c \
|
||||
|
||||
@ -45,10 +45,6 @@ static void abort_quick_ticks(countdown_state_t *state) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline int32_t get_tz_offset(movement_settings_t *settings) {
|
||||
return movement_timezone_offsets[settings->bit.time_zone] * 60;
|
||||
}
|
||||
|
||||
static inline void store_countdown(countdown_state_t *state) {
|
||||
/* Store set countdown time */
|
||||
state->set_hours = state->hours;
|
||||
@ -70,13 +66,14 @@ static inline void button_beep(movement_settings_t *settings) {
|
||||
}
|
||||
|
||||
static void schedule_countdown(countdown_state_t *state, movement_settings_t *settings) {
|
||||
(void) settings;
|
||||
|
||||
// Calculate the new state->now_ts but don't update it until we've updated the target -
|
||||
// avoid possible race where the old target is compared to the new time and immediately triggers
|
||||
uint32_t new_now = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), get_tz_offset(settings));
|
||||
uint32_t new_now = watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset());
|
||||
state->target_ts = watch_utility_offset_timestamp(new_now, state->hours, state->minutes, state->seconds);
|
||||
state->now_ts = new_now;
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(state->target_ts, get_tz_offset(settings));
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(state->target_ts, movement_get_current_timezone_offset());
|
||||
movement_schedule_background_task_for_face(state->watch_face_index, target_dt);
|
||||
}
|
||||
|
||||
@ -136,7 +133,7 @@ static void draw(countdown_state_t *state, uint8_t subsecond) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
watch_display_string(buf, 0);
|
||||
watch_display_text(WATCH_POSITION_FULL, buf);
|
||||
}
|
||||
|
||||
static void pause(countdown_state_t *state) {
|
||||
@ -203,7 +200,7 @@ void countdown_face_activate(movement_settings_t *settings, void *context) {
|
||||
countdown_state_t *state = (countdown_state_t *)context;
|
||||
if(state->mode == cd_running) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, get_tz_offset(settings));
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
watch_set_indicator(WATCH_INDICATOR_SIGNAL);
|
||||
}
|
||||
watch_set_colon();
|
||||
@ -224,7 +221,7 @@ bool countdown_face_loop(movement_event_t event, movement_settings_t *settings,
|
||||
break;
|
||||
case EVENT_TICK:
|
||||
if (quick_ticks_running) {
|
||||
if (watch_get_pin_level(BTN_ALARM))
|
||||
if (HAL_GPIO_BTN_ALARM_read())
|
||||
settings_increment(state);
|
||||
else
|
||||
abort_quick_ticks(state);
|
||||
Loading…
x
Reference in New Issue
Block a user