This section covers various useful functions that don't fit anywhere else.
More...
|
const char * | watch_utility_get_weekday (watch_date_time date_time) |
| Returns a two-letter weekday for the given timestamp, suitable for display in positions 0-1 of the watch face. More...
|
|
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, uint32_t utc_offset) |
| Returns the UNIX time (seconds since 1970) for a given date/time in UTC. More...
|
|
uint32_t | watch_utility_date_time_to_unix_time (watch_date_time date_time, uint32_t utc_offset) |
| Returns the UNIX time (seconds since 1970) for a given watch_date_time struct. More...
|
|
watch_date_time | watch_utility_date_time_from_unix_time (uint32_t timestamp, uint32_t utc_offset) |
| Returns the UNIX time (seconds since 1970) for a given watch_date_time struct. More...
|
|
float | watch_utility_thermistor_temperature (uint16_t value, bool highside, float b_coefficient, float nominal_temperature, float nominal_resistance, float series_resistance) |
| Returns a temperature in degrees Celsius for a given thermistor voltage divider circuit. More...
|
|
This section covers various useful functions that don't fit anywhere else.
◆ watch_utility_convert_to_unix_time()
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, |
|
|
uint32_t |
utc_offset |
|
) |
| |
Returns the UNIX time (seconds since 1970) for a given date/time in UTC.
- Parameters
-
date_time | The watch_date_time that you wish to convert. |
year | The year of the date you wish to convert. |
month | The month of the date you wish to convert. |
day | The day of the date you wish to convert. |
hour | The hour of the date you wish to convert. |
minute | The minute of the date you wish to convert. |
second | The second of the date you wish to convert. |
utc_offset | The number of seconds that date_time is offset from UTC, or 0 if the time is UTC. |
- Returns
- A UNIX timestamp for the given date/time and UTC offset.
- Note
- Implemented by Wesley Ellis (tahnok) and based on BSD-licensed code by Josh Haberman: https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html
◆ watch_utility_date_time_from_unix_time()
watch_date_time watch_utility_date_time_from_unix_time |
( |
uint32_t |
timestamp, |
|
|
uint32_t |
utc_offset |
|
) |
| |
◆ watch_utility_date_time_to_unix_time()
uint32_t watch_utility_date_time_to_unix_time |
( |
watch_date_time |
date_time, |
|
|
uint32_t |
utc_offset |
|
) |
| |
Returns the UNIX time (seconds since 1970) for a given watch_date_time struct.
- Parameters
-
date_time | The watch_date_time that you wish to convert. |
utc_offset | The number of seconds that date_time is offset from UTC, or 0 if the time is UTC. |
- Returns
- A UNIX timestamp for the given watch_date_time and UTC offset.
◆ watch_utility_get_weekday()
Returns a two-letter weekday for the given timestamp, suitable for display in positions 0-1 of the watch face.
- Parameters
-
◆ watch_utility_thermistor_temperature()
float watch_utility_thermistor_temperature |
( |
uint16_t |
value, |
|
|
bool |
highside, |
|
|
float |
b_coefficient, |
|
|
float |
nominal_temperature, |
|
|
float |
nominal_resistance, |
|
|
float |
series_resistance |
|
) |
| |
Returns a temperature in degrees Celsius for a given thermistor voltage divider circuit.
- Parameters
-
value | The raw analog reading from the thermistor pin (0-65535) |
highside | True if the thermistor is connected to VCC and the series resistor is connected to GND; false if the thermistor is connected to GND and the series resistor is connected to VCC. |
b_coefficient | From your thermistor's data sheet, the B25/85 coefficient. A typical value will be between 2000 and 5000. |
nominal_temperature | From your thermistor's data sheet, the temperature (in Celsius) at which the thermistor's resistance is at its nominal value. |
nominal_resistance | The thermistor's resistance at the nominal temperature. |
series_resistance | The value of the other resistor in the voltage divider. |
- Note
- Ported from Adafruit's MIT-licensed CircuitPython thermistor code, (c) 2017 Scott Shawcroft: https://github.com/adafruit/Adafruit_CircuitPython_Thermistor/blob/main/adafruit_thermistor.py