From c0090716995447bd59954c8a7e24cd5c20598f7a Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Thu, 27 Jan 2022 15:47:25 +0000 Subject: deploy: 29fa6052831f8d26815405d4652b5799e3c74147 --- group__utility.html | 396 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 group__utility.html (limited to 'group__utility.html') diff --git a/group__utility.html b/group__utility.html new file mode 100644 index 00000000..4c31d1e0 --- /dev/null +++ b/group__utility.html @@ -0,0 +1,396 @@ + + + + + + + +Sensor Watch: Utility Functions + + + + + + + + + +
+
+ + + + + + +
+
Sensor Watch +  0.0.0 +
+
A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+ +
+
Utility Functions
+
+
+ +

This section covers various useful functions that don't fit anywhere else. +More...

+ + + + + + + + + + + + + + + + + + + + +

+Functions

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...
 
watch_date_time watch_utility_date_time_convert_zone (watch_date_time date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset)
 Converts a time from a given time zone to another time zone. 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...
 
+

Detailed Description

+

This section covers various useful functions that don't fit anywhere else.

+

Function Documentation

+ +

◆ 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_timeThe watch_date_time that you wish to convert.
yearThe year of the date you wish to convert.
monthThe month of the date you wish to convert.
dayThe day of the date you wish to convert.
hourThe hour of the date you wish to convert.
minuteThe minute of the date you wish to convert.
secondThe second of the date you wish to convert.
utc_offsetThe 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_convert_zone()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
watch_date_time watch_utility_date_time_convert_zone (watch_date_time date_time,
uint32_t origin_utc_offset,
uint32_t destination_utc_offset 
)
+
+ +

Converts a time from a given time zone to another time zone.

+
Parameters
+ + + + +
date_timeThe watch_date_time that you wish to convert
origin_utc_offsetThe number of seconds from UTC in the origin time zone
destination_utc_offsetThe number of seconds from UTC in the destination time zone
+
+
+
Returns
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.
+
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_utility_date_time_from_unix_time()

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

+
Parameters
+ + + +
timestampThe UNIX timestamp that you wish to convert.
utc_offsetThe number of seconds that you wish date_time to be offset from UTC.
+
+
+
Returns
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.
+
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_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_timeThe watch_date_time that you wish to convert.
utc_offsetThe 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()

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

+
Parameters
+ + +
date_timeThe watch_date_time whose weekday you want.
+
+
+ +
+
+ +

◆ 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
+ + + + + + + +
valueThe raw analog reading from the thermistor pin (0-65535)
highsideTrue 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_coefficientFrom your thermistor's data sheet, the B25/85 coefficient. A typical value will be between 2000 and 5000.
nominal_temperatureFrom your thermistor's data sheet, the temperature (in Celsius) at which the thermistor's resistance is at its nominal value.
nominal_resistanceThe thermistor's resistance at the nominal temperature.
series_resistanceThe 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
+ +
+
+
+ + + + -- cgit v1.2.3