use consistent naming style for typedefs
This commit is contained in:
@@ -75,7 +75,7 @@ static const uint8_t num_enabled_activities = sizeof(enabled_activities) / sizeo
|
||||
// One logged activity
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
// Activity's start time
|
||||
watch_date_time start_time;
|
||||
watch_date_time_t start_time;
|
||||
|
||||
// Total duration of activity, including time spend in paus
|
||||
uint16_t total_sec;
|
||||
@@ -132,7 +132,7 @@ typedef struct {
|
||||
uint16_t counter;
|
||||
|
||||
// Start of currently logged activity, if any
|
||||
watch_date_time start_time;
|
||||
watch_date_time_t start_time;
|
||||
|
||||
// Total seconds elapsed since logging started
|
||||
uint16_t curr_total_sec;
|
||||
@@ -197,7 +197,7 @@ static void _activity_activate(activity_state_t *state) {
|
||||
// Those are not up-to-date because ticks have not been coming
|
||||
if (state->le_state != 0 && state->mode == ACTM_LOGGING) {
|
||||
state->le_state = 2;
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_time, 0);
|
||||
uint32_t total_seconds = now_timestamp - start_timestamp;
|
||||
@@ -244,7 +244,7 @@ static void _activity_update_logging_screen(activity_state_t *state) {
|
||||
|
||||
// If we're in LE state: per-minute update is special
|
||||
if (state->le_state == 1) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_time, 0);
|
||||
uint32_t total_seconds = now_timestamp - start_timestamp;
|
||||
@@ -292,7 +292,7 @@ static void _activity_update_logging_screen(activity_state_t *state) {
|
||||
// Briefly, show time without seconds
|
||||
else {
|
||||
watch_clear_indicator(WATCH_INDICATOR_LAP);
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint8_t hour = now.unit.hour;
|
||||
if (!movement_clock_mode_24h()) {
|
||||
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||
@@ -397,7 +397,7 @@ static uint8_t _activity_get_next_byte(uint8_t *next_byte) {
|
||||
// Do this the hard way, byte by byte, to avoid high/low endedness issues
|
||||
// Higher order bytes first, is our serialization format
|
||||
uint8_t val;
|
||||
// watch_date_time start_time;
|
||||
// watch_date_time_t start_time;
|
||||
// uint16_t total_sec;
|
||||
// uint16_t pause_sec;
|
||||
// uint8_t activity_type;
|
||||
|
||||
@@ -79,7 +79,7 @@ static void _astronomy_face_recalculate(astronomy_state_t *state) {
|
||||
}
|
||||
#endif
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
date_time = watch_utility_date_time_from_unix_time(timestamp, 0);
|
||||
double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
|
||||
|
||||
@@ -35,7 +35,7 @@ static uint32_t _day_one_face_juliandaynum(uint16_t year, uint16_t month, uint16
|
||||
|
||||
static void _day_one_face_update(day_one_state_t *state) {
|
||||
char buf[15];
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
uint32_t julian_date = _day_one_face_juliandaynum(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day);
|
||||
uint32_t julian_birthdate = _day_one_face_juliandaynum(state->birth_year, state->birth_month, state->birth_day);
|
||||
if (julian_date < julian_birthdate) {
|
||||
@@ -148,7 +148,7 @@ bool day_one_face_loop(movement_event_t event, void *context) {
|
||||
break;
|
||||
// otherwise, check if we have to update. the display only needs to change at midnight!
|
||||
case PAGE_DISPLAY: {
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
if (date_time.unit.hour == 0 && date_time.unit.minute == 0 && date_time.unit.second == 0) {
|
||||
_day_one_face_update(state);
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ static bool _running_loop(movement_event_t event, void *context);
|
||||
static void _running_display(movement_event_t event, deadline_state_t *state);
|
||||
static void _setting_init(deadline_state_t *state);
|
||||
static bool _setting_loop(movement_event_t event, void *context);
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time date);
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time_t date);
|
||||
|
||||
/* Utility functions */
|
||||
static void _background_alarm_play(deadline_state_t *state);
|
||||
static void _background_alarm_schedule(deadline_state_t *state);
|
||||
static void _background_alarm_cancel(deadline_state_t *state);
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time date_time);
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time_t date_time);
|
||||
static inline void _change_tick_freq(uint8_t freq, deadline_state_t *state);
|
||||
static inline bool _is_leap(int16_t y);
|
||||
static inline int _days_in_month(int16_t mpnth, int16_t y);
|
||||
@@ -199,7 +199,7 @@ static inline void _change_tick_freq(uint8_t freq, deadline_state_t *state)
|
||||
/* Determine index of closest deadline */
|
||||
static uint8_t _closest_deadline(deadline_state_t *state)
|
||||
{
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
uint32_t min_ts = UINT32_MAX;
|
||||
uint8_t min_index = 0;
|
||||
@@ -243,7 +243,7 @@ static void _background_alarm_cancel(deadline_state_t *state)
|
||||
static inline void _reset_deadline(deadline_state_t *state)
|
||||
{
|
||||
/* Get current time and reset hours/minutes/seconds */
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
date_time.unit.second = 0;
|
||||
date_time.unit.minute = 0;
|
||||
date_time.unit.hour = 0;
|
||||
@@ -256,7 +256,7 @@ static inline void _reset_deadline(deadline_state_t *state)
|
||||
}
|
||||
|
||||
/* Increment date in settings mode. Function taken from `set_time_face.c` */
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time date_time)
|
||||
static void _increment_date(deadline_state_t *state, watch_date_time_t date_time)
|
||||
{
|
||||
const uint8_t days_in_month[12] = { 31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31 };
|
||||
|
||||
@@ -307,7 +307,7 @@ static void _running_display(movement_event_t event, deadline_state_t *state)
|
||||
else
|
||||
watch_clear_indicator(WATCH_INDICATOR_BELL);
|
||||
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
|
||||
/* Deadline expired */
|
||||
@@ -323,7 +323,7 @@ static void _running_display(movement_event_t event, deadline_state_t *state)
|
||||
}
|
||||
|
||||
/* Get date time structs */
|
||||
watch_date_time deadline = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], movement_get_current_timezone_offset()
|
||||
watch_date_time_t deadline = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], movement_get_current_timezone_offset()
|
||||
);
|
||||
|
||||
/* Calculate naive difference of dates */
|
||||
@@ -430,7 +430,7 @@ static bool _running_loop(movement_event_t event, void *context)
|
||||
}
|
||||
|
||||
/* Update display in settings mode */
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time date_time)
|
||||
static void _setting_display(movement_event_t event, deadline_state_t *state, watch_date_time_t date_time)
|
||||
{
|
||||
char buf[11];
|
||||
|
||||
@@ -493,7 +493,7 @@ static void _setting_init(deadline_state_t *state)
|
||||
static bool _setting_loop(movement_event_t event, void *context)
|
||||
{
|
||||
deadline_state_t *state = (deadline_state_t *) context;
|
||||
watch_date_time date_time;
|
||||
watch_date_time_t date_time;
|
||||
date_time = watch_utility_date_time_from_unix_time(state->deadlines[state->current_index], movement_get_current_timezone_offset());
|
||||
|
||||
if (event.event_type != EVENT_BACKGROUND_TASK)
|
||||
@@ -614,7 +614,7 @@ movement_watch_face_advisory_t deadline_face_advise(void *context)
|
||||
return false;
|
||||
|
||||
/* Determine closest deadline */
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
uint32_t next_ts = state->deadlines[_closest_deadline(state)];
|
||||
|
||||
@@ -627,7 +627,7 @@ movement_watch_face_advisory_t deadline_face_advise(void *context)
|
||||
return false;
|
||||
|
||||
/* Deadline within next minute. Let's set up an alarm */
|
||||
watch_date_time next = watch_utility_date_time_from_unix_time(next_ts, movement_get_current_timezone_offset());
|
||||
watch_date_time_t next = watch_utility_date_time_from_unix_time(next_ts, movement_get_current_timezone_offset());
|
||||
movement_request_wake();
|
||||
movement_schedule_background_task_for_face(state->face_idx, next);
|
||||
return false;
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "../../../watch-library/hardware/hri/hri_tc_l22.h"
|
||||
#endif
|
||||
|
||||
static const watch_date_time distant_future = {.unit = {0, 0, 0, 1, 1, 63}};
|
||||
static const watch_date_time_t distant_future = {.unit = {0, 0, 0, 1, 1, 63}};
|
||||
static bool _is_running;
|
||||
static uint32_t _ticks;
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ static void display_fuel(uint8_t subsecond, uint8_t difficulty) {
|
||||
|
||||
static void check_and_reset_hi_score(endless_runner_state_t *state) {
|
||||
// Resets the hi score at the beginning of each month.
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
if ((state -> year_last_hi_score != date_time.unit.year) ||
|
||||
(state -> month_last_hi_score != date_time.unit.month))
|
||||
{
|
||||
@@ -320,8 +320,8 @@ static void display_title(endless_runner_state_t *state) {
|
||||
display_difficulty(difficulty);
|
||||
}
|
||||
|
||||
static void display_time(watch_date_time date_time, bool clock_mode_24h) {
|
||||
static watch_date_time previous_date_time;
|
||||
static void display_time(watch_date_time_t date_time, bool clock_mode_24h) {
|
||||
static watch_date_time_t previous_date_time;
|
||||
char buf[6 + 1];
|
||||
|
||||
// If the hour needs updating or it's the first time displaying the time
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
|
||||
static inline uint32_t today_unix(const uint32_t utc_offset) {
|
||||
const watch_date_time dt = watch_rtc_get_date_time();
|
||||
const watch_date_time_t dt = watch_rtc_get_date_time();
|
||||
return watch_utility_convert_to_unix_time(dt.unit.year + 2020, dt.unit.month,
|
||||
dt.unit.day, 0, 0, 0, utc_offset);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static inline void _inc_uint8(uint8_t *value, uint8_t step, uint8_t max) {
|
||||
|
||||
static uint32_t _get_now_ts() {
|
||||
// returns the current date time as unix timestamp
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
return watch_utility_date_time_to_unix_time(now, 0);
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ static void _set_next_timestamp(interval_face_state_t *state) {
|
||||
if (delta <= 0) delta = 1;
|
||||
_target_ts += delta;
|
||||
// schedule next background task
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(_target_ts, 0);
|
||||
watch_date_time_t target_dt = watch_utility_date_time_from_unix_time(_target_ts, 0);
|
||||
movement_schedule_background_task_for_face(state->face_idx, target_dt);
|
||||
// play sound
|
||||
watch_buzzer_play_sequence(sound_seq, NULL);
|
||||
@@ -363,7 +363,7 @@ static void _resume_paused_timer(interval_face_state_t *state) {
|
||||
// resume paused timer
|
||||
_now_ts = _get_now_ts();
|
||||
_target_ts += _now_ts - _paused_ts;
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(_target_ts, 0);
|
||||
watch_date_time_t target_dt = watch_utility_date_time_from_unix_time(_target_ts, 0);
|
||||
movement_schedule_background_task_for_face(state->face_idx, target_dt);
|
||||
state->face_state = interval_state_running;
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
|
||||
@@ -98,7 +98,7 @@ static inline uint32_t total_days_tracked(menstrual_cycle_state_t *state) {
|
||||
return 0;
|
||||
|
||||
// Otherwise, set the start date to the first day of the first tracked cycle
|
||||
watch_date_time date_time_start;
|
||||
watch_date_time_t date_time_start;
|
||||
date_time_start.unit.second = 0;
|
||||
date_time_start.unit.minute = 0;
|
||||
date_time_start.unit.hour = 0;
|
||||
@@ -107,7 +107,7 @@ static inline uint32_t total_days_tracked(menstrual_cycle_state_t *state) {
|
||||
date_time_start.unit.year = state->dates.bit.first_year;
|
||||
|
||||
// Get the current date and time
|
||||
watch_date_time date_time_now = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time_now = watch_rtc_get_date_time();
|
||||
|
||||
// Convert the start date and current date to Unix time
|
||||
uint32_t unix_start = watch_utility_date_time_to_unix_time(date_time_start, state->utc_offset);
|
||||
@@ -176,7 +176,7 @@ typedef enum Fertile_Window {first_day, last_day} fertile_window;
|
||||
static inline uint32_t get_day_pk_fert(menstrual_cycle_state_t *state, fertile_window which_day) {
|
||||
|
||||
// Get the date of the previous period
|
||||
watch_date_time date_prev_period;
|
||||
watch_date_time_t date_prev_period;
|
||||
date_prev_period.unit.second = 0;
|
||||
date_prev_period.unit.minute = 0;
|
||||
date_prev_period.unit.hour = 0;
|
||||
@@ -210,7 +210,7 @@ static inline bool inside_fert_window(menstrual_cycle_state_t *state) {
|
||||
return false;
|
||||
|
||||
// Get the current date/time
|
||||
watch_date_time date_time_now = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time_now = watch_rtc_get_date_time();
|
||||
|
||||
// Check if the current day falls between the first and last predicted peak fertility days
|
||||
if (get_day_pk_fert(state, first_day) > get_day_pk_fert(state, last_day)) { // We are crossing over the end of the month
|
||||
@@ -229,7 +229,7 @@ static inline bool inside_fert_window(menstrual_cycle_state_t *state) {
|
||||
static inline void update_shortest_longest_cycle(menstrual_cycle_state_t *state) {
|
||||
|
||||
// Get the date of the previous menstrual cycle
|
||||
watch_date_time date_prev_period;
|
||||
watch_date_time_t date_prev_period;
|
||||
date_prev_period.unit.second = 0;
|
||||
date_prev_period.unit.minute = 0;
|
||||
date_prev_period.unit.hour = 0;
|
||||
@@ -305,7 +305,7 @@ void menstrual_cycle_face_activate(void *context) {
|
||||
|
||||
bool menstrual_cycle_face_loop(movement_event_t event, void *context) {
|
||||
menstrual_cycle_state_t *state = (menstrual_cycle_state_t *)context;
|
||||
watch_date_time date_period;
|
||||
watch_date_time_t date_period;
|
||||
uint8_t current_page = state->current_page;
|
||||
uint8_t first_day_fert;
|
||||
uint8_t last_day_fert;
|
||||
|
||||
@@ -56,7 +56,7 @@ void moon_phase_face_activate(void *context) {
|
||||
static void _update(moon_phase_state_t *state, uint32_t offset) {
|
||||
(void)state;
|
||||
char buf[11];
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
uint32_t now = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset()) + offset;
|
||||
date_time = watch_utility_date_time_from_unix_time(now, movement_get_current_timezone_offset());
|
||||
double currentfrac = fmod(now - FIRST_MOON, LUNAR_SECONDS) / LUNAR_SECONDS;
|
||||
@@ -132,7 +132,7 @@ static void _update(moon_phase_state_t *state, uint32_t offset) {
|
||||
|
||||
bool moon_phase_face_loop(movement_event_t event, void *context) {
|
||||
moon_phase_state_t *state = (moon_phase_state_t *)context;
|
||||
watch_date_time date_time;
|
||||
watch_date_time_t date_time;
|
||||
|
||||
switch (event.event_type) {
|
||||
case EVENT_ACTIVATE:
|
||||
|
||||
@@ -47,7 +47,7 @@ static const char orrery_celestial_body_names[NUM_AVAILABLE_BODIES][3] = {
|
||||
};
|
||||
|
||||
static void _orrery_face_recalculate(orrery_state_t *state) {
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
|
||||
date_time = watch_utility_date_time_from_unix_time(timestamp, 0);
|
||||
double jd = astro_convert_date_to_julian_date(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
|
||||
|
||||
@@ -133,10 +133,10 @@ static void _planetary_solar_phases(planetary_hours_state_t *state) {
|
||||
// location detected
|
||||
state->no_location = false;
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
watch_date_time scratch_time; // scratchpad, contains different values at different times
|
||||
watch_date_time midnight;
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
watch_date_time_t scratch_time; // scratchpad, contains different values at different times
|
||||
watch_date_time_t midnight;
|
||||
scratch_time.reg = midnight.reg = utc_now.reg;
|
||||
midnight.unit.hour = midnight.unit.minute = midnight.unit.second = 0; // start of the day at midnight
|
||||
|
||||
@@ -227,7 +227,7 @@ static void _planetary_hours(planetary_hours_state_t *state) {
|
||||
char ruler[3];
|
||||
uint8_t weekday, planet, planetary_hour;
|
||||
uint32_t current_hour_epoch;
|
||||
watch_date_time scratch_time;
|
||||
watch_date_time_t scratch_time;
|
||||
|
||||
// check if we have a location. If not, display error
|
||||
if ( state->no_location ) {
|
||||
@@ -236,8 +236,8 @@ static void _planetary_hours(planetary_hours_state_t *state) {
|
||||
}
|
||||
|
||||
// get current time
|
||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
current_hour_epoch = watch_utility_date_time_to_unix_time(utc_now, 0);
|
||||
|
||||
// set the current planetary hour as default screen
|
||||
|
||||
@@ -128,10 +128,10 @@ static void _planetary_solar_phase(planetary_time_state_t *state) {
|
||||
// location detected
|
||||
state->no_location = false;
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
watch_date_time scratch_time; // scratchpad, contains different values at different times
|
||||
watch_date_time midnight;
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0); // the current date / time in UTC
|
||||
watch_date_time_t scratch_time; // scratchpad, contains different values at different times
|
||||
watch_date_time_t midnight;
|
||||
scratch_time.reg = midnight.reg = utc_now.reg;
|
||||
midnight.unit.hour = midnight.unit.minute = midnight.unit.second = 0; // start of the day at midnight
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ typedef struct {
|
||||
bool day_ruler;
|
||||
bool no_location;
|
||||
sunrise_sunset_state_t sunstate;
|
||||
watch_date_time scratch;
|
||||
watch_date_time_t scratch;
|
||||
} planetary_time_state_t;
|
||||
|
||||
void planetary_time_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
||||
|
||||
@@ -164,7 +164,7 @@ static void ring(sailing_state_t *state) {
|
||||
return;
|
||||
}
|
||||
state->nextbeep_ts = state->target_ts - beepseconds[beepflag+1];
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(state->nextbeep_ts, get_tz_offset(settings));
|
||||
watch_date_time_t target_dt = watch_utility_date_time_from_unix_time(state->nextbeep_ts, get_tz_offset(settings));
|
||||
movement_schedule_background_task_for_face(state->watch_face_index, target_dt);
|
||||
//background task is set, now we have time to play the tune. If this is cancelled accidentally, the next alarm will still ring. Sound is implemented non-blocking, so that neither buttons nor display output are compromised.
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -192,7 +192,7 @@ static void start(sailing_state_t *state) {//gets called by starting / switching
|
||||
beepflag++;
|
||||
}
|
||||
if (state->index > 5 || state->minutes[state->index] == 0) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, get_tz_offset(settings));
|
||||
state->target_ts = state->now_ts;
|
||||
if (alarmflag != 0){
|
||||
@@ -203,7 +203,7 @@ static void start(sailing_state_t *state) {//gets called by starting / switching
|
||||
}
|
||||
movement_request_tick_frequency(1); //synchronises tick with the moment the button was pressed. Solves 1s offset between sound and display, solves up to +-0.5s offset between button action and display.
|
||||
state->mode = sl_running;
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, get_tz_offset(settings));
|
||||
state->target_ts = watch_utility_offset_timestamp(state->now_ts, 0, state->minutes[state->index], 0);
|
||||
ring(state, settings);
|
||||
@@ -249,11 +249,11 @@ void sailing_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
void sailing_face_activate(void *context) {
|
||||
sailing_state_t *state = (sailing_state_t *)context;
|
||||
if(state->mode == sl_running) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, get_tz_offset(settings));
|
||||
}
|
||||
if(state->mode == sl_counting) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, get_tz_offset(settings));
|
||||
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "ships_bell_face.h"
|
||||
|
||||
static void ships_bell_ring() {
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
|
||||
date_time.unit.hour %= 4;
|
||||
date_time.unit.hour = date_time.unit.hour == 0 && date_time.unit.minute < 30 ? 4 : date_time.unit.hour;
|
||||
@@ -54,7 +54,7 @@ static void ships_bell_draw(ships_bell_state_t *state) {
|
||||
sprintf(buf, " ");
|
||||
}
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
date_time.unit.hour %= 4;
|
||||
|
||||
sprintf(buf + 1, " %d%02d%02d", date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
|
||||
@@ -130,7 +130,7 @@ movement_watch_face_advisory_t ships_bell_face_advise(void *context) {
|
||||
|
||||
if (!state->bell_enabled) return retval;
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
if (!(date_time.unit.minute == 0 || date_time.unit.minute == 30)) return retval;
|
||||
|
||||
date_time.unit.hour %= 12;
|
||||
|
||||
@@ -77,7 +77,7 @@ static double calculate_solstice_equinox(uint16_t year, uint8_t k) {
|
||||
}
|
||||
|
||||
// Convert JDE to Gergorian datetime as per Meeus Ch 7
|
||||
static watch_date_time jde_to_date_time(double JDE) {
|
||||
static watch_date_time_t jde_to_date_time(double JDE) {
|
||||
double tmp = JDE + 0.5;
|
||||
double Z = floor(tmp);
|
||||
double F = fmod(tmp, 1);
|
||||
@@ -110,7 +110,7 @@ static watch_date_time jde_to_date_time(double JDE) {
|
||||
double minutes = fmod(hours, 1) * 60;
|
||||
double seconds = fmod(minutes, 1) * 60;
|
||||
|
||||
watch_date_time result = {.unit = {
|
||||
watch_date_time_t result = {.unit = {
|
||||
floor(seconds),
|
||||
floor(minutes),
|
||||
floor(hours),
|
||||
@@ -135,7 +135,7 @@ void solstice_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
*context_ptr = malloc(sizeof(solstice_state_t));
|
||||
solstice_state_t *state = (solstice_state_t *)*context_ptr;
|
||||
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->year = now.unit.year;
|
||||
state->index = 0;
|
||||
calculate_datetimes(state, settings);
|
||||
@@ -155,14 +155,14 @@ void solstice_face_activate(void *context) {
|
||||
|
||||
static void show_main_screen(solstice_state_t *state) {
|
||||
char buf[11];
|
||||
watch_date_time date_time = state->datetimes[state->index];
|
||||
watch_date_time_t date_time = state->datetimes[state->index];
|
||||
sprintf(buf, " %2d %2d%02d", date_time.unit.year + 20, date_time.unit.month, date_time.unit.day);
|
||||
watch_display_string(buf, 0);
|
||||
}
|
||||
|
||||
static void show_date_time(solstice_state_t *state) {
|
||||
char buf[11];
|
||||
watch_date_time date_time = state->datetimes[state->index];
|
||||
watch_date_time_t date_time = state->datetimes[state->index];
|
||||
if (!movement_clock_mode_24h()) {
|
||||
if (date_time.unit.hour < 12) {
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
watch_date_time datetimes[4];
|
||||
watch_date_time_t datetimes[4];
|
||||
uint8_t year;
|
||||
uint8_t index;
|
||||
} solstice_state_t;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
// distant future for background task: January 1, 2083
|
||||
// see stopwatch_face_activate for details
|
||||
static const watch_date_time distant_future = {
|
||||
static const watch_date_time_t distant_future = {
|
||||
.unit = {0, 0, 0, 1, 1, 63}
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ void stopwatch_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
|
||||
static void _stopwatch_face_update_display(stopwatch_state_t *stopwatch_state, bool show_seconds) {
|
||||
if (stopwatch_state->running) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(stopwatch_state->start_time, 0);
|
||||
stopwatch_state->seconds_counted = now_timestamp - start_timestamp;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
typedef struct {
|
||||
bool running;
|
||||
watch_date_time start_time; // while running, show the difference between this time and now
|
||||
watch_date_time_t start_time; // while running, show the difference between this time and now
|
||||
uint32_t seconds_counted; // set this value when paused, and show that instead.
|
||||
} stopwatch_state_t;
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ bool tachymeter_face_loop(movement_event_t event, void *context) {
|
||||
}
|
||||
// Stop running
|
||||
state->running = false;
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_seconds, 0);
|
||||
// Total time in centiseconds
|
||||
|
||||
@@ -84,7 +84,7 @@ typedef struct {
|
||||
bool editing; // editing distance
|
||||
uint8_t active_digit; // active digit at editing distance
|
||||
uint8_t animation_state; // running animation state
|
||||
watch_date_time start_seconds; // start_seconds
|
||||
watch_date_time_t start_seconds; // start_seconds
|
||||
int8_t start_subsecond; // start_subsecond count (each count = 250 ms)
|
||||
distance_digits_t dist_digits; // distance digitwise
|
||||
uint32_t distance; // distance
|
||||
|
||||
@@ -101,7 +101,7 @@ bool tempchart_face_loop(movement_event_t event, void *context) {
|
||||
thermistor_driver_enable();
|
||||
float temperature_c = thermistor_driver_get_temperature();
|
||||
thermistor_driver_disable();
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
|
||||
int temp = round(temperature_c * 2);
|
||||
if ((temp < 0) || (temp >= 70)) break;
|
||||
@@ -137,7 +137,7 @@ movement_watch_face_advisory_t tempchart_face_advise(void *context) {
|
||||
(void) context;
|
||||
movement_watch_face_advisory_t retval = { 0 };
|
||||
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
// Updating data every 5 minutes
|
||||
retval.wants_background_task = date_time.unit.minute % 5 == 0;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ static void _draw(time_left_state_t *state, uint8_t subsecond) {
|
||||
watch_display_character(_state_titles[state->current_page][2], 3);
|
||||
if (state->current_page < TIME_LEFT_FACE_SETTINGS_STATE) {
|
||||
// we are displaying days left or days from birth
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
uint32_t julian_current_day = _juliandaynum(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day);
|
||||
uint32_t julian_target_day = _juliandaynum(state->target_date.bit.year, state->target_date.bit.month, state->target_date.bit.day);
|
||||
int32_t days_left = julian_target_day - julian_current_day;
|
||||
@@ -221,7 +221,7 @@ void time_left_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
state->birth_date.bit.day = 1;
|
||||
watch_store_backup_data(state->birth_date.reg, 2);
|
||||
// set target date to today + 10 years (just to have any value)
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
state->target_date.bit.year = date_time.unit.year + WATCH_RTC_REFERENCE_YEAR + 10;
|
||||
state->target_date.bit.month = date_time.unit.month;
|
||||
state->target_date.bit.day = date_time.unit.day;
|
||||
@@ -233,7 +233,7 @@ void time_left_face_activate(void *context) {
|
||||
time_left_state_t *state = (time_left_state_t *)context;
|
||||
|
||||
// stash the current year, useful in birthday setting mode
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
state->current_year = date_time.unit.year + WATCH_RTC_REFERENCE_YEAR;
|
||||
_quick_ticks_running = false;
|
||||
// fetch the user's birth date from the birthday register
|
||||
@@ -263,7 +263,7 @@ bool time_left_face_loop(movement_event_t event, void *context) {
|
||||
_draw(state, subsecond);
|
||||
} else {
|
||||
// otherwise, check if we have to update. the display only needs to change at midnight
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
watch_date_time_t date_time = watch_rtc_get_date_time();
|
||||
if (date_time.unit.hour == 0 && date_time.unit.minute == 0 && date_time.unit.second == 0) {
|
||||
_draw(state, subsecond);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ static void _signal_callback() {
|
||||
|
||||
static void _start(timer_state_t *state, bool with_beep) {
|
||||
if (state->timers[state->current_timer].value == 0) return;
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
if (state->mode == pausing)
|
||||
state->target_ts = state->now_ts + state->paused_left;
|
||||
@@ -54,7 +54,7 @@ static void _start(timer_state_t *state, bool with_beep) {
|
||||
state->timers[state->current_timer].unit.hours,
|
||||
state->timers[state->current_timer].unit.minutes,
|
||||
state->timers[state->current_timer].unit.seconds);
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(state->target_ts, movement_get_current_timezone_offset());
|
||||
watch_date_time_t target_dt = watch_utility_date_time_from_unix_time(state->target_ts, movement_get_current_timezone_offset());
|
||||
state->mode = running;
|
||||
movement_schedule_background_task_for_face(state->watch_face_index, target_dt);
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
@@ -203,7 +203,7 @@ void timer_face_activate(void *context) {
|
||||
watch_display_string("TR", 0);
|
||||
watch_set_colon();
|
||||
if(state->mode == running) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
} else {
|
||||
|
||||
@@ -42,13 +42,13 @@ static uint8_t get_length(tomato_state_t *state) {
|
||||
}
|
||||
|
||||
static void tomato_start(tomato_state_t *state) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
int8_t length = (int8_t) get_length(state);
|
||||
|
||||
state->mode = tomato_run;
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
state->target_ts = watch_utility_offset_timestamp(state->now_ts, 0, length, 0);
|
||||
watch_date_time target_dt = watch_utility_date_time_from_unix_time(state->target_ts, movement_get_current_timezone_offset());
|
||||
watch_date_time_t target_dt = watch_utility_date_time_from_unix_time(state->target_ts, movement_get_current_timezone_offset());
|
||||
movement_schedule_background_task(target_dt);
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ void tomato_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||
void tomato_face_activate(void *context) {
|
||||
tomato_state_t *state = (tomato_state_t *)context;
|
||||
if (state->mode == tomato_run) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
|
||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ movement_watch_face_advisory_t wake_face_advise(void *context) {
|
||||
movement_watch_face_advisory_t retval = { 0 };
|
||||
|
||||
if ( state->mode ) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
retval.wants_background_task = state->hour==now.unit.hour && state->minute==now.unit.minute;
|
||||
// We’re at the mercy of the advise handler
|
||||
// In Safari, the emulator triggers at the ›end‹ of the minute
|
||||
|
||||
@@ -293,7 +293,7 @@ static void display_wait(wordle_state_t *state) {
|
||||
#endif
|
||||
|
||||
static uint32_t get_day_unix_time(void) {
|
||||
watch_date_time now = watch_rtc_get_date_time();
|
||||
watch_date_time_t now = watch_rtc_get_date_time();
|
||||
#if WORDLE_USE_DAILY_STREAK == 2
|
||||
now.unit.hour = now.unit.minute = now.unit.second = 0;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user