533 lines
31 KiB
HTML
533 lines
31 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.4"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Sensor Watch: Utility Functions</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">Sensor Watch<span id="projectnumber"> 0.0.1</span>
|
|
</div>
|
|
<div id="projectbrief">A board replacement for the classic Casio F-91W wristwatch, powered by a Microchip SAM L22 microcontroller.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.4 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#nested-classes">Data Structures</a> |
|
|
<a href="#func-members">Functions</a> |
|
|
<a href="#var-members">Variables</a> </div>
|
|
<div class="headertitle"><div class="title">Utility Functions</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>This section covers various useful functions that don't fit anywhere else.
|
|
<a href="#details">More...</a></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
|
|
Data Structures</h2></td></tr>
|
|
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structwatch__duration__t.html">watch_duration_t</a></td></tr>
|
|
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:gaad14860c068aeed7a60e57874cad92b4"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#gaad14860c068aeed7a60e57874cad92b4">watch_utility_get_weekday</a> (<a class="el" href="unionwatch__date__time.html">watch_date_time</a> date_time)</td></tr>
|
|
<tr class="memdesc:gaad14860c068aeed7a60e57874cad92b4"><td class="mdescLeft"> </td><td class="mdescRight">Returns a two-letter weekday for the given timestamp, suitable for display in positions 0-1 of the watch face. <a href="group__utility.html#gaad14860c068aeed7a60e57874cad92b4">More...</a><br /></td></tr>
|
|
<tr class="separator:gaad14860c068aeed7a60e57874cad92b4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga94f5cc404949bf4c0ac4bc4770ec8eda"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga94f5cc404949bf4c0ac4bc4770ec8eda">watch_utility_convert_to_unix_time</a> (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t utc_offset)</td></tr>
|
|
<tr class="memdesc:ga94f5cc404949bf4c0ac4bc4770ec8eda"><td class="mdescLeft"> </td><td class="mdescRight">Returns the UNIX time (seconds since 1970) for a given date/time in UTC. <a href="group__utility.html#ga94f5cc404949bf4c0ac4bc4770ec8eda">More...</a><br /></td></tr>
|
|
<tr class="separator:ga94f5cc404949bf4c0ac4bc4770ec8eda"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gaffafef58755ff2704cf93fe1a0849a27"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#gaffafef58755ff2704cf93fe1a0849a27">watch_utility_date_time_to_unix_time</a> (<a class="el" href="unionwatch__date__time.html">watch_date_time</a> date_time, uint32_t utc_offset)</td></tr>
|
|
<tr class="memdesc:gaffafef58755ff2704cf93fe1a0849a27"><td class="mdescLeft"> </td><td class="mdescRight">Returns the UNIX time (seconds since 1970) for a given <a class="el" href="unionwatch__date__time.html">watch_date_time</a> struct. <a href="group__utility.html#gaffafef58755ff2704cf93fe1a0849a27">More...</a><br /></td></tr>
|
|
<tr class="separator:gaffafef58755ff2704cf93fe1a0849a27"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga5d6af930688b240d0f075806b5730d21"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structwatch__duration__t.html">watch_duration_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga5d6af930688b240d0f075806b5730d21">watch_utility_seconds_to_duration</a> (uint32_t seconds)</td></tr>
|
|
<tr class="memdesc:ga5d6af930688b240d0f075806b5730d21"><td class="mdescLeft"> </td><td class="mdescRight">Converts a duration in seconds to a <a class="el" href="structwatch__duration__t.html">watch_duration_t</a> struct. <a href="group__utility.html#ga5d6af930688b240d0f075806b5730d21">More...</a><br /></td></tr>
|
|
<tr class="separator:ga5d6af930688b240d0f075806b5730d21"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga396e56109234aaa00993c3dd84f3f43c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga396e56109234aaa00993c3dd84f3f43c">watch_utility_date_time_from_unix_time</a> (uint32_t timestamp, uint32_t utc_offset)</td></tr>
|
|
<tr class="memdesc:ga396e56109234aaa00993c3dd84f3f43c"><td class="mdescLeft"> </td><td class="mdescRight">Returns a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> struct for a given UNIX time and UTC offset. <a href="group__utility.html#ga396e56109234aaa00993c3dd84f3f43c">More...</a><br /></td></tr>
|
|
<tr class="separator:ga396e56109234aaa00993c3dd84f3f43c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga470a4c7199afac6319c259fc459881f4"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga470a4c7199afac6319c259fc459881f4">watch_utility_convert_to_12_hour</a> (<a class="el" href="unionwatch__date__time.html">watch_date_time</a> *date_time)</td></tr>
|
|
<tr class="memdesc:ga470a4c7199afac6319c259fc459881f4"><td class="mdescLeft"> </td><td class="mdescRight">Converts a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> for 12-hour display. <a href="group__utility.html#ga470a4c7199afac6319c259fc459881f4">More...</a><br /></td></tr>
|
|
<tr class="separator:ga470a4c7199afac6319c259fc459881f4"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga94f038ec0e1b8f3c48c4364b56566327"><td class="memItemLeft" align="right" valign="top"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga94f038ec0e1b8f3c48c4364b56566327">watch_utility_date_time_convert_zone</a> (<a class="el" href="unionwatch__date__time.html">watch_date_time</a> date_time, uint32_t origin_utc_offset, uint32_t destination_utc_offset)</td></tr>
|
|
<tr class="memdesc:ga94f038ec0e1b8f3c48c4364b56566327"><td class="mdescLeft"> </td><td class="mdescRight">Converts a time from a given time zone to another time zone. <a href="group__utility.html#ga94f038ec0e1b8f3c48c4364b56566327">More...</a><br /></td></tr>
|
|
<tr class="separator:ga94f038ec0e1b8f3c48c4364b56566327"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga2753ff031c28202d23b0f3e80de2c920"><td class="memItemLeft" align="right" valign="top">float </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga2753ff031c28202d23b0f3e80de2c920">watch_utility_thermistor_temperature</a> (uint16_t value, bool highside, float b_coefficient, float nominal_temperature, float nominal_resistance, float series_resistance)</td></tr>
|
|
<tr class="memdesc:ga2753ff031c28202d23b0f3e80de2c920"><td class="mdescLeft"> </td><td class="mdescRight">Returns a temperature in degrees Celsius for a given thermistor voltage divider circuit. <a href="group__utility.html#ga2753ff031c28202d23b0f3e80de2c920">More...</a><br /></td></tr>
|
|
<tr class="separator:ga2753ff031c28202d23b0f3e80de2c920"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga176fd2c04778c2049f6ae8b9d374725c"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga176fd2c04778c2049f6ae8b9d374725c">watch_utility_offset_timestamp</a> (uint32_t now, int8_t hours, int8_t minutes, int8_t seconds)</td></tr>
|
|
<tr class="memdesc:ga176fd2c04778c2049f6ae8b9d374725c"><td class="mdescLeft"> </td><td class="mdescRight">Offset a timestamp by a given amount. <a href="group__utility.html#ga176fd2c04778c2049f6ae8b9d374725c">More...</a><br /></td></tr>
|
|
<tr class="separator:ga176fd2c04778c2049f6ae8b9d374725c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
|
|
Variables</h2></td></tr>
|
|
<tr class="memitem:ga214dcb4a04944fec63818c52e6c4096f"><td class="memItemLeft" align="right" valign="top"><a id="ga214dcb4a04944fec63818c52e6c4096f" name="ga214dcb4a04944fec63818c52e6c4096f"></a>
|
|
uint8_t </td><td class="memItemRight" valign="bottom"><b>watch_duration_t::seconds</b></td></tr>
|
|
<tr class="separator:ga214dcb4a04944fec63818c52e6c4096f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gafc7fa57c207237df2190f4979a625053"><td class="memItemLeft" align="right" valign="top"><a id="gafc7fa57c207237df2190f4979a625053" name="gafc7fa57c207237df2190f4979a625053"></a>
|
|
uint8_t </td><td class="memItemRight" valign="bottom"><b>watch_duration_t::minutes</b></td></tr>
|
|
<tr class="separator:gafc7fa57c207237df2190f4979a625053"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga05216f93223bb35b5166b03ab59098a1"><td class="memItemLeft" align="right" valign="top"><a id="ga05216f93223bb35b5166b03ab59098a1" name="ga05216f93223bb35b5166b03ab59098a1"></a>
|
|
uint8_t </td><td class="memItemRight" valign="bottom"><b>watch_duration_t::hours</b></td></tr>
|
|
<tr class="separator:ga05216f93223bb35b5166b03ab59098a1"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga64f074551349a7dd1c922287dc731c15"><td class="memItemLeft" align="right" valign="top"><a id="ga64f074551349a7dd1c922287dc731c15" name="ga64f074551349a7dd1c922287dc731c15"></a>
|
|
uint32_t </td><td class="memItemRight" valign="bottom"><b>watch_duration_t::days</b></td></tr>
|
|
<tr class="separator:ga64f074551349a7dd1c922287dc731c15"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<p >This section covers various useful functions that don't fit anywhere else. </p>
|
|
<h2 class="groupheader">Function Documentation</h2>
|
|
<a id="ga470a4c7199afac6319c259fc459881f4" name="ga470a4c7199afac6319c259fc459881f4"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga470a4c7199afac6319c259fc459881f4">◆ </a></span>watch_utility_convert_to_12_hour()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool watch_utility_convert_to_12_hour </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> * </td>
|
|
<td class="paramname"><em>date_time</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Converts a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> for 12-hour display. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">date_time</td><td>A pointer to the <a class="el" href="unionwatch__date__time.html">watch_date_time</a> 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. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>True if the value is in the afternoon. You can use this value to determine whether to set the PM indicator on the LCD. </dd></dl>
|
|
<dl class="section note"><dt>Note</dt><dd>This function sort of abuses the <a class="el" href="unionwatch__date__time.html">watch_date_time</a> 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 <a class="el" href="unionwatch__date__time.html">watch_date_time</a> for writing to an RTC register. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga94f5cc404949bf4c0ac4bc4770ec8eda" name="ga94f5cc404949bf4c0ac4bc4770ec8eda"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga94f5cc404949bf4c0ac4bc4770ec8eda">◆ </a></span>watch_utility_convert_to_unix_time()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">uint32_t watch_utility_convert_to_unix_time </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint16_t </td>
|
|
<td class="paramname"><em>year</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>month</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>day</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>hour</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>minute</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>second</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>utc_offset</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the UNIX time (seconds since 1970) for a given date/time in UTC. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">date_time</td><td>The <a class="el" href="unionwatch__date__time.html">watch_date_time</a> that you wish to convert. </td></tr>
|
|
<tr><td class="paramname">year</td><td>The year of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">month</td><td>The month of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">day</td><td>The day of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">hour</td><td>The hour of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">minute</td><td>The minute of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">second</td><td>The second of the date you wish to convert. </td></tr>
|
|
<tr><td class="paramname">utc_offset</td><td>The number of seconds that date_time is offset from UTC, or 0 if the time is UTC. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A UNIX timestamp for the given date/time and UTC offset. </dd></dl>
|
|
<dl class="section note"><dt>Note</dt><dd>Implemented by Wesley Ellis (tahnok) and based on BSD-licensed code by Josh Haberman: <a href="https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html">https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga94f038ec0e1b8f3c48c4364b56566327" name="ga94f038ec0e1b8f3c48c4364b56566327"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga94f038ec0e1b8f3c48c4364b56566327">◆ </a></span>watch_utility_date_time_convert_zone()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> watch_utility_date_time_convert_zone </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> </td>
|
|
<td class="paramname"><em>date_time</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>origin_utc_offset</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>destination_utc_offset</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Converts a time from a given time zone to another time zone. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">date_time</td><td>The <a class="el" href="unionwatch__date__time.html">watch_date_time</a> that you wish to convert </td></tr>
|
|
<tr><td class="paramname">origin_utc_offset</td><td>The number of seconds from UTC in the origin time zone </td></tr>
|
|
<tr><td class="paramname">destination_utc_offset</td><td>The number of seconds from UTC in the destination time zone </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A <a class="el" href="unionwatch__date__time.html">watch_date_time</a> for the given UNIX timestamp and UTC offset, or if outside the range that <a class="el" href="unionwatch__date__time.html">watch_date_time</a> can represent, a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> with all fields set to 0. </dd></dl>
|
|
<dl class="section note"><dt>Note</dt><dd>Adapted from MIT-licensed code from musl, Copyright © 2005-2014 Rich Felker, et al.: <a href="https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c">https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga396e56109234aaa00993c3dd84f3f43c" name="ga396e56109234aaa00993c3dd84f3f43c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga396e56109234aaa00993c3dd84f3f43c">◆ </a></span>watch_utility_date_time_from_unix_time()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> watch_utility_date_time_from_unix_time </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>timestamp</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>utc_offset</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> struct for a given UNIX time and UTC offset. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">timestamp</td><td>The UNIX timestamp that you wish to convert. </td></tr>
|
|
<tr><td class="paramname">utc_offset</td><td>The number of seconds that you wish date_time to be offset from UTC. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A <a class="el" href="unionwatch__date__time.html">watch_date_time</a> for the given UNIX timestamp and UTC offset, or if outside the range that <a class="el" href="unionwatch__date__time.html">watch_date_time</a> can represent, a <a class="el" href="unionwatch__date__time.html">watch_date_time</a> with all fields set to 0. </dd></dl>
|
|
<dl class="section note"><dt>Note</dt><dd>Adapted from MIT-licensed code from musl, Copyright © 2005-2014 Rich Felker, et al.: <a href="https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c">https://github.com/esmil/musl/blob/1cc81f5cb0df2b66a795ff0c26d7bbc4d16e13c6/src/time/__secs_to_tm.c</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="gaffafef58755ff2704cf93fe1a0849a27" name="gaffafef58755ff2704cf93fe1a0849a27"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaffafef58755ff2704cf93fe1a0849a27">◆ </a></span>watch_utility_date_time_to_unix_time()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">uint32_t watch_utility_date_time_to_unix_time </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> </td>
|
|
<td class="paramname"><em>date_time</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>utc_offset</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the UNIX time (seconds since 1970) for a given <a class="el" href="unionwatch__date__time.html">watch_date_time</a> struct. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">date_time</td><td>The <a class="el" href="unionwatch__date__time.html">watch_date_time</a> that you wish to convert. </td></tr>
|
|
<tr><td class="paramname">utc_offset</td><td>The number of seconds that date_time is offset from UTC, or 0 if the time is UTC. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A UNIX timestamp for the given <a class="el" href="unionwatch__date__time.html">watch_date_time</a> and UTC offset. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="gaad14860c068aeed7a60e57874cad92b4" name="gaad14860c068aeed7a60e57874cad92b4"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#gaad14860c068aeed7a60e57874cad92b4">◆ </a></span>watch_utility_get_weekday()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">const char * watch_utility_get_weekday </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="unionwatch__date__time.html">watch_date_time</a> </td>
|
|
<td class="paramname"><em>date_time</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns a two-letter weekday for the given timestamp, suitable for display in positions 0-1 of the watch face. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">date_time</td><td>The <a class="el" href="unionwatch__date__time.html">watch_date_time</a> whose weekday you want. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga176fd2c04778c2049f6ae8b9d374725c" name="ga176fd2c04778c2049f6ae8b9d374725c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga176fd2c04778c2049f6ae8b9d374725c">◆ </a></span>watch_utility_offset_timestamp()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">uint32_t watch_utility_offset_timestamp </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>now</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int8_t </td>
|
|
<td class="paramname"><em>hours</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int8_t </td>
|
|
<td class="paramname"><em>minutes</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int8_t </td>
|
|
<td class="paramname"><em>seconds</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Offset a timestamp by a given amount. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">now</td><td>Timestamp to offset from </td></tr>
|
|
<tr><td class="paramname">hours</td><td>Number of hours to offset </td></tr>
|
|
<tr><td class="paramname">minutes</td><td>Nmber of minutes to offset </td></tr>
|
|
<tr><td class="paramname">seconds</td><td>Number of secodns to offset </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga5d6af930688b240d0f075806b5730d21" name="ga5d6af930688b240d0f075806b5730d21"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga5d6af930688b240d0f075806b5730d21">◆ </a></span>watch_utility_seconds_to_duration()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="structwatch__duration__t.html">watch_duration_t</a> watch_utility_seconds_to_duration </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint32_t </td>
|
|
<td class="paramname"><em>seconds</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Converts a duration in seconds to a <a class="el" href="structwatch__duration__t.html">watch_duration_t</a> struct. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">seconds</td><td>A positive number of seconds that you wish to convert to a formatted duration. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>A populated struct with the number of days, hours, minutes and seconds elapsed. </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="ga2753ff031c28202d23b0f3e80de2c920" name="ga2753ff031c28202d23b0f3e80de2c920"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#ga2753ff031c28202d23b0f3e80de2c920">◆ </a></span>watch_utility_thermistor_temperature()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">float watch_utility_thermistor_temperature </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint16_t </td>
|
|
<td class="paramname"><em>value</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>highside</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">float </td>
|
|
<td class="paramname"><em>b_coefficient</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">float </td>
|
|
<td class="paramname"><em>nominal_temperature</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">float </td>
|
|
<td class="paramname"><em>nominal_resistance</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">float </td>
|
|
<td class="paramname"><em>series_resistance</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns a temperature in degrees Celsius for a given thermistor voltage divider circuit. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">value</td><td>The raw analog reading from the thermistor pin (0-65535) </td></tr>
|
|
<tr><td class="paramname">highside</td><td>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. </td></tr>
|
|
<tr><td class="paramname">b_coefficient</td><td>From your thermistor's data sheet, the B25/85 coefficient. A typical value will be between 2000 and 5000. </td></tr>
|
|
<tr><td class="paramname">nominal_temperature</td><td>From your thermistor's data sheet, the temperature (in Celsius) at which the thermistor's resistance is at its nominal value. </td></tr>
|
|
<tr><td class="paramname">nominal_resistance</td><td>The thermistor's resistance at the nominal temperature. </td></tr>
|
|
<tr><td class="paramname">series_resistance</td><td>The value of the other resistor in the voltage divider. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section note"><dt>Note</dt><dd>Ported from Adafruit's MIT-licensed CircuitPython thermistor code, (c) 2017 Scott Shawcroft: <a href="https://github.com/adafruit/Adafruit_CircuitPython_Thermistor/blob/main/adafruit_thermistor.py">https://github.com/adafruit/Adafruit_CircuitPython_Thermistor/blob/main/adafruit_thermistor.py</a> </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
|
|
</small></address>
|
|
</body>
|
|
</html>
|