use consistent naming style for typedefs

This commit is contained in:
joeycastillo
2024-10-05 10:31:17 -04:00
parent 997f091c16
commit 0a9d71e2d4
70 changed files with 222 additions and 222 deletions

View File

@@ -92,7 +92,7 @@ bool close_enough_clock_face_loop(movement_event_t event, void *context) {
close_enough_clock_state_t *state = (close_enough_clock_state_t *)context;
char buf[11];
watch_date_time date_time;
watch_date_time_t date_time;
bool show_next_hour = false;
int prev_five_minute_period;
int prev_min_checked;

View File

@@ -34,7 +34,7 @@ static double better_fmod(double x, double y) {
return fmod(fmod(x, y) + y, y);
}
static void recalculate(watch_date_time utc_now, day_night_percentage_state_t *state) {
static void recalculate(watch_date_time_t utc_now, day_night_percentage_state_t *state) {
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
if (movement_location.reg == 0) {
@@ -61,7 +61,7 @@ void day_night_percentage_face_setup(uint8_t watch_face_index, void ** context_p
if (*context_ptr == NULL) {
*context_ptr = malloc(sizeof(day_night_percentage_state_t));
day_night_percentage_state_t *state = (day_night_percentage_state_t *)*context_ptr;
watch_date_time utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0);
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), movement_get_current_timezone_offset(), 0);
recalculate(utc_now, state);
}
}
@@ -74,8 +74,8 @@ bool day_night_percentage_face_loop(movement_event_t event, void *context) {
day_night_percentage_state_t *state = (day_night_percentage_state_t *)context;
char buf[12];
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0);
watch_date_time_t date_time = watch_rtc_get_date_time();
watch_date_time_t utc_now = watch_utility_date_time_convert_zone(date_time, movement_get_current_timezone_offset(), 0);
switch (event.event_type) {
case EVENT_ACTIVATE:

View File

@@ -72,7 +72,7 @@ bool decimal_time_face_loop(movement_event_t event, void *context) {
char buf[16];
uint8_t centihours, decimal_seconds;
watch_date_time date_time;
watch_date_time_t date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:

View File

@@ -52,7 +52,7 @@ bool french_revolutionary_face_loop(movement_event_t event, void *context) {
french_revolutionary_state_t *state = (french_revolutionary_state_t *)context;
char buf[11];
watch_date_time date_time;
watch_date_time_t date_time;
fr_decimal_time decimal_time;
switch (event.event_type) {
@@ -139,7 +139,7 @@ void french_revolutionary_face_resign(void *context) {
}
// Calculate decimal time from normal (24hr) time
fr_decimal_time get_decimal_time(watch_date_time *date_time) {
fr_decimal_time get_decimal_time(watch_date_time_t *date_time) {
uint32_t current_24hr_secs, current_decimal_seconds;
fr_decimal_time decimal_time;
// Current 24-hr time in seconds (There are 86400 of these in a day.)
@@ -167,7 +167,7 @@ fr_decimal_time get_decimal_time(watch_date_time *date_time) {
// - Decimal-time with normal time in the top (minutes first, then hours, due to display limitations)
// TODO: There is some power-saving stuff that simple clock does here around not redrawing characters that haven't changed, but we're not doing that here.
// I'll try to add that optimization could be added in a future commit.
void set_display_buffer(char *buf, french_revolutionary_state_t *state, fr_decimal_time *decimal_time, watch_date_time *date_time) {
void set_display_buffer(char *buf, french_revolutionary_state_t *state, fr_decimal_time *decimal_time, watch_date_time_t *date_time) {
switch (state->display_type) {
// Decimal time only
case 0:

View File

@@ -68,8 +68,8 @@ void french_revolutionary_face_activate(void *context);
bool french_revolutionary_face_loop(movement_event_t event, void *context);
void french_revolutionary_face_resign(void *context);
char fix_character_one(char digit);
fr_decimal_time get_decimal_time(watch_date_time *date_time);
void set_display_buffer(char *buf, french_revolutionary_state_t *state, fr_decimal_time *decimal_time, watch_date_time *date_time);
fr_decimal_time get_decimal_time(watch_date_time_t *date_time);
void set_display_buffer(char *buf, french_revolutionary_state_t *state, fr_decimal_time *decimal_time, watch_date_time_t *date_time);
#define french_revolutionary_face ((const watch_face_t){ \

View File

@@ -69,7 +69,7 @@ static void _h_to_hms(mars_clock_hms_t *date_time, double h) {
static void _update(mars_time_state_t *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());
// TODO: I'm skipping over some steps here.
// https://www.giss.nasa.gov/tools/mars24/help/algorithm.html

View File

@@ -27,7 +27,7 @@
#include "minimal_clock_face.h"
static void _minimal_clock_face_update_display() {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
char buffer[11];
if (!movement_clock_mode_24h()) {

View File

@@ -102,7 +102,7 @@ bool minute_repeater_decimal_face_loop(movement_event_t event, void *context) {
char buf[11];
uint8_t pos;
watch_date_time date_time;
watch_date_time_t date_time;
uint32_t previous_date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
@@ -230,7 +230,7 @@ movement_watch_face_advisory_t minute_repeater_decimal_face_advise(void *context
movement_watch_face_advisory_t retval = { 0 };
if (state->signal_enabled) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
retval.wants_background_task = date_time.unit.minute == 0;
}

View File

@@ -87,7 +87,7 @@ bool repetition_minute_face_loop(movement_event_t event, void *context) {
char buf[11];
uint8_t pos;
watch_date_time date_time;
watch_date_time_t date_time;
uint32_t previous_date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
@@ -213,7 +213,7 @@ movement_watch_face_advisory_t repetition_minute_face_advise(void *context) {
movement_watch_face_advisory_t retval = { 0 };
if (state->signal_enabled) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
retval.wants_background_task = date_time.unit.minute == 0;
}

View File

@@ -79,7 +79,7 @@ bool simple_clock_bin_led_face_loop(movement_event_t event, void *context) {
char buf[11];
uint8_t pos;
watch_date_time date_time;
watch_date_time_t date_time;
uint32_t previous_date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
@@ -214,7 +214,7 @@ movement_watch_face_advisory_t simple_clock_bin_led_face_advise(void *context) {
movement_watch_face_advisory_t retval = { 0 };
if (state->signal_enabled) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
retval.wants_background_task = date_time.unit.minute == 0;
}

View File

@@ -69,7 +69,7 @@ bool weeknumber_clock_face_loop(movement_event_t event, void *context) {
char buf[11];
uint8_t pos;
watch_date_time date_time;
watch_date_time_t date_time;
uint32_t previous_date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
@@ -148,7 +148,7 @@ movement_watch_face_advisory_t weeknumber_clock_face_advise(void *context) {
movement_watch_face_advisory_t retval = { 0 };
if (state->signal_enabled) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
retval.wants_background_task = date_time.unit.minute == 0;
}

View File

@@ -162,7 +162,7 @@ static bool mode_display(movement_event_t event, world_clock2_state_t *state)
uint32_t timestamp;
uint32_t previous_date_time;
watch_date_time date_time;
watch_date_time_t date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:

View File

@@ -109,7 +109,7 @@ void wyoscan_face_activate(void *context) {
bool wyoscan_face_loop(movement_event_t event, void *context) {
wyoscan_state_t *state = (wyoscan_state_t *)context;
watch_date_time date_time;
watch_date_time_t date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
break;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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:

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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 {

View File

@@ -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);
}

View File

@@ -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;
// Were at the mercy of the advise handler
// In Safari, the emulator triggers at the end of the minute

View File

@@ -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

View File

@@ -36,11 +36,11 @@
// Pressing the alarm button enters the log mode, where the main display shows the number of interrupts detected in each of the last
// 24 hours (the hour is shown in the top right digit and AM/PM indicator, if the clock is set to 12 hour mode)
static void _lis2dw_logging_face_update_display(lis2dw_logger_state_t *logger_state, lis2dw_wakeup_source wakeup_source) {
static void _lis2dw_logging_face_update_display(lis2dw_logger_state_t *logger_state, lis2dw_wakeup_source_t wakeup_source) {
char buf[14];
char time_indication_character;
int8_t pos;
watch_date_time date_time;
watch_date_time_t date_time;
if (logger_state->log_ticks) {
pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DW_LOGGING_NUM_DATA_POINTS;
@@ -92,7 +92,7 @@ static void _lis2dw_logging_face_update_display(lis2dw_logger_state_t *logger_st
}
static void _lis2dw_logging_face_log_data(lis2dw_logger_state_t *logger_state) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
// we get this call 15 minutes late; i.e. at 6:15 we're logging events for 6:00.
// so: if we're at the top of the hour, roll the hour back too (7:00 task logs data for 6:45)
if (date_time.unit.minute == 0) date_time.unit.hour = (date_time.unit.hour + 23) % 24;
@@ -136,8 +136,8 @@ void lis2dh_logging_face_activate(void *context) {
bool lis2dw_logging_face_loop(movement_event_t event, void *context) {
lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context;
lis2dw_wakeup_source wakeup_source = 0;
lis2dw_interrupt_source interrupt_source = 0;
lis2dw_wakeup_source_t wakeup_source = 0;
lis2dw_interrupt_source_t interrupt_source = 0;
switch (event.event_type) {
case EVENT_LIGHT_BUTTON_DOWN:
@@ -189,7 +189,7 @@ void lis2dw_logging_face_resign(void *context) {
movement_watch_face_advisory_t lis2dw_logging_face_advise(void *context) {
lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context;
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
movement_watch_face_advisory_t retval = { 0 };
// this is kind of an abuse of the API, but, let's use the 1 minute tick to shift all our data over.

View File

@@ -39,7 +39,7 @@
#define LIS2DW_LOGGING_NUM_DATA_POINTS (96)
typedef struct {
watch_date_time timestamp;
watch_date_time_t timestamp;
uint32_t x_interrupts;
uint32_t y_interrupts;
uint32_t z_interrupts;

View File

@@ -437,7 +437,7 @@ static void start_reading(accelerometer_data_acquisition_state_t *state) {
lis2dw_enable_fifo();
accelerometer_data_acquisition_record_t record;
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
state->starting_timestamp = watch_utility_date_time_to_unix_time(date_time, movement_get_current_timezone_offset());
record.header.info.record_type = ACCELEROMETER_DATA_ACQUISITION_HEADER;
record.header.info.range = ACCELEROMETER_RANGE;

View File

@@ -30,7 +30,7 @@
static void _thermistor_logging_face_log_data(thermistor_logger_state_t *logger_state) {
thermistor_driver_enable();
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
size_t pos = logger_state->data_points % THERMISTOR_LOGGING_NUM_DATA_POINTS;
logger_state->data[pos].timestamp.reg = date_time.reg;
@@ -51,7 +51,7 @@ static void _thermistor_logging_face_update_display(thermistor_logger_state_t *l
if (pos < 0) {
sprintf(buf, "TL%2dno dat", logger_state->display_index);
} else if (logger_state->ts_ticks) {
watch_date_time date_time = logger_state->data[pos].timestamp;
watch_date_time_t date_time = logger_state->data[pos].timestamp;
watch_set_colon();
if (clock_mode_24h) {
watch_set_indicator(WATCH_INDICATOR_24H);

View File

@@ -59,7 +59,7 @@
#define THERMISTOR_LOGGING_NUM_DATA_POINTS (36)
typedef struct {
watch_date_time timestamp;
watch_date_time_t timestamp;
float temperature_c;
} thermistor_logger_data_point_t;

View File

@@ -53,7 +53,7 @@ void thermistor_readout_face_activate(void *context) {
bool thermistor_readout_face_loop(movement_event_t event, void *context) {
(void) context;
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
switch (event.event_type) {
case EVENT_ALARM_BUTTON_DOWN:
movement_set_use_imperial_units(!movement_use_imperial_units());

View File

@@ -63,7 +63,7 @@ static void finetune_update_display(void) {
if (finetune_page == 0) {
watch_display_string("FT", 0);
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
sprintf(buf, "%02d", date_time.unit.second);
watch_display_string(buf, 8);
@@ -104,7 +104,7 @@ static void finetune_adjust_subseconds(int delta) {
watch_rtc_enable(false);
delay_ms(delta);
if (delta > 500) {
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 = (date_time.unit.second + 1) % 60;
if (date_time.unit.second == 0) { // Overflow
date_time.unit.minute = (date_time.unit.minute + 1) % 60;
@@ -143,7 +143,7 @@ bool finetune_face_loop(movement_event_t event, void *context) {
// If needed, update your display here, at canonical 0.5sec position.
// We flash green LED once per minute to measure clock error, when we are not on first screen
if (finetune_page!=0) {
watch_date_time date_time;
watch_date_time_t date_time;
date_time = watch_rtc_get_date_time();
if (date_time.unit.second == 0) {
watch_set_led_green();

View File

@@ -45,7 +45,7 @@ const float voltage_coefficient = 0.241666667 * dithering; // 10 * ppm/V. Nomina
static void nanosec_init_profile(void) {
nanosec_changed = true;
nanosec_state.correction_cadence = 10;
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
nanosec_state.last_correction_time = watch_utility_date_time_to_unix_time(date_time, 0);
// init data after changing profile - do that once per profile selection
@@ -259,7 +259,7 @@ static void nanosec_next_edit_screen(void) {
float nanosec_get_aging() // Returns aging correction in ppm
{
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
float years = (watch_utility_date_time_to_unix_time(date_time, 0) - nanosec_state.last_correction_time) / 31536000.0f; // Years passed since finetune
return years*nanosec_state.aging_ppm_pa/100.0f;
}
@@ -367,7 +367,7 @@ movement_watch_face_advisory_t nanosec_face_advise(void *context) {
// No need for background correction if we are on profile 0 - static hardware correction.
if (nanosec_state.correction_profile != 0) {
watch_date_time date_time = watch_rtc_get_date_time();
watch_date_time_t date_time = watch_rtc_get_date_time();
retval.wants_background_task = date_time.unit.minute % nanosec_state.correction_cadence == 0;
}

View File

@@ -54,7 +54,7 @@ typedef struct savefile {
uint32_t b5;
uint32_t b6;
uint32_t b7;
watch_date_time rtc;
watch_date_time_t rtc;
} savefile_t;
#define SAVE_LOAD_SLOTS 4

View File

@@ -32,7 +32,7 @@
char set_time_hackwatch_face_titles[][3] = {"HR", "M1", "SE", "YR", "MO", "DA", "ZO"};
#define set_time_hackwatch_face_NUM_SETTINGS (sizeof(set_time_hackwatch_face_titles) / sizeof(*set_time_hackwatch_face_titles))
watch_date_time date_time_settings;
watch_date_time_t date_time_settings;
void set_time_hackwatch_face_setup(uint8_t watch_face_index, void ** context_ptr) {
(void) watch_face_index;