1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
<!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=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<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 style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Sensor Watch
 <span id="projectnumber">0.0.0</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.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'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:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(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="#func-members">Functions</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 name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga8f3d6ddf5f22bc61e1dc4b569009b127"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__utility.html#ga8f3d6ddf5f22bc61e1dc4b569009b127">watch_utility_get_weekday</a> (<a class="el" href="unionwatch__date__time.html">watch_date_time</a> date_time)</td></tr>
<tr class="memdesc:ga8f3d6ddf5f22bc61e1dc4b569009b127"><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#ga8f3d6ddf5f22bc61e1dc4b569009b127">More...</a><br /></td></tr>
<tr class="separator:ga8f3d6ddf5f22bc61e1dc4b569009b127"><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: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 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#ga396e56109234aaa00993c3dd84f3f43c">More...</a><br /></td></tr>
<tr class="separator:ga396e56109234aaa00993c3dd84f3f43c"><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>
</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="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="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 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">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"></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="ga8f3d6ddf5f22bc61e1dc4b569009b127"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8f3d6ddf5f22bc61e1dc4b569009b127">◆ </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="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.1
</small></address>
</body>
</html>
|