diff options
author | Alexsander Akers <me@a2.io> | 2022-01-25 15:03:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 15:03:22 -0500 |
commit | b8de35658ffd78ad8b22f91ccbbd3d63663afda9 (patch) | |
tree | 1f265ddfcc8e5abf0316b81b15f80bf5c70fa7b7 /watch-library/watch/watch_utility.h | |
parent | 9e24f6c336773c7404139ab4db0eaab2f99504e2 (diff) | |
download | Sensor-Watch-b8de35658ffd78ad8b22f91ccbbd3d63663afda9.tar.gz Sensor-Watch-b8de35658ffd78ad8b22f91ccbbd3d63663afda9.tar.bz2 Sensor-Watch-b8de35658ffd78ad8b22f91ccbbd3d63663afda9.zip |
Sensor Watch Simulator (#35)
* Put something on screen
* Use the 32bit watch_date_time repr to pass from JS
* Implement periodic callbacks
* Clear display on enabling
* Hook up watch_set_led_color() to SVG (green-only)
* Make debug output full-width
* Remove default Emscripten canvas
* Implement sleep and button clicks
* Fix time zone conversion bug in beats-time app
* Clean up warnings
* Fix pin levels
* Set time zone to browser value (if available)
* Add basic backup data saving
* Silence format specifier warnings in both targets
* Remove unnecessary, copied files
* Use RTC pointer to clear callbacks (if available)
* Use preprocessor define to avoid hardcoding MOVEMENT_NUM_FACES
* Change each face to const preprocessor definition
* Remove Intl.DateTimeFormat usage
* Update shell.html title, header
* Add touch start/end event handlers on SVG buttons
* Update shell.html
* Update folder structure (shared, simulator, hardware under watch-library)
* Tease out shared components from watch_slcd
* Clean up simulator watch_slcd.c inline JS calls
* Fix missing newlines at end of file
* Add simulator warnings (except format, unused-paremter)
* Implement remaining watch_rtc functions
* Fix button bug on mouse down then drag out
* Implement remaining watch_slcd functions
* Link keyboard events to buttons (for keys A, L, M)
* Rewrite event handling (mouse, touch, keyboard) in C
* Set explicit text UTF-8 charset in shell.html
* Address PR comments
* Remove unused directories from include paths
Diffstat (limited to 'watch-library/watch/watch_utility.h')
-rw-r--r-- | watch-library/watch/watch_utility.h | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/watch-library/watch/watch_utility.h b/watch-library/watch/watch_utility.h deleted file mode 100644 index 66af6ed5..00000000 --- a/watch-library/watch/watch_utility.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 Joey Castillo - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _WATCH_UTILITY_H_INCLUDED -#define _WATCH_UTILITY_H_INCLUDED -////< @file watch_utility.h - -#include "watch.h" - -/** @addtogroup utility Utility Functions - * @brief This section covers various useful functions that don't fit anywhere else. - **/ -/// @{ -/** @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. - */ -const char * watch_utility_get_weekday(watch_date_time date_time); - -/** @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 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. - * @param hour The hour of the date you wish to convert. - * @param minute The minute of the date you wish to convert. - * @param second The second of the date 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 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 - */ -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); - -/** @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. - * @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. - */ -uint32_t watch_utility_date_time_to_unix_time(watch_date_time date_time, uint32_t utc_offset); - -/** @brief Returns the UNIX time (seconds since 1970) for a given watch_date_time struct. - * @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. - * @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, uint32_t utc_offset); - -/** @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 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. - * @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); - -/** @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) - * @param 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. - * @param b_coefficient From your thermistor's data sheet, the B25/85 coefficient. A typical value - * will be between 2000 and 5000. - * @param nominal_temperature From your thermistor's data sheet, the temperature (in Celsius) at - * which the thermistor's resistance is at its nominal value. - * @param nominal_resistance The thermistor's resistance at the nominal temperature. - * @param 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 - */ -float watch_utility_thermistor_temperature(uint16_t value, bool highside, float b_coefficient, float nominal_temperature, float nominal_resistance, float series_resistance); - -#endif |