]> git.earman.xyz Git - sensor-watch.git/commitdiff
use consistent naming style for typedefs
authorjoeycastillo <joeycastillo@utexas.edu>
Sat, 5 Oct 2024 14:31:17 +0000 (10:31 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sat, 5 Oct 2024 14:36:58 +0000 (10:36 -0400)
70 files changed:
movement.c
movement.h
movement/watch_faces/clock/close_enough_clock_face.c
movement/watch_faces/clock/day_night_percentage_face.c
movement/watch_faces/clock/decimal_time_face.c
movement/watch_faces/clock/french_revolutionary_face.c
movement/watch_faces/clock/french_revolutionary_face.h
movement/watch_faces/clock/mars_time_face.c
movement/watch_faces/clock/minimal_clock_face.c
movement/watch_faces/clock/minute_repeater_decimal_face.c
movement/watch_faces/clock/repetition_minute_face.c
movement/watch_faces/clock/simple_clock_bin_led_face.c
movement/watch_faces/clock/weeknumber_clock_face.c
movement/watch_faces/clock/world_clock2_face.c
movement/watch_faces/clock/wyoscan_face.c
movement/watch_faces/complication/activity_face.c
movement/watch_faces/complication/astronomy_face.c
movement/watch_faces/complication/day_one_face.c
movement/watch_faces/complication/deadline_face.c
movement/watch_faces/complication/dual_timer_face.c
movement/watch_faces/complication/endless_runner_face.c
movement/watch_faces/complication/habit_face.c
movement/watch_faces/complication/interval_face.c
movement/watch_faces/complication/menstrual_cycle_face.c
movement/watch_faces/complication/moon_phase_face.c
movement/watch_faces/complication/orrery_face.c
movement/watch_faces/complication/planetary_hours_face.c
movement/watch_faces/complication/planetary_time_face.c
movement/watch_faces/complication/planetary_time_face.h
movement/watch_faces/complication/sailing_face.c
movement/watch_faces/complication/ships_bell_face.c
movement/watch_faces/complication/solstice_face.c
movement/watch_faces/complication/solstice_face.h
movement/watch_faces/complication/stopwatch_face.c
movement/watch_faces/complication/stopwatch_face.h
movement/watch_faces/complication/tachymeter_face.c
movement/watch_faces/complication/tachymeter_face.h
movement/watch_faces/complication/tempchart_face.c
movement/watch_faces/complication/time_left_face.c
movement/watch_faces/complication/timer_face.c
movement/watch_faces/complication/tomato_face.c
movement/watch_faces/complication/wake_face.c
movement/watch_faces/complication/wordle_face.c
movement/watch_faces/demo/lis2dw_logging_face.c
movement/watch_faces/demo/lis2dw_logging_face.h
movement/watch_faces/sensor/accelerometer_data_acquisition_face.c
movement/watch_faces/sensor/thermistor_logging_face.c
movement/watch_faces/sensor/thermistor_logging_face.h
movement/watch_faces/sensor/thermistor_readout_face.c
movement/watch_faces/settings/finetune_face.c
movement/watch_faces/settings/nanosec_face.c
movement/watch_faces/settings/save_load_face.h
movement/watch_faces/settings/set_time_hackwatch_face.c
watch-faces/clock/beats_face.c
watch-faces/clock/clock_face.c
watch-faces/clock/world_clock_face.c
watch-faces/complication/advanced_alarm_face.c
watch-faces/complication/countdown_face.c
watch-faces/complication/fast_stopwatch_face.c
watch-faces/complication/sunrise_sunset_face.c
watch-faces/complication/sunrise_sunset_face.h
watch-faces/sensor/voltage_face.c
watch-faces/settings/set_time_face.c
watch-library/shared/driver/lis2dw.c
watch-library/shared/driver/lis2dw.h
watch-library/shared/watch/watch_rtc.h
watch-library/shared/watch/watch_utility.c
watch-library/shared/watch/watch_utility.h
watch-library/simulator/watch/watch_private.c
watch-library/simulator/watch/watch_rtc.c

index 0ee7e00a7ab6014f6cb4ba195571f36382751633..624ed296d7472ec542b29937f4fe7a13aa0cf447 100644 (file)
@@ -52,7 +52,7 @@
 
 movement_state_t movement_state;
 void * watch_face_contexts[MOVEMENT_NUM_FACES];
-watch_date_time scheduled_tasks[MOVEMENT_NUM_FACES];
+watch_date_time_t scheduled_tasks[MOVEMENT_NUM_FACES];
 const int32_t movement_le_inactivity_deadlines[8] = {INT_MAX, 600, 3600, 7200, 21600, 43200, 86400, 604800};
 const int16_t movement_timeout_inactivity_deadlines[4] = {60, 120, 300, 1800};
 movement_event_t event;
@@ -76,7 +76,7 @@ void yield(void) {
     cdc_task();
 }
 
-static udatetime_t _movement_convert_date_time_to_udate(watch_date_time date_time) {
+static udatetime_t _movement_convert_date_time_to_udate(watch_date_time_t date_time) {
     return (udatetime_t) {
         .date.dayofmonth = date_time.unit.day,
         .date.dayofweek = dayofweek(UYEAR_FROM_YEAR(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR), date_time.unit.month, date_time.unit.day),
@@ -92,13 +92,13 @@ static bool _movement_update_dst_offset_cache(void) {
     uzone_t local_zone;
     udatetime_t udate_time;
     bool dst_changed = false;
-    watch_date_time system_date_time = watch_rtc_get_date_time();
+    watch_date_time_t system_date_time = watch_rtc_get_date_time();
 
     printf("current zone: %d\n", movement_state.settings.bit.time_zone);
 
     for (uint8_t i = 0; i < NUM_ZONE_NAMES; i++) {
         unpack_zone(&zone_defns[i], "", &local_zone);
-        watch_date_time date_time = watch_utility_date_time_convert_zone(system_date_time, 0, local_zone.offset.hours * 3600 + local_zone.offset.minutes * 60);
+        watch_date_time_t date_time = watch_utility_date_time_convert_zone(system_date_time, 0, local_zone.offset.hours * 3600 + local_zone.offset.minutes * 60);
 
         if (!!local_zone.rules_len) {
             // if local zone has DST rules, we need to see if DST applies.
@@ -144,7 +144,7 @@ static inline void _movement_disable_fast_tick_if_possible(void) {
 }
 
 static void _movement_handle_top_of_minute(void) {
-    watch_date_time date_time = watch_rtc_get_date_time();
+    watch_date_time_t date_time = watch_rtc_get_date_time();
 
     // update the DST offset cache every 15 minutes, since someplace in the world could change.
     if (date_time.unit.minute % 15 == 0) {
@@ -171,7 +171,7 @@ static void _movement_handle_top_of_minute(void) {
 }
 
 static void _movement_handle_scheduled_tasks(void) {
-    watch_date_time date_time = watch_rtc_get_date_time();
+    watch_date_time_t date_time = watch_rtc_get_date_time();
     uint8_t num_active_tasks = 0;
 
     for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
@@ -281,7 +281,7 @@ void movement_move_to_next_face(void) {
     movement_move_to_face((movement_state.current_face_idx + 1) % face_max);
 }
 
-void movement_schedule_background_task(watch_date_time date_time) {
+void movement_schedule_background_task(watch_date_time_t date_time) {
     movement_schedule_background_task_for_face(movement_state.current_face_idx, date_time);
 }
 
@@ -289,8 +289,8 @@ void movement_cancel_background_task(void) {
     movement_cancel_background_task_for_face(movement_state.current_face_idx);
 }
 
-void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time date_time) {
-    watch_date_time now = watch_rtc_get_date_time();
+void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time_t date_time) {
+    watch_date_time_t now = watch_rtc_get_date_time();
     if (date_time.reg > now.reg) {
         movement_state.has_scheduled_background_task = true;
         scheduled_tasks[watch_face_index].reg = date_time.reg;
@@ -394,23 +394,23 @@ void movement_set_timezone_index(uint8_t value) {
     movement_state.settings.bit.time_zone = value;
 }
 
-watch_date_time movement_get_utc_date_time(void) {
+watch_date_time_t movement_get_utc_date_time(void) {
     return watch_rtc_get_date_time();
 }
 
-watch_date_time movement_get_date_time_in_zone(uint8_t zone_index) {
+watch_date_time_t movement_get_date_time_in_zone(uint8_t zone_index) {
     int32_t offset = movement_get_current_timezone_offset_for_zone(zone_index);
     return watch_utility_date_time_convert_zone(watch_rtc_get_date_time(), 0, offset);
 }
 
-watch_date_time movement_get_local_date_time(void) {
-    watch_date_time date_time = watch_rtc_get_date_time();
+watch_date_time_t movement_get_local_date_time(void) {
+    watch_date_time_t date_time = watch_rtc_get_date_time();
     return watch_utility_date_time_convert_zone(date_time, 0, movement_get_current_timezone_offset());
 }
 
-void movement_set_local_date_time(watch_date_time date_time) {
+void movement_set_local_date_time(watch_date_time_t date_time) {
     int32_t current_offset = movement_get_current_timezone_offset();
-    watch_date_time utc_date_time = watch_utility_date_time_convert_zone(date_time, current_offset, 0);
+    watch_date_time_t utc_date_time = watch_utility_date_time_convert_zone(date_time, current_offset, 0);
     watch_rtc_set_date_time(utc_date_time);
 
     // this may seem wasteful, but if the user's local time is in a zone that observes DST,
@@ -496,7 +496,7 @@ void movement_set_alarm_enabled(bool value) {
 void app_init(void) {
     _watch_init();
 
-    watch_date_time date_time = watch_rtc_get_date_time();
+    watch_date_time_t date_time = watch_rtc_get_date_time();
     if (date_time.reg == 0) {
         // at first boot, set year to 2024
         date_time.unit.year = 2024 - WATCH_RTC_REFERENCE_YEAR;
@@ -593,7 +593,7 @@ void app_setup(void) {
         _movement_update_dst_offset_cache();
 
         // set up the 1 minute alarm (for background tasks and low power updates)
-        watch_date_time alarm_time;
+        watch_date_time_t alarm_time;
         alarm_time.reg = 0;
         alarm_time.unit.second = 59; // after a match, the alarm fires at the next rising edge of CLK_RTC_CNT, so 59 seconds lets us update at :00
         watch_rtc_register_alarm_callback(cb_alarm_fired, alarm_time, ALARM_MATCH_SS);
@@ -857,7 +857,7 @@ void cb_fast_tick(void) {
 
 void cb_tick(void) {
     event.event_type = EVENT_TICK;
-    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.second != movement_state.last_second) {
         // TODO: can we consolidate these two ticks?
         if (movement_state.settings.bit.le_interval && movement_state.le_mode_ticks > 0) movement_state.le_mode_ticks--;
index 72ac9d7c0f5d00b7ff01672bb7db3f4a4f41f4fd..879ec3b75ccc31e63bef6fae3cf6f1f4293f9e6f 100644 (file)
@@ -312,14 +312,14 @@ void movement_request_tick_frequency(uint8_t freq);
 
 // note: watch faces can only schedule a background task when in the foreground, since
 // movement will associate the scheduled task with the currently active face.
-void movement_schedule_background_task(watch_date_time date_time);
+void movement_schedule_background_task(watch_date_time_t date_time);
 
 // note: watch faces can only cancel their background task when in the foreground, since
 // movement will associate the scheduled task with the currently active face.
 void movement_cancel_background_task(void);
 
 // these functions should work around the limitation of the above functions, which will be deprecated.
-void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time date_time);
+void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time_t date_time);
 void movement_cancel_background_task_for_face(uint8_t watch_face_index);
 
 void movement_request_sleep(void);
@@ -337,11 +337,11 @@ int32_t movement_get_current_timezone_offset(void);
 int32_t movement_get_timezone_index(void);
 void movement_set_timezone_index(uint8_t value);
 
-watch_date_time movement_get_utc_date_time(void);
-watch_date_time movement_get_local_date_time(void);
-watch_date_time movement_get_date_time_in_zone(uint8_t zone_index);
+watch_date_time_t movement_get_utc_date_time(void);
+watch_date_time_t movement_get_local_date_time(void);
+watch_date_time_t movement_get_date_time_in_zone(uint8_t zone_index);
 
-void movement_set_local_date_time(watch_date_time date_time);
+void movement_set_local_date_time(watch_date_time_t date_time);
 
 bool movement_button_should_sound(void);
 void movement_set_button_should_sound(bool value);
index 2f34c293e7a4e408a09d6eb726610c1f26584719..98a8e7032ce3d39ad2470f111f1d6a9a5dfe3771 100644 (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;
index dfac555a2a7b121eb0b31b3e31f55e05912e1bea..fbd3d455142a368bf0fe2e6f292b876382321949 100644 (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:
index 95e6a51a59411620bacfe24bc28d0d21b7b3e04e..5056302f1e45ce9e9bc06f484d3c1d930f1607eb 100644 (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:
index 3b2e9c396293e23f2d9370365574caf04d63d162..83564a3ad81ece093e05f7d8b4903fffaecf4a9a 100644 (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:
index 60bacfc4fcc3022b912f3aebc4ffe6e2dc2c6c1d..554bceaf61c2b382c2ad4d5fa5f143032db55d5c 100644 (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){ \
index cb49ac961bdce23123a11247f8eabca2ce5c1900..5c55cd193147db51443528be9e2241c5753ac88e 100644 (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
index bccd11538ace3dd5b010e18f5e2d39c937553af9..cb66323d59ebb232ff1840568299bc863245e6ac 100644 (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()) {
index 7582a7a4372071d36a8e268dfc82f624086f0130..9f5eb43c7df9170f6146798785480eb23c4df884 100644 (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;
     }
 
index 0d792a3f6a365ad7a0d1b6cd936a120faf3f81fc..b475b45ee3c4b336592a40117f00e9759b1ad5cf 100644 (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;
     }
 
index cbe1593548fd160e407a0058e84ed97f5b62c3cb..527b1cd14e5802ac3b03026dd0caee4498a2d72a 100644 (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;
     }
 
index 2a270a2e3020d9fa94487e9d7ad3ede8677a24b1..3a153e185072a4ce7ad10b4401f98b463ec3ee04 100644 (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;
     }
 
index 5dca9267cc22ff8101a3fd65ad5d4d601042a9d9..e79f2df740ceea0a1e398eee38e56382c3cf79a8 100644 (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:
index 1598193f365436eb3b00206a2a9cd2274c2cf91e..bf7b5e1c704c5c1b86d5d0649c27f0135c75a45d 100644 (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;
index 063f03b5cac152f1fa23d6af935464fa8655edf6..58107493df74ff219ba861a741efe88f9dac9187 100644 (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;
index a02dd06d0ef86ce4aed3d81c804fec483df685ee..61df67be9bb11327a5cf603840a30b8652b577fd 100644 (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);
index 46b2c4fc03f28cd42b59611e2e9ee22e771f1009..0810b9aaf3d12c369b5900d4951d87081460f52d 100644 (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);
                     }
index 7fbea72e93688b082f875e3dcb54bd75eb141905..ed4b5a0605bf2d3d8279acd5c68322b4d0450c0f 100644 (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;
index e7bc5b3ff742be52bcf63cc846c53dc9184a13fc..e819d59833f4811c68a4cd89a84cacead1685731 100644 (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;
 
index d15517eedfdc9e7842d907ec82c72198a8961c0e..f305ac4fe0883d75497a1b53cea168fd773f0525 100644 (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
index 693d7a0f7099dfc907696b70c0157ef4ac66e129..1045032035dda73c7601725999104e6dd7e0c489 100644 (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);
 }
index d32c2dc8c826b4aa96bd35129ad0e4493d229004..c354e7226d336f4cdd5aea867b1eb520780290cf 100644 (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);
index 2ef2a89bd47d60b827d0eb10a23d17cccab552d2..ccd678cd052530f7f9eecf610fcea9878d2b0e5e 100644 (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;
index 7729fed75aabe6d8eff0825c2f06dea9433af514..7b28e446a847bd5d00943d47bc302e33a67b287e 100644 (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:
index 0b538bfed198385891e8ae58aad5d1604de2c359..fba821b019a6b0efe7ff941c8928a57df924358f 100644 (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);
index 73cf747db446484d16ce1042cdeeb061604bc4e7..f4011ba41f0e40dbcc5d2b3adfd0787984c86687 100644 (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
index d0ed3df4d3c2042b3f72e5e505a981ac518b70fd..d19937b9f4c01c57fa8a26157f56e8fcb975059f 100644 (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
 
index 1acdb11d30d32a15dd74f4269138b9b82a3fcc5b..0dd594ef76663a268650ac8741281a5e92472bb0 100644 (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);
index 32c6fa6fe6b9bac604ecb65af06781eba748d7cd..9f8109baee3795f9883177b31b22a50c4f0198ca 100644 (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);
     }
index fe364fed8bdc6a6a4bdf9841616c03381c7d9815..fc4d51b4c7e3aa64f8a699b34f36a6b4007932ea 100644 (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;
index 58139f4ec31c72f9c624baa05135947db954c4de..d981c4f59ca9898e68bb3da3399378a73d84094c 100644 (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);
index 17e630d4ceca118147a19c638d316d099f6b11c7..57dcb4ee7accc2afbd80128a3c1bab5dcf37ac38 100644 (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;
index ecaba0196a1107a252e652df7f1bc73aec4c5385..c2ef89970c35e7cfecfc784ca39cd87ccbb34d8f 100644 (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;
index cf0d8fe6ac98ebb68cab57026e69a50ccadcdd05..5f9d66bb2bec286949b621fa7a7fcf802bcfb36c 100644 (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;
 
index 8ed9b6e677e64dad68a6258ebbdb98d2e7fd9062..ddaafc5d802d93d5a1224c1ac35988ed41d1c8d0 100644 (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
index 98f96e25253d2f5b6dc670bce87839a55f52aaaf..d299cb83ef61d5dbe1ec7c5b867aefe94f996452 100644 (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
index 07ade30ab53de26c087ac42b35412588229c1312..e8e1cfa8174621562bd6e147a405aaca9d211434 100644 (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;
 
index 9e8caf8706869174b4b0ec6bc6dee89c5317a3d8..b91db201b3c17f87f2f42a05cf3c5cf8562222ef 100644 (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);
                 }
index b993a615b043f1853149560f0500bd3b1e6f8677..338269a306ae4afc7fbde9eee9b61d5c7e9b5a44 100644 (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 {
index 6e9f6bbd88bba00260420fec6d4a2a6743418ccc..d33f8f0f66b46348b310dcafe6948eaba0e2fc27 100644 (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);
     }
index ca3a96ceef45745a6a057d3060f277d182239ee5..30982da0e500a2ccd665883720300d17852e0ade 100644 (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;
         // We’re at the mercy of the advise handler
         // In Safari, the emulator triggers at the ›end‹ of the minute
index cae36eb406551c6464d49e893bd8887effeb07cf..e7ab39f9f61402a2b7d7a0cc5c494f49d8b39928 100644 (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
index 969ad0ef31bfb3c5ec7c3be52c290e4d1b4fa8a1..76108a0b6e4750b026cd4432566485e52c6882a5 100644 (file)
 // 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.
index cfae1a716b47091f91463952e3616e8abd4f5640..49d48eec9db183e8aa91abf60fe4fb1ef215bba7 100644 (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;
index f5548f5c9a26f4428e9d2217d2371c148308fc00..5784bd2c978cf2d408b6bf19062529b33ca97ba4 100644 (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;
index 171daf271945725973f3c178a29cefb84a856005..77bc24255d5dfec2812bad10340d6711af54e3c9 100644 (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);
index a32a274b44340a17d8ec8300c9baf823bd19c475..51755730da1a249e4d26fe39ec0ec91a95627819 100644 (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;
 
index bbd120f3d754a0619b7d43f0ffccb01883a53a9a..520ac4ff81b094851f4dfb24ed1e158fa4e9d831 100644 (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());
index da26c2f6948bc37184c731ceb61f62ec17dc8955..e1b64a9c543a8412e3a4cd44b355e0703ceddb0f 100644 (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();
index ed5d73296d6ea9ab09341bc35f85fd6f931eeb7d..8efdacca942298cb9d50eb3a888dcd40ab2e61d1 100644 (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;
     }
 
index 786b5f546bfb1d841267e340cce399f842c8fe75..4e962fbfe564b3205b83e30b1f86e9f4d2bc60ad 100644 (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
index d10917a87183e80815e12324a6c172c7094a5400..94557be2f032a49b3b158f266578d89a89e858db 100644 (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;
index b2bde552ebec5ae7d0239ce488e698c8663187fe..16fc0b8608362b8ff925d8f92ba64569f87b5e52 100644 (file)
@@ -53,7 +53,7 @@ bool beats_face_loop(movement_event_t event, void *context) {
     char buf[16];
     uint32_t centibeats;
 
-    watch_date_time date_time;
+    watch_date_time_t date_time;
     switch (event.event_type) {
         case EVENT_ACTIVATE:
         case EVENT_TICK:
index 0fb63451380b335491b59cdb2ec616ea9e9d9cb9..f120b1094e0925ddf817c3965491d8db407674b3 100644 (file)
@@ -44,7 +44,7 @@
 
 typedef struct {
     struct {
-        watch_date_time previous;
+        watch_date_time_t previous;
     } date_time;
     uint8_t last_battery_check;
     uint8_t watch_face_index;
@@ -72,11 +72,11 @@ static void clock_indicate_24h() {
     clock_indicate(WATCH_INDICATOR_24H, !!movement_clock_mode_24h());
 }
 
-static bool clock_is_pm(watch_date_time date_time) {
+static bool clock_is_pm(watch_date_time_t date_time) {
     return date_time.unit.hour >= 12;
 }
 
-static void clock_indicate_pm(watch_date_time date_time) {
+static void clock_indicate_pm(watch_date_time_t date_time) {
     if (movement_clock_mode_24h()) { return; }
     clock_indicate(WATCH_INDICATOR_PM, clock_is_pm(date_time));
 }
@@ -86,7 +86,7 @@ static void clock_indicate_low_available_power(clock_state_t *clock) {
     clock_indicate(WATCH_INDICATOR_LAP, clock->battery_low);
 }
 
-static watch_date_time clock_24h_to_12h(watch_date_time date_time) {
+static watch_date_time_t clock_24h_to_12h(watch_date_time_t date_time) {
     date_time.unit.hour %= 12;
 
     if (date_time.unit.hour == 0) {
@@ -96,7 +96,7 @@ static watch_date_time clock_24h_to_12h(watch_date_time date_time) {
     return date_time;
 }
 
-static void clock_check_battery_periodically(clock_state_t *clock, watch_date_time date_time) {
+static void clock_check_battery_periodically(clock_state_t *clock, watch_date_time_t date_time) {
     // check the battery voltage once a day
     if (date_time.unit.day == clock->last_battery_check) { return; }
 
@@ -116,7 +116,7 @@ static void clock_toggle_time_signal(clock_state_t *clock) {
     clock_indicate_time_signal(clock);
 }
 
-static void clock_display_all(watch_date_time date_time) {
+static void clock_display_all(watch_date_time_t date_time) {
     char buf[8 + 1];
 
     snprintf(
@@ -134,7 +134,7 @@ static void clock_display_all(watch_date_time date_time) {
     watch_display_text(WATCH_POSITION_BOTTOM, buf + 2);
 }
 
-static bool clock_display_some(watch_date_time current, watch_date_time previous) {
+static bool clock_display_some(watch_date_time_t current, watch_date_time_t previous) {
     if ((current.reg >> 6) == (previous.reg >> 6)) {
         // everything before seconds is the same, don't waste cycles setting those segments.
 
@@ -167,7 +167,7 @@ static bool clock_display_some(watch_date_time current, watch_date_time previous
     }
 }
 
-static void clock_display_clock(clock_state_t *clock, watch_date_time current) {
+static void clock_display_clock(clock_state_t *clock, watch_date_time_t current) {
     if (!clock_display_some(current, clock->date_time.previous)) {
         if (movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_12H) {
             clock_indicate_pm(current);
@@ -177,7 +177,7 @@ static void clock_display_clock(clock_state_t *clock, watch_date_time current) {
     }
 }
 
-static void clock_display_low_energy(watch_date_time date_time) {
+static void clock_display_low_energy(watch_date_time_t date_time) {
     if (movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_12H) {
         clock_indicate_pm(date_time);
         date_time = clock_24h_to_12h(date_time);
@@ -240,7 +240,7 @@ void clock_face_activate(void *context) {
 
 bool clock_face_loop(movement_event_t event, void *context) {
     clock_state_t *state = (clock_state_t *) context;
-    watch_date_time current;
+    watch_date_time_t current;
 
     switch (event.event_type) {
         case EVENT_LOW_ENERGY_UPDATE:
@@ -282,7 +282,7 @@ movement_watch_face_advisory_t clock_face_advise(void *context) {
     clock_state_t *state = (clock_state_t *) context;
 
     if (state->time_signal_enabled) {
-        watch_date_time date_time = movement_get_local_date_time();
+        watch_date_time_t date_time = movement_get_local_date_time();
         retval.wants_background_task = date_time.unit.minute == 0;
     }
 
index e67dbb216aa55f37b284d23f578c9876e3b81321..4b819ee4c79cf12781757c8433f29016ff07bce6 100644 (file)
@@ -58,7 +58,7 @@ static bool world_clock_face_do_display_mode(movement_event_t event, world_clock
     char buf[11];
 
     uint32_t previous_date_time;
-    watch_date_time date_time;
+    watch_date_time_t date_time;
     switch (event.event_type) {
         case EVENT_ACTIVATE:
             if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
index ea012a508250cc00fde573d4128af1316f21b8e9..a8662c83ff2b843ef4ae22ed1f0e2a5ee839f400 100644 (file)
@@ -54,7 +54,7 @@ static const uint8_t _buzzer_segdata[3][2] = {{0, 3}, {1, 3}, {2, 2}};
 
 static int8_t _wait_ticks;
 
-static uint8_t _get_weekday_idx(watch_date_time date_time) {
+static uint8_t _get_weekday_idx(watch_date_time_t date_time) {
     date_time.unit.year += 20;
     if (date_time.unit.month <= 2) {
         date_time.unit.month += 12;
@@ -143,7 +143,7 @@ static void _alarm_resume_setting(alarm_state_t *state, uint8_t subsecond) {
 static void _alarm_update_alarm_enabled(alarm_state_t *state) {
     // save indication for active alarms to movement settings
     bool active_alarms = false;
-    watch_date_time now;
+    watch_date_time_t now;
     bool now_init = false;
     uint8_t weekday_idx;
     uint16_t now_minutes_of_day;
@@ -244,7 +244,7 @@ movement_watch_face_advisory_t advanced_alarm_face_advise(void *context) {
     alarm_state_t *state = (alarm_state_t *)context;
     movement_watch_face_advisory_t retval = { 0 };
 
-    watch_date_time now = movement_get_local_date_time();
+    watch_date_time_t now = movement_get_local_date_time();
     // just a failsafe: never fire more than one alarm within a minute
     if (state->alarm_handled_minute == now.unit.minute) return retval;
     state->alarm_handled_minute = now.unit.minute;
index 34ea4341bbec60267d4257a8d3b115a522246808..4de0592042aa72de3018184402b04cb537767e96 100644 (file)
@@ -72,7 +72,7 @@ static void schedule_countdown(countdown_state_t *state) {
     uint32_t new_now = watch_utility_date_time_to_unix_time(movement_get_utc_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, 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_for_face(state->watch_face_index, target_dt);
 }
 
@@ -196,7 +196,7 @@ void countdown_face_setup(uint8_t watch_face_index, void ** context_ptr) {
 void countdown_face_activate(void *context) {
     countdown_state_t *state = (countdown_state_t *)context;
     if(state->mode == cd_running) {
-        watch_date_time now = movement_get_utc_date_time();
+        watch_date_time_t now = movement_get_utc_date_time();
         state->now_ts = watch_utility_date_time_to_unix_time(now, movement_get_current_timezone_offset());
         watch_set_indicator(WATCH_INDICATOR_SIGNAL);
     }
index 1116898be95a19e12a4af483dcd4832af3c93bc7..d28832c410b898e11bf600ce17475e4d9db9afc3 100644 (file)
@@ -48,7 +48,7 @@
 #endif
 
 // distant future for background task: January 1, 2083
-static const watch_date_time distant_future = {
+static const watch_date_time_t distant_future = {
     .unit = {0, 0, 0, 1, 1, 63}
 };
 
index 474fe9d7aabb163be563993ea7cf631e8cee2a7c..1a657104754dfb266f8242eae3032c96486f67ff 100644 (file)
@@ -39,7 +39,7 @@
 
 static const uint8_t _location_count = sizeof(longLatPresets) / sizeof(long_lat_presets_t);
 
-static void _sunrise_sunset_set_expiration(sunrise_sunset_state_t *state, watch_date_time next_rise_set) {
+static void _sunrise_sunset_set_expiration(sunrise_sunset_state_t *state, watch_date_time_t next_rise_set) {
     uint32_t timestamp = watch_utility_date_time_to_unix_time(next_rise_set, 0);
     state->rise_set_expires = watch_utility_date_time_from_unix_time(timestamp + 60, 0);
 }
@@ -62,9 +62,9 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
         return;
     }
 
-    watch_date_time date_time = movement_get_local_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_t date_time = movement_get_local_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
     scratch_time.reg = utc_now.reg;
 
     // Weird quirky unsigned things were happening when I tried to cast these directly to doubles below.
@@ -76,8 +76,8 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
     double lon = (double)lon_centi / 100.0;
 
     // sunriset returns the rise/set times as signed decimal hours in UTC.
-    // this can mean hours below 0 or above 31, which won't fit into a watch_date_time struct.
-    // to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time.
+    // this can mean hours below 0 or above 31, which won't fit into a watch_date_time_t struct.
+    // to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time_t.
     double hours_from_utc = ((double)movement_get_current_timezone_offset()) / 3600.0;
 
     // we loop twice because if it's after sunset today, we need to recalculate to display values for tomorrow.
@@ -338,7 +338,7 @@ bool sunrise_sunset_face_loop(movement_event_t event, void *context) {
                 // if entering low energy mode, start tick animation
                 if (event.event_type == EVENT_LOW_ENERGY_UPDATE && !watch_sleep_animation_is_running()) watch_start_sleep_animation(1000);
                 // check if we need to update the display
-                watch_date_time date_time = movement_get_local_date_time();
+                watch_date_time_t date_time = movement_get_local_date_time();
                 if (date_time.reg >= state->rise_set_expires.reg) {
                     // and on the off chance that this happened before EVENT_TIMEOUT snapped us back to rise/set 0, go back now
                     state->rise_index = 0;
index 133eed0282cd11de4f963c782b7961691a8e4d1e..2380105e62545713333492be682db5f146ce58a4 100644 (file)
@@ -52,7 +52,7 @@ typedef struct {
     uint8_t rise_index;
     uint8_t active_digit;
     bool location_changed;
-    watch_date_time rise_set_expires;
+    watch_date_time_t rise_set_expires;
     sunrise_sunset_lat_lon_settings_t working_latitude;
     sunrise_sunset_lat_lon_settings_t working_longitude;
     uint8_t longLatToUse;
index b172ec6b50e7cff0ebb7f683dc7e53b4d31824a0..17ab5ea2fbf06a77648e2579e49cdffe0899306a 100644 (file)
@@ -47,7 +47,7 @@ void voltage_face_activate(void *context) {
 
 bool voltage_face_loop(movement_event_t event, void *context) {
     (void) context;
-    watch_date_time date_time;
+    watch_date_time_t date_time;
     switch (event.event_type) {
         case EVENT_ACTIVATE:
             _voltage_face_update_display();
index a1c41c978b6408c476d0440e3b5896050ca450e2..8092e871278c0b37e6a727c5ffdd978e81fee243 100644 (file)
@@ -35,7 +35,7 @@ const char set_time_face_titles[SET_TIME_FACE_NUM_SETTINGS][3] = {"HR", "M1", "S
 static bool _quick_ticks_running;
 static int32_t current_offset;
 
-static void _handle_alarm_button(watch_date_time date_time, uint8_t current_page) {
+static void _handle_alarm_button(watch_date_time_t date_time, uint8_t current_page) {
     // handles short or long pressing of the alarm button
 
     switch (current_page) {
@@ -90,7 +90,7 @@ void set_time_face_activate(void *context) {
 
 bool set_time_face_loop(movement_event_t event, void *context) {
     uint8_t current_page = *((uint8_t *)context);
-    watch_date_time date_time = movement_get_local_date_time();
+    watch_date_time_t date_time = movement_get_local_date_time();
 
     switch (event.event_type) {
         case EVENT_TICK:
index b90acc7e895e4ed142c120408c9e050cdb949688..6ea50e1dae4bd717c7bb256b6f215d676d67aff8 100644 (file)
@@ -229,10 +229,10 @@ void lis2dw_configure_wakeup_int1(uint8_t threshold, bool latch, bool active_sta
     watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7, configuration | LIS2DW_CTRL7_VAL_INTERRUPTS_ENABLE);
 }
 
-lis2dw_wakeup_source lis2dw_get_wakeup_source() {
-    return (lis2dw_wakeup_source) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_SRC);
+lis2dw_wakeup_source_t lis2dw_get_wakeup_source() {
+    return (lis2dw_wakeup_source_t) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_SRC);
 }
 
-lis2dw_interrupt_source lis2dw_get_interrupt_source(void) {
-    return (lis2dw_interrupt_source) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_ALL_INT_SRC);
+lis2dw_interrupt_source_t lis2dw_get_interrupt_source(void) {
+    return (lis2dw_interrupt_source_t) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_ALL_INT_SRC);
 }
index c791c461ac96c1e85c2c7d1582d83ba2fe6f2f00..29bb2833af68951dd2eb1f352e9de5aa50d23d09 100644 (file)
@@ -106,7 +106,7 @@ typedef enum {
   LIS2DW_INTERRUPT_SRC_SINGLE_TAP   = 0b00000100,
   LIS2DW_INTERRUPT_SRC_WU           = 0b00000010,
   LIS2DW_INTERRUPT_SRC_FF           = 0b00000001
-} lis2dw_interrupt_source;
+} lis2dw_interrupt_source_t;
 
 typedef enum {
   LIS2DW_WAKEUP_SRC_FREEFALL    = 0b00100000,
@@ -115,7 +115,7 @@ typedef enum {
   LIS2DW_WAKEUP_SRC_WAKEUP_X    = 0b00000100,
   LIS2DW_WAKEUP_SRC_WAKEUP_Y    = 0b00000010,
   LIS2DW_WAKEUP_SRC_WAKEUP_Z    = 0b00000001
-} lis2dw_wakeup_source;
+} lis2dw_wakeup_source_t;
 
 // Assumes SA0 is high; if low, its 0x18
 #define LIS2DW_ADDRESS (0x19)
@@ -337,8 +337,8 @@ void lis2dw_clear_fifo(void);
 
 void lis2dw_configure_wakeup_int1(uint8_t threshold, bool latch, bool active_state);
 
-lis2dw_interrupt_source lis2dw_get_interrupt_source(void);
+lis2dw_interrupt_source_t lis2dw_get_interrupt_source(void);
 
-lis2dw_wakeup_source lis2dw_get_wakeup_source(void);
+lis2dw_wakeup_source_t lis2dw_get_wakeup_source(void);
 
 #endif // LIS2DW_H
index 64d107fb10b7569ec0b56c9cf8adedd84f4cd635..c590040cec1fd7c522c161d198792563d491bb23 100644 (file)
@@ -45,7 +45,7 @@ extern watch_cb_t a4_callback;
 
 #define WATCH_RTC_REFERENCE_YEAR (2020)
 
-#define watch_date_time rtc_date_time_t
+#define watch_date_time_t rtc_date_time_t
 
 /** @brief Called by main.c to check if the RTC is enabled.
   * You may call this function, but outside of app_init, it should always return true.
index 337797e1645cddc0637dbe3244dec0d3e343acc7..81211f6ec7a12729ca4fedfc5754e74bd133b914 100644 (file)
 #include <math.h>
 #include "watch_utility.h"
 
-const char * watch_utility_get_weekday(watch_date_time date_time) {
+const char * watch_utility_get_weekday(watch_date_time_t date_time) {
     static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"};
     return weekdays[watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1];
 }
 
-const char * watch_utility_get_long_weekday(watch_date_time date_time) {
+const char * watch_utility_get_long_weekday(watch_date_time_t date_time) {
     static const char weekdays[7][4] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
     return weekdays[watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1];
 }
@@ -190,7 +190,7 @@ uint32_t watch_utility_convert_to_unix_time(uint16_t year, uint8_t month, uint8_
     return timestamp;
 }
 
-uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, int32_t utc_offset) {
+uint32_t watch_utility_date_time_to_unix_time(watch_date_time_t date_time, int32_t utc_offset) {
     return watch_utility_convert_to_unix_time(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, utc_offset);
 }
 
@@ -200,8 +200,8 @@ uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, int32_t
 #define DAYS_PER_100Y (365*100 + 24)
 #define DAYS_PER_4Y   (365*4   + 1)
 
-watch_date_time watch_utility_date_time_from_unix_time(uint32_t timestamp, int32_t utc_offset) {
-    watch_date_time retval;
+watch_date_time_t watch_utility_date_time_from_unix_time(uint32_t timestamp, int32_t utc_offset) {
+    watch_date_time_t retval;
     retval.reg = 0;
     int32_t days, secs;
     int32_t remdays, remsecs, remyears;
@@ -270,7 +270,7 @@ watch_date_time watch_utility_date_time_from_unix_time(uint32_t timestamp, int32
     return retval;
 }
 
-watch_date_time watch_utility_date_time_convert_zone(watch_date_time date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset) {
+watch_date_time_t watch_utility_date_time_convert_zone(watch_date_time_t date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset) {
     uint32_t timestamp = watch_utility_date_time_to_unix_time(date_time, origin_utc_offset);
     return watch_utility_date_time_from_unix_time(timestamp, destination_utc_offset);
 }
@@ -286,7 +286,7 @@ watch_duration_t watch_utility_seconds_to_duration(uint32_t seconds) {
     return retval;
 }
 
-bool watch_utility_convert_to_12_hour(watch_date_time *date_time) {
+bool watch_utility_convert_to_12_hour(watch_date_time_t *date_time) {
     bool is_pm = date_time->unit.hour > 11;
     date_time->unit.hour %= 12;
     if (date_time->unit.hour == 0) date_time->unit.hour = 12;
index 6cb35553e4df81dd8d4d9a7da001d9b7933d577f..169e573bd73cb6c2f01dfc5d12ea054e9c841137 100644 (file)
@@ -46,14 +46,14 @@ typedef struct {
 } watch_duration_t;
 
 /** @brief Returns a two-letter weekday for the given timestamp, suitable for display in positions 0-1 of the watch face
-  * @param date_time The watch_date_time whose weekday you want.
+  * @param date_time The watch_date_time_t whose weekday you want.
   */
-const char * watch_utility_get_weekday(watch_date_time date_time);
+const char * watch_utility_get_weekday(watch_date_time_t date_time);
 
 /** @brief Returns a three-letter weekday for the given timestamp, suitable for display on the custom LCD
-  * @param date_time The watch_date_time whose weekday you want.
+  * @param date_time The watch_date_time_t whose weekday you want.
   */
-const char * watch_utility_get_long_weekday(watch_date_time date_time);
+const char * watch_utility_get_long_weekday(watch_date_time_t date_time);
 
 /** @brief Returns a number between 1-7 representing the weekday according to ISO8601 : week starts on Monday and has index 1, Sunday has index 7
  * @param year The year of the date
@@ -83,7 +83,7 @@ uint16_t watch_utility_days_since_new_year(uint16_t year, uint8_t month, uint8_t
 uint8_t is_leap(uint16_t year);
 
 /** @brief Returns the UNIX time (seconds since 1970) for a given date/time in UTC.
-  * @param date_time The watch_date_time that you wish to convert.
+  * @param date_time The watch_date_time_t that you wish to convert.
   * @param year The year of the date you wish to convert.
   * @param month The month of the date you wish to convert.
   * @param day The day of the date you wish to convert.
@@ -97,12 +97,12 @@ uint8_t is_leap(uint16_t year);
   */
 uint32_t watch_utility_convert_to_unix_time(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, int32_t utc_offset);
 
-/** @brief Returns the UNIX time (seconds since 1970) for a given watch_date_time struct.
-  * @param date_time The watch_date_time that you wish to convert.
+/** @brief Returns the UNIX time (seconds since 1970) for a given watch_date_time_t struct.
+  * @param date_time The watch_date_time_t that you wish to convert.
   * @param utc_offset The number of seconds that date_time is offset from UTC, or 0 if the time is UTC.
-  * @return A UNIX timestamp for the given watch_date_time and UTC offset.
+  * @return A UNIX timestamp for the given watch_date_time_t and UTC offset.
   */
-uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, int32_t utc_offset);
+uint32_t watch_utility_date_time_to_unix_time(watch_date_time_t date_time, int32_t utc_offset);
 
 /** @brief Converts a duration in seconds to a watch_duration_t struct.
   * @param seconds A positive number of seconds that you wish to convert to a formatted duration.
@@ -110,39 +110,39 @@ uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, int32_t
   */
 watch_duration_t watch_utility_seconds_to_duration(uint32_t seconds);
 
-/** @brief Returns a watch_date_time struct for a given UNIX time and UTC offset.
+/** @brief Returns a watch_date_time_t struct for a given UNIX time and UTC offset.
   * @param timestamp The UNIX timestamp that you wish to convert.
   * @param utc_offset The number of seconds that you wish date_time to be offset from UTC.
-  * @return A watch_date_time for the given UNIX timestamp and UTC offset, or if outside the range that
-  *         watch_date_time can represent, a watch_date_time with all fields set to 0.
+  * @return A watch_date_time_t for the given UNIX timestamp and UTC offset, or if outside the range that
+  *         watch_date_time_t can represent, a watch_date_time_t with all fields set to 0.
   * @note Adapted from MIT-licensed code from musl, Copyright © 2005-2014 Rich Felker, et al.:
   *       https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c
   */
-watch_date_time watch_utility_date_time_from_unix_time(uint32_t timestamp, int32_t utc_offset);
+watch_date_time_t watch_utility_date_time_from_unix_time(uint32_t timestamp, int32_t utc_offset);
 
-/** @brief Converts a watch_date_time for 12-hour display.
-  * @param date_time A pointer to the watch_date_time that you wish to convert for display. Note that this
+/** @brief Converts a watch_date_time_t for 12-hour display.
+  * @param date_time A pointer to the watch_date_time_t that you wish to convert for display. Note that this
   *                  function will OVERWRITE the original date/time, rendering it invalid for date/time
   *                  calculations. Midnight (hour 0) will become 12, and hours in the afternoon will wrap
   *                  back around to values from 1-11.
   * @return True if the value is in the afternoon. You can use this value to determine whether to set the
   *         PM indicator on the LCD.
-  * @note This function sort of abuses the watch_date_time struct; the date/time that results from calling
+  * @note This function sort of abuses the watch_date_time_t struct; the date/time that results from calling
   *       this function is clamped to the hours of 1:00:00 AM through 12:59:59 PM. It no longer reflects a
-  *       valid watch_date_time for writing to an RTC register.
+  *       valid watch_date_time_t for writing to an RTC register.
   */
-bool watch_utility_convert_to_12_hour(watch_date_time *date_time);
+bool watch_utility_convert_to_12_hour(watch_date_time_t *date_time);
 
 /** @brief Converts a time from a given time zone to another time zone.
-  * @param date_time The watch_date_time that you wish to convert
+  * @param date_time The watch_date_time_t that you wish to convert
   * @param origin_utc_offset The number of seconds from UTC in the origin time zone
   * @param destination_utc_offset The number of seconds from UTC in the destination time zone
-  * @return A watch_date_time for the given UNIX timestamp and UTC offset, or if outside the range that
-  *         watch_date_time can represent, a watch_date_time with all fields set to 0.
+  * @return A watch_date_time_t for the given UNIX timestamp and UTC offset, or if outside the range that
+  *         watch_date_time_t can represent, a watch_date_time_t with all fields set to 0.
   * @note Adapted from MIT-licensed code from musl, Copyright © 2005-2014 Rich Felker, et al.:
   *       https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c
   */
-watch_date_time watch_utility_date_time_convert_zone(watch_date_time date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset);
+watch_date_time_t watch_utility_date_time_convert_zone(watch_date_time_t date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset);
 
 /** @brief Returns a temperature in degrees Celsius for a given thermistor voltage divider circuit.
   * @param value The raw analog reading from the thermistor pin (0-65535)
index f809c536767819b47a5bc67c10a01972206a446c..6f97490ba650e16dc69781dff5a9884388effb9b 100644 (file)
@@ -42,7 +42,7 @@ int getentropy(void *buf, size_t buflen) {
 int _gettimeofday(struct timeval *tv, void *tzvp);
 int _gettimeofday(struct timeval *tv, void *tzvp) {
     (void)tzvp;
-    watch_date_time date_time = watch_rtc_get_date_time();
+    watch_date_time_t date_time = watch_rtc_get_date_time();
 
     // FIXME: this assumes the system time is UTC! Will break for any other time zone.
     tv->tv_sec = watch_utility_date_time_to_unix_time(date_time, 0);
index 2bb6074c714ceda61f6c6e94fa01f77cbff6d194..3b244f2418bc89b18bbaf57015040c299bed6928 100644 (file)
@@ -46,7 +46,7 @@ bool _watch_rtc_is_enabled(void) {
 void _watch_rtc_init(void) {
 }
 
-void watch_rtc_set_date_time(watch_date_time date_time) {
+void watch_rtc_set_date_time(watch_date_time_t date_time) {
     time_offset = EM_ASM_DOUBLE({
         const year = 2020 + (($0 >> 26) & 0x3f);
         const month = ($0 >> 22) & 0xf;
@@ -59,8 +59,8 @@ void watch_rtc_set_date_time(watch_date_time date_time) {
     }, date_time.reg);
 }
 
-watch_date_time watch_rtc_get_date_time(void) {
-    watch_date_time retval;
+watch_date_time_t watch_rtc_get_date_time(void) {
+    watch_date_time_t retval;
     retval.reg = EM_ASM_INT({
         const date = new Date(Date.now() + $0);
         return date.getSeconds() |
@@ -134,7 +134,7 @@ static void watch_invoke_alarm_callback(void *userData) {
     alarm_interval_id = emscripten_set_interval(watch_invoke_alarm_interval_callback, alarm_interval, NULL);
 }
 
-void watch_rtc_register_alarm_callback(ext_irq_cb_t callback, watch_date_time alarm_time, watch_rtc_alarm_match mask) {
+void watch_rtc_register_alarm_callback(ext_irq_cb_t callback, watch_date_time_t alarm_time, watch_rtc_alarm_match mask) {
     watch_rtc_disable_alarm_callback();
 
     switch (mask) {