From 46c14a44e8e889bbdd317895492b70b179070441 Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Tue, 14 Dec 2021 17:06:59 +0000 Subject: deploy: e8e9a0e2d86d37fa0354b3475c907eae1bf5a6dd --- group__utility.html | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 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..701bd865 --- /dev/null +++ b/group__utility.html @@ -0,0 +1,347 @@ + + + + + + + +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...
 
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_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