Skip to content

Commit

Permalink
use consistent naming style for typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Oct 5, 2024
1 parent 997f091 commit 0a9d71e
Show file tree
Hide file tree
Showing 70 changed files with 222 additions and 222 deletions.
36 changes: 18 additions & 18 deletions movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand All @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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++) {
Expand Down Expand Up @@ -281,16 +281,16 @@ 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);
}

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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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--;
Expand Down
12 changes: 6 additions & 6 deletions movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/close_enough_clock_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions movement/watch_faces/clock/day_night_percentage_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/decimal_time_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions movement/watch_faces/clock/french_revolutionary_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.)
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions movement/watch_faces/clock/french_revolutionary_face.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){ \
Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/mars_time_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/minimal_clock_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions movement/watch_faces/clock/minute_repeater_decimal_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions movement/watch_faces/clock/repetition_minute_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions movement/watch_faces/clock/simple_clock_bin_led_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions movement/watch_faces/clock/weeknumber_clock_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/world_clock2_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion movement/watch_faces/clock/wyoscan_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 0a9d71e

Please sign in to comment.