use consistent naming style for typedefs

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

View File

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

View 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

View 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.

View File

@@ -25,12 +25,12 @@
#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;

View 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)

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

View 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) {