summaryrefslogtreecommitdiffstats
path: root/group__utility.html
blob: 020f8eae2e7036236c8cfb099d1c671be851a13f (plain)
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<!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.3"/>
<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">&#160;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.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;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&amp;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> &#124;
<a href="#func-members">Functions</a> &#124;
<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 &#160;</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">&#160;</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 *&#160;</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">&#160;</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">&#160;</td></tr>
<tr class="memitem:ga94f5cc404949bf4c0ac4bc4770ec8eda"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</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">&#160;</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">&#160;</td></tr>
<tr class="memitem:gaffafef58755ff2704cf93fe1a0849a27"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</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">&#160;</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">&#160;</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>&#160;</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">&#160;</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">&#160;</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>&#160;</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">&#160;</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">&#160;</td></tr>
<tr class="memitem:ga470a4c7199afac6319c259fc459881f4"><td class="memItemLeft" align="right" valign="top">bool&#160;</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">&#160;</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">&#160;</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>&#160;</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">&#160;</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">&#160;</td></tr>
<tr class="memitem:ga2753ff031c28202d23b0f3e80de2c920"><td class="memItemLeft" align="right" valign="top">float&#160;</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">&#160;</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">&#160;</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&#160;</td><td class="memItemRight" valign="bottom"><b>watch_duration_t::seconds</b></td></tr>
<tr class="separator:ga214dcb4a04944fec63818c52e6c4096f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafc7fa57c207237df2190f4979a625053"><td class="memItemLeft" align="right" valign="top"><a id="gafc7fa57c207237df2190f4979a625053" name="gafc7fa57c207237df2190f4979a625053"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><b>watch_duration_t::minutes</b></td></tr>
<tr class="separator:gafc7fa57c207237df2190f4979a625053"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga05216f93223bb35b5166b03ab59098a1"><td class="memItemLeft" align="right" valign="top"><a id="ga05216f93223bb35b5166b03ab59098a1" name="ga05216f93223bb35b5166b03ab59098a1"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><b>watch_duration_t::hours</b></td></tr>
<tr class="separator:ga05216f93223bb35b5166b03ab59098a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga64f074551349a7dd1c922287dc731c15"><td class="memItemLeft" align="right" valign="top"><a id="ga64f074551349a7dd1c922287dc731c15" name="ga64f074551349a7dd1c922287dc731c15"></a>
uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>watch_duration_t::days</b></td></tr>
<tr class="separator:ga64f074551349a7dd1c922287dc731c15"><td class="memSeparator" colspan="2">&#160;</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">&#9670;&nbsp;</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> *&#160;</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">&#9670;&nbsp;</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&#160;</td>
          <td class="paramname"><em>year</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>month</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>day</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>hour</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>minute</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>second</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>utc_offset</em>&#160;</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">&#9670;&nbsp;</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>&#160;</td>
          <td class="paramname"><em>date_time</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>origin_utc_offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>destination_utc_offset</em>&#160;</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">&#9670;&nbsp;</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&#160;</td>
          <td class="paramname"><em>timestamp</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>utc_offset</em>&#160;</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">&#9670;&nbsp;</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>&#160;</td>
          <td class="paramname"><em>date_time</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>utc_offset</em>&#160;</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">&#9670;&nbsp;</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>&#160;</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="ga5d6af930688b240d0f075806b5730d21" name="ga5d6af930688b240d0f075806b5730d21"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5d6af930688b240d0f075806b5730d21">&#9670;&nbsp;</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&#160;</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">&#9670;&nbsp;</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&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>highside</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>b_coefficient</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>nominal_temperature</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>nominal_resistance</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>series_resistance</em>&#160;</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&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3
</small></address>
</body>
</html>