mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
189 lines
20 KiB
HTML
189 lines
20 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
|
|
<title>ArduinoLibs: RTC.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body onload='searchBox.OnSelectItem(0);'>
|
|
<!-- Generated by Doxygen 1.7.4 -->
|
|
<script type="text/javascript"><!--
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
--></script>
|
|
<div id="top">
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
<li id="searchli">
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">RTC.h</div> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
|
|
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2012 Southern Storm Software, Pty Ltd.</span>
|
|
<a name="l00003"></a>00003 <span class="comment"> *</span>
|
|
<a name="l00004"></a>00004 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span>
|
|
<a name="l00005"></a>00005 <span class="comment"> * copy of this software and associated documentation files (the "Software"),</span>
|
|
<a name="l00006"></a>00006 <span class="comment"> * to deal in the Software without restriction, including without limitation</span>
|
|
<a name="l00007"></a>00007 <span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span>
|
|
<a name="l00008"></a>00008 <span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span>
|
|
<a name="l00009"></a>00009 <span class="comment"> * Software is furnished to do so, subject to the following conditions:</span>
|
|
<a name="l00010"></a>00010 <span class="comment"> *</span>
|
|
<a name="l00011"></a>00011 <span class="comment"> * The above copyright notice and this permission notice shall be included</span>
|
|
<a name="l00012"></a>00012 <span class="comment"> * in all copies or substantial portions of the Software.</span>
|
|
<a name="l00013"></a>00013 <span class="comment"> *</span>
|
|
<a name="l00014"></a>00014 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</span>
|
|
<a name="l00015"></a>00015 <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
|
|
<a name="l00016"></a>00016 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
|
|
<a name="l00017"></a>00017 <span class="comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
|
|
<a name="l00018"></a>00018 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span>
|
|
<a name="l00019"></a>00019 <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span>
|
|
<a name="l00020"></a>00020 <span class="comment"> * DEALINGS IN THE SOFTWARE.</span>
|
|
<a name="l00021"></a>00021 <span class="comment"> */</span>
|
|
<a name="l00022"></a>00022
|
|
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef RTC_h</span>
|
|
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define RTC_h</span>
|
|
<a name="l00025"></a>00025 <span class="preprocessor"></span>
|
|
<a name="l00026"></a>00026 <span class="preprocessor">#include <inttypes.h></span>
|
|
<a name="l00027"></a>00027
|
|
<a name="l00028"></a><a class="code" href="structRTCTime.html">00028</a> <span class="keyword">struct </span><a class="code" href="structRTCTime.html" title="Stores time information from a realtime clock chip.">RTCTime</a>
|
|
<a name="l00029"></a>00029 {
|
|
<a name="l00030"></a><a class="code" href="structRTCTime.html#a98ba717092ef856dd2b773ba02fcb1a4">00030</a> uint8_t <a class="code" href="structRTCTime.html#a98ba717092ef856dd2b773ba02fcb1a4" title="Hour of the day (0-23)">hour</a>;
|
|
<a name="l00031"></a><a class="code" href="structRTCTime.html#acf2161ca037080dc4b767e636ad8db84">00031</a> uint8_t <a class="code" href="structRTCTime.html#acf2161ca037080dc4b767e636ad8db84" title="Minute within the hour (0-59)">minute</a>;
|
|
<a name="l00032"></a><a class="code" href="structRTCTime.html#a87b7c02e535d808dcba04c77e34abb91">00032</a> uint8_t <a class="code" href="structRTCTime.html#a87b7c02e535d808dcba04c77e34abb91" title="Second within the minute (0-59)">second</a>;
|
|
<a name="l00033"></a>00033 };
|
|
<a name="l00034"></a>00034
|
|
<a name="l00035"></a><a class="code" href="structRTCDate.html">00035</a> <span class="keyword">struct </span><a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a>
|
|
<a name="l00036"></a>00036 {
|
|
<a name="l00037"></a><a class="code" href="structRTCDate.html#a7d31822daff3c3fc947386abd897732f">00037</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRTCDate.html#a7d31822daff3c3fc947386abd897732f" title="Year (4-digit)">year</a>;
|
|
<a name="l00038"></a><a class="code" href="structRTCDate.html#a6e6196059b36186041a5312400ea9202">00038</a> uint8_t <a class="code" href="structRTCDate.html#a6e6196059b36186041a5312400ea9202" title="Month of the year (1-12)">month</a>;
|
|
<a name="l00039"></a><a class="code" href="structRTCDate.html#a2d68ff3fb90240df522b41222362704c">00039</a> uint8_t <a class="code" href="structRTCDate.html#a2d68ff3fb90240df522b41222362704c" title="Day of the month (1-31)">day</a>;
|
|
<a name="l00040"></a>00040 };
|
|
<a name="l00041"></a>00041
|
|
<a name="l00042"></a><a class="code" href="structRTCAlarm.html">00042</a> <span class="keyword">struct </span><a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a>
|
|
<a name="l00043"></a>00043 {
|
|
<a name="l00044"></a><a class="code" href="structRTCAlarm.html#a75bdc42acd3ab3ad495680c6b6a34692">00044</a> uint8_t <a class="code" href="structRTCAlarm.html#a75bdc42acd3ab3ad495680c6b6a34692" title="Hour of the day for the alarm (0-23).">hour</a>;
|
|
<a name="l00045"></a><a class="code" href="structRTCAlarm.html#ad9a75ceb4b4b3474baa66dd5466e62fe">00045</a> uint8_t <a class="code" href="structRTCAlarm.html#ad9a75ceb4b4b3474baa66dd5466e62fe" title="Minute of the hour for the alarm (0-59).">minute</a>;
|
|
<a name="l00046"></a><a class="code" href="structRTCAlarm.html#a0f2ef7363cb60a26642d5295b77ca19e">00046</a> uint8_t <a class="code" href="structRTCAlarm.html#a0f2ef7363cb60a26642d5295b77ca19e" title="Additional flags for the alarm.">flags</a>;
|
|
<a name="l00047"></a>00047 };
|
|
<a name="l00048"></a>00048
|
|
<a name="l00049"></a><a class="code" href="classRTC.html">00049</a> <span class="keyword">class </span><a class="code" href="classRTC.html" title="Base class for realtime clock handlers.">RTC</a>
|
|
<a name="l00050"></a>00050 {
|
|
<a name="l00051"></a>00051 <span class="keyword">public</span>:
|
|
<a name="l00052"></a>00052 <a class="code" href="classRTC.html#ada31c5120d18d2dd2863b3d440308da2" title="Constructs a new realtime clock handler.">RTC</a>();
|
|
<a name="l00053"></a>00053 ~<a class="code" href="classRTC.html" title="Base class for realtime clock handlers.">RTC</a>();
|
|
<a name="l00054"></a>00054
|
|
<a name="l00055"></a><a class="code" href="classRTC.html#ab2ca0cbee608ec32d3d6e04d40298f11">00055</a> <span class="keyword">enum</span> <a class="code" href="classRTC.html#ab2ca0cbee608ec32d3d6e04d40298f11" title="Day of the week corresponding to a date.">DayOfWeek</a>
|
|
<a name="l00056"></a>00056 {
|
|
<a name="l00057"></a>00057 Monday = 1,
|
|
<a name="l00058"></a>00058 Tuesday,
|
|
<a name="l00059"></a>00059 Wednesday,
|
|
<a name="l00060"></a>00060 Thursday,
|
|
<a name="l00061"></a>00061 Friday,
|
|
<a name="l00062"></a>00062 Saturday,
|
|
<a name="l00063"></a>00063 Sunday,
|
|
<a name="l00064"></a>00064 };
|
|
<a name="l00065"></a>00065
|
|
<a name="l00066"></a>00066 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classRTC.html#a3690761f29654a2c9e676fcbfa32dd30" title="Returns true if the realtime clock has updated since the last call to this function.">hasUpdates</a>();
|
|
<a name="l00067"></a>00067
|
|
<a name="l00068"></a>00068 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#aaf0a5c1f32f210a49718d148620b5bec" title="Reads the current time from the realtime clock into value.">readTime</a>(<a class="code" href="structRTCTime.html" title="Stores time information from a realtime clock chip.">RTCTime</a> *value);
|
|
<a name="l00069"></a>00069 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#aa1e21bf42ebd4456919744ae0f4f631e" title="Reads the current date from the realtime clock into value.">readDate</a>(<a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *value);
|
|
<a name="l00070"></a>00070
|
|
<a name="l00071"></a>00071 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#a102e2ec15bf0273d8f7e9ce4b6dcc96e" title="Updates the time in the realtime clock to match value.">writeTime</a>(<span class="keyword">const</span> <a class="code" href="structRTCTime.html" title="Stores time information from a realtime clock chip.">RTCTime</a> *value);
|
|
<a name="l00072"></a>00072 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#ae667600d05c8e7b06a93574dd068a4d7" title="Updates the date in the realtime clock to match value.">writeDate</a>(<span class="keyword">const</span> <a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *value);
|
|
<a name="l00073"></a>00073
|
|
<a name="l00074"></a><a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3">00074</a> <span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a> = 4;
|
|
<a name="l00075"></a>00075
|
|
<a name="l00076"></a>00076 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#ade282d7a60147c3f0269f1fcd59c8d66" title="Reads the details of the alarm with index alarmNum into value.">readAlarm</a>(uint8_t alarmNum, <a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a> *value);
|
|
<a name="l00077"></a>00077 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#a0e96c91efd9e7a6340effdae3eadf17e" title="Updates the details of the alarm with index alarmNum from value.">writeAlarm</a>(uint8_t alarmNum, <span class="keyword">const</span> <a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a> *value);
|
|
<a name="l00078"></a>00078
|
|
<a name="l00079"></a>00079 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classRTC.html#acfdebfb449710e44e11f9a3675e14fd8" title="Returns the number of bytes of non-volatile memory that can be used for storage of arbitrary settings...">byteCount</a>() <span class="keyword">const</span>;
|
|
<a name="l00080"></a>00080 <span class="keyword">virtual</span> uint8_t <a class="code" href="classRTC.html#a0f47b10b436e3f9d36e04ec907579431" title="Reads the byte at offset within the realtime clock's non-volatile memory.">readByte</a>(uint8_t offset);
|
|
<a name="l00081"></a>00081 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#a1cab6397ec04b1e2b3feea5b3cd1f749" title="Writes value to offset within the realtime clock's non-volatile memory.">writeByte</a>(uint8_t offset, uint8_t value);
|
|
<a name="l00082"></a>00082
|
|
<a name="l00083"></a><a class="code" href="classRTC.html#a9ed5480b362a83f1f45c4d3bcf7c3bf8">00083</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classRTC.html#a9ed5480b362a83f1f45c4d3bcf7c3bf8" title="Value that is returned from readTemperature() if the realtime clock chip cannot determine the tempera...">NO_TEMPERATURE</a> = 32767;
|
|
<a name="l00084"></a>00084
|
|
<a name="l00085"></a>00085 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classRTC.html#aeca3c8387332e8cabfd09c1806276e5a" title="Reads the value of the temperature sensor and returns the temperature in quarters of a degree celcius...">readTemperature</a>();
|
|
<a name="l00086"></a>00086
|
|
<a name="l00087"></a>00087 <span class="comment">// Flags for adjustDays(), adjustMonths(), and adjustYears().</span>
|
|
<a name="l00088"></a><a class="code" href="classRTC.html#aacbe3ebbf893685950b05327c11d5c37">00088</a> <span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="classRTC.html#aacbe3ebbf893685950b05327c11d5c37" title="Increment the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears().">INCREMENT</a> = 0x0000;
|
|
<a name="l00089"></a><a class="code" href="classRTC.html#a05b1bd1479afc80682abdd4f3e58dc6f">00089</a> <span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="classRTC.html#a05b1bd1479afc80682abdd4f3e58dc6f" title="Decrement the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears().">DECREMENT</a> = 0x0001;
|
|
<a name="l00090"></a><a class="code" href="classRTC.html#a02ace2d775063be9a99035851c9274eb">00090</a> <span class="keyword">static</span> <span class="keyword">const</span> uint8_t <a class="code" href="classRTC.html#a02ace2d775063be9a99035851c9274eb" title="Wrap around to the beginning of the current month/year rather than advance to the next one...">WRAP</a> = 0x0002;
|
|
<a name="l00091"></a>00091
|
|
<a name="l00092"></a>00092 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#adc29d7c43efc5a192d21965da5c3ee1d" title="Adjusts date up or down one day according to flags.">adjustDays</a>(<a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *date, uint8_t flags);
|
|
<a name="l00093"></a>00093 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#aeca597e6e37a05716e664242f9cfc5f4" title="Adjusts date up or down one month according to flags.">adjustMonths</a>(<a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *date, uint8_t flags);
|
|
<a name="l00094"></a>00094 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classRTC.html#a31d10cb2f7cac8839bd4be2d858b802d" title="Adjusts date up or down one year according to flags.">adjustYears</a>(<a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *date, uint8_t flags);
|
|
<a name="l00095"></a>00095
|
|
<a name="l00096"></a>00096 <span class="keyword">static</span> <a class="code" href="classRTC.html#ab2ca0cbee608ec32d3d6e04d40298f11" title="Day of the week corresponding to a date.">DayOfWeek</a> <a class="code" href="classRTC.html#a525a9c1dad89613708f47a683eb316aa" title="Returns the day of the week corresponding to date.">dayOfWeek</a>(<span class="keyword">const</span> <a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> *date);
|
|
<a name="l00097"></a>00097
|
|
<a name="l00098"></a>00098 <span class="keyword">private</span>:
|
|
<a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> midnight;
|
|
<a name="l00100"></a>00100 <a class="code" href="structRTCDate.html" title="Stores date information from a realtime clock chip.">RTCDate</a> date;
|
|
<a name="l00101"></a>00101 <a class="code" href="structRTCAlarm.html" title="Stores alarm information from a realtime clock chip.">RTCAlarm</a> alarms[<a class="code" href="classRTC.html#aee5ae8f600ee5296e65635c0d836fca3" title="Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().">ALARM_COUNT</a>];
|
|
<a name="l00102"></a>00102 uint8_t *nvram;
|
|
<a name="l00103"></a>00103 };
|
|
<a name="l00104"></a>00104
|
|
<a name="l00105"></a>00105 <span class="preprocessor">#endif</span>
|
|
</pre></div></div>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a></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>
|
|
|
|
<hr class="footer"/><address class="footer"><small>Generated on Mon Jun 18 2012 11:02:52 for ArduinoLibs by 
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
|
|
</body>
|
|
</html>
|