1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00
arduinolibs/TimeField_8cpp_source.html
Rhys Weatherley 448ca56a5a Update docs
2012-06-10 10:52:14 +10:00

305 lines
26 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: TimeField.cpp 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&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;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&#160;List</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<div class="title">TimeField.cpp</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 &quot;Software&quot;),</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 &quot;AS IS&quot;, 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">#include &quot;TimeField.h&quot;</span>
<a name="l00024"></a>00024
<a name="l00065"></a>00065 <span class="preprocessor">#define EDIT_HOUR 0</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#define EDIT_MINUTE_TENS 1</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span><span class="preprocessor">#define EDIT_MINUTE 2</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span><span class="preprocessor">#define EDIT_SECOND_TENS 3</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#define EDIT_SECOND 4</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span>
<a name="l00082"></a><a class="code" href="classTimeField.html#a138e2425379705828a87eb2d8a836431">00082</a> <a class="code" href="classTimeField.html#a138e2425379705828a87eb2d8a836431" title="Constructs a new time field with a specific label.">TimeField::TimeField</a>(<span class="keyword">const</span> String &amp;label)
<a name="l00083"></a>00083 : <a class="code" href="classField.html" title="Manages a single data input/output field within a Form.">Field</a>(label)
<a name="l00084"></a>00084 , _value(0)
<a name="l00085"></a>00085 , _maxHours(24)
<a name="l00086"></a>00086 , _printLen(0)
<a name="l00087"></a>00087 , _readOnly(false)
<a name="l00088"></a>00088 , editField(EDIT_HOUR)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091
<a name="l00105"></a><a class="code" href="classTimeField.html#a87f222bc098367963ed21a7edc4624de">00105</a> <a class="code" href="classTimeField.html#a138e2425379705828a87eb2d8a836431" title="Constructs a new time field with a specific label.">TimeField::TimeField</a>(<a class="code" href="classForm.html" title="Manager for a form containing data input/output fields.">Form</a> &amp;form, <span class="keyword">const</span> String &amp;label, <span class="keywordtype">int</span> maxHours, <span class="keywordtype">bool</span> readOnly)
<a name="l00106"></a>00106 : <a class="code" href="classField.html" title="Manages a single data input/output field within a Form.">Field</a>(form, label)
<a name="l00107"></a>00107 , _value(0)
<a name="l00108"></a>00108 , _maxHours(maxHours)
<a name="l00109"></a>00109 , _printLen(0)
<a name="l00110"></a>00110 , _readOnly(readOnly)
<a name="l00111"></a>00111 , editField(EDIT_HOUR)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114
<a name="l00115"></a><a class="code" href="classTimeField.html#a9b953d9abdbe960a3fa34938462832e5">00115</a> <span class="keywordtype">int</span> <a class="code" href="classTimeField.html#a9b953d9abdbe960a3fa34938462832e5" title="Dispatches event via this field.">TimeField::dispatch</a>(<span class="keywordtype">int</span> event)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> newValue;
<a name="l00118"></a>00118 <span class="keywordflow">if</span> (_readOnly)
<a name="l00119"></a>00119 <span class="keywordflow">return</span> -1;
<a name="l00120"></a>00120 <span class="keywordflow">if</span> (event == LCD_BUTTON_UP) {
<a name="l00121"></a>00121 newValue = _value;
<a name="l00122"></a>00122 <span class="keywordflow">if</span> (editField == EDIT_HOUR) {
<a name="l00123"></a>00123 newValue += 60 * 60;
<a name="l00124"></a>00124 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE_TENS) {
<a name="l00125"></a>00125 <span class="keywordflow">if</span> (((newValue / 60) % 60) &gt;= 50)
<a name="l00126"></a>00126 newValue -= 50 * 60;
<a name="l00127"></a>00127 <span class="keywordflow">else</span>
<a name="l00128"></a>00128 newValue += 10 * 60;
<a name="l00129"></a>00129 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE) {
<a name="l00130"></a>00130 <span class="keywordflow">if</span> (((newValue / 60) % 60) == 59)
<a name="l00131"></a>00131 newValue -= 59 * 60;
<a name="l00132"></a>00132 <span class="keywordflow">else</span>
<a name="l00133"></a>00133 newValue += 60;
<a name="l00134"></a>00134 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_SECOND_TENS) {
<a name="l00135"></a>00135 <span class="keywordflow">if</span> ((newValue % 60) &gt;= 50)
<a name="l00136"></a>00136 newValue -= 50;
<a name="l00137"></a>00137 <span class="keywordflow">else</span>
<a name="l00138"></a>00138 newValue += 10;
<a name="l00139"></a>00139 } <span class="keywordflow">else</span> {
<a name="l00140"></a>00140 <span class="keywordflow">if</span> ((newValue % 60) == 59)
<a name="l00141"></a>00141 newValue -= 59;
<a name="l00142"></a>00142 <span class="keywordflow">else</span>
<a name="l00143"></a>00143 newValue += 1;
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 <a class="code" href="classTimeField.html#a063b6df2bd6fa7970ee445ab4e5d1fc1" title="Sets the value of this time field, in seconds.">setValue</a>(newValue);
<a name="l00146"></a>00146 <span class="keywordflow">return</span> FORM_CHANGED;
<a name="l00147"></a>00147 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event == LCD_BUTTON_DOWN) {
<a name="l00148"></a>00148 newValue = _value;
<a name="l00149"></a>00149 <span class="keywordflow">if</span> (editField == EDIT_HOUR) {
<a name="l00150"></a>00150 <span class="keywordflow">if</span> (newValue &lt; 60 * 60)
<a name="l00151"></a>00151 newValue += ((<span class="keywordtype">unsigned</span> long)(_maxHours - 1)) * 60 * 60;
<a name="l00152"></a>00152 <span class="keywordflow">else</span>
<a name="l00153"></a>00153 newValue -= 60 * 60;
<a name="l00154"></a>00154 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE_TENS) {
<a name="l00155"></a>00155 <span class="keywordflow">if</span> (((newValue / 60) % 60) &lt; 10)
<a name="l00156"></a>00156 newValue += 50 * 60;
<a name="l00157"></a>00157 <span class="keywordflow">else</span>
<a name="l00158"></a>00158 newValue -= 10 * 60;
<a name="l00159"></a>00159 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE) {
<a name="l00160"></a>00160 <span class="keywordflow">if</span> (((newValue / 60) % 60) == 0)
<a name="l00161"></a>00161 newValue += 59 * 60;
<a name="l00162"></a>00162 <span class="keywordflow">else</span>
<a name="l00163"></a>00163 newValue -= 60;
<a name="l00164"></a>00164 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_SECOND_TENS) {
<a name="l00165"></a>00165 <span class="keywordflow">if</span> ((newValue % 60) &lt; 10)
<a name="l00166"></a>00166 newValue += 50;
<a name="l00167"></a>00167 <span class="keywordflow">else</span>
<a name="l00168"></a>00168 newValue -= 10;
<a name="l00169"></a>00169 } <span class="keywordflow">else</span> {
<a name="l00170"></a>00170 <span class="keywordflow">if</span> ((newValue % 60) == 0)
<a name="l00171"></a>00171 newValue += 59;
<a name="l00172"></a>00172 <span class="keywordflow">else</span>
<a name="l00173"></a>00173 newValue -= 1;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 <a class="code" href="classTimeField.html#a063b6df2bd6fa7970ee445ab4e5d1fc1" title="Sets the value of this time field, in seconds.">setValue</a>(newValue);
<a name="l00176"></a>00176 <span class="keywordflow">return</span> FORM_CHANGED;
<a name="l00177"></a>00177 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event == LCD_BUTTON_LEFT) {
<a name="l00178"></a>00178 <span class="keywordflow">if</span> (editField != EDIT_HOUR) {
<a name="l00179"></a>00179 --editField;
<a name="l00180"></a>00180 printTime();
<a name="l00181"></a>00181 <span class="keywordflow">return</span> 0;
<a name="l00182"></a>00182 }
<a name="l00183"></a>00183 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event == LCD_BUTTON_RIGHT) {
<a name="l00184"></a>00184 <span class="keywordflow">if</span> (editField != EDIT_SECOND) {
<a name="l00185"></a>00185 ++editField;
<a name="l00186"></a>00186 printTime();
<a name="l00187"></a>00187 <span class="keywordflow">return</span> 0;
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 }
<a name="l00190"></a>00190 <span class="keywordflow">return</span> -1;
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192
<a name="l00193"></a><a class="code" href="classTimeField.html#ae914d6b870283a334d2d669460f7646b">00193</a> <span class="keywordtype">void</span> <a class="code" href="classTimeField.html#ae914d6b870283a334d2d669460f7646b" title="Enters the field due to form navigation.">TimeField::enterField</a>(<span class="keywordtype">bool</span> reverse)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 <a class="code" href="classTimeField.html#ae914d6b870283a334d2d669460f7646b" title="Enters the field due to form navigation.">Field::enterField</a>(reverse);
<a name="l00196"></a>00196 <span class="keywordflow">if</span> (reverse)
<a name="l00197"></a>00197 editField = EDIT_SECOND;
<a name="l00198"></a>00198 <span class="keywordflow">else</span>
<a name="l00199"></a>00199 editField = EDIT_HOUR;
<a name="l00200"></a>00200 printTime();
<a name="l00201"></a>00201 <span class="keywordflow">if</span> (!_readOnly)
<a name="l00202"></a>00202 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;cursor();
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204
<a name="l00205"></a><a class="code" href="classTimeField.html#a5a6b7db2e3fda7745e0ff9c3d8d9a541">00205</a> <span class="keywordtype">void</span> <a class="code" href="classTimeField.html#a5a6b7db2e3fda7745e0ff9c3d8d9a541" title="Exits the field due to form navigation.">TimeField::exitField</a>()
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207 <span class="keywordflow">if</span> (!_readOnly)
<a name="l00208"></a>00208 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;noCursor();
<a name="l00209"></a>00209 <a class="code" href="classTimeField.html#a5a6b7db2e3fda7745e0ff9c3d8d9a541" title="Exits the field due to form navigation.">Field::exitField</a>();
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211
<a name="l00227"></a><a class="code" href="classTimeField.html#a063b6df2bd6fa7970ee445ab4e5d1fc1">00227</a> <span class="keywordtype">void</span> <a class="code" href="classTimeField.html#a063b6df2bd6fa7970ee445ab4e5d1fc1" title="Sets the value of this time field, in seconds.">TimeField::setValue</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> value)
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> maxSecs = ((<span class="keywordtype">unsigned</span> long)_maxHours) * 60 * 60;
<a name="l00230"></a>00230 value %= maxSecs;
<a name="l00231"></a>00231 <span class="keywordflow">if</span> (value != _value) {
<a name="l00232"></a>00232 _value = <a class="code" href="classTimeField.html#a400aaa72a83b3b872e1de1c3af1a240f" title="Returns the current value of this time field, in seconds.">value</a>;
<a name="l00233"></a>00233 <span class="keywordflow">if</span> (<a class="code" href="classField.html#a25d86a67b321e8c642edf75a10a35f72" title="Returns true if this field is the currently-displayed field in its owning form; false otherwise...">isCurrent</a>())
<a name="l00234"></a>00234 printTime();
<a name="l00235"></a>00235 }
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237
<a name="l00268"></a><a class="code" href="classTimeField.html#a3f002a0729e90e88d04025908be102fe">00268</a> <span class="keywordtype">void</span> <a class="code" href="classTimeField.html#a3f002a0729e90e88d04025908be102fe" title="Sets the read-only state of this field to value.">TimeField::setReadOnly</a>(<span class="keywordtype">bool</span> value)
<a name="l00269"></a>00269 {
<a name="l00270"></a>00270 <span class="keywordflow">if</span> (_readOnly != value) {
<a name="l00271"></a>00271 _readOnly = <a class="code" href="classTimeField.html#a400aaa72a83b3b872e1de1c3af1a240f" title="Returns the current value of this time field, in seconds.">value</a>;
<a name="l00272"></a>00272 printTime();
<a name="l00273"></a>00273 <span class="keywordflow">if</span> (<a class="code" href="classField.html#a25d86a67b321e8c642edf75a10a35f72" title="Returns true if this field is the currently-displayed field in its owning form; false otherwise...">isCurrent</a>()) {
<a name="l00274"></a>00274 <span class="keywordflow">if</span> (value)
<a name="l00275"></a>00275 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;cursor();
<a name="l00276"></a>00276 <span class="keywordflow">else</span>
<a name="l00277"></a>00277 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;noCursor();
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 }
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <span class="keywordtype">void</span> TimeField::printTime()
<a name="l00283"></a>00283 {
<a name="l00284"></a>00284 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(0, 1);
<a name="l00285"></a>00285 <span class="keywordtype">int</span> col = printField(_value / (60 * 60));
<a name="l00286"></a>00286 <span class="keywordtype">int</span> hourCol = col - 1;
<a name="l00287"></a>00287 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39;:&#39;</span>);
<a name="l00288"></a>00288 ++col;
<a name="l00289"></a>00289 col += printField((_value / 60) % 60);
<a name="l00290"></a>00290 <span class="keywordtype">int</span> minuteCol = col - 1;
<a name="l00291"></a>00291 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39;:&#39;</span>);
<a name="l00292"></a>00292 ++col;
<a name="l00293"></a>00293 col += printField(_value % 60);
<a name="l00294"></a>00294 <span class="keywordtype">int</span> secondCol = col - 1;
<a name="l00295"></a>00295 <span class="keywordtype">int</span> tempCol = col;
<a name="l00296"></a>00296 <span class="keywordflow">while</span> (tempCol++ &lt; _printLen)
<a name="l00297"></a>00297 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39; &#39;</span>);
<a name="l00298"></a>00298 _printLen = col;
<a name="l00299"></a>00299 <span class="keywordflow">if</span> (!_readOnly) {
<a name="l00300"></a>00300 <span class="keywordflow">if</span> (editField == EDIT_HOUR)
<a name="l00301"></a>00301 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(hourCol, 1);
<a name="l00302"></a>00302 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE_TENS)
<a name="l00303"></a>00303 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(minuteCol - 1, 1);
<a name="l00304"></a>00304 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_MINUTE)
<a name="l00305"></a>00305 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(minuteCol, 1);
<a name="l00306"></a>00306 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (editField == EDIT_SECOND_TENS)
<a name="l00307"></a>00307 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(secondCol - 1, 1);
<a name="l00308"></a>00308 <span class="keywordflow">else</span>
<a name="l00309"></a>00309 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;setCursor(secondCol, 1);
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311 }
<a name="l00312"></a>00312
<a name="l00313"></a>00313 <span class="keywordtype">int</span> TimeField::printField(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> value)
<a name="l00314"></a>00314 {
<a name="l00315"></a>00315 <span class="keywordflow">if</span> (value &lt; 100) {
<a name="l00316"></a>00316 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39;0&#39;</span> + (<span class="keywordtype">int</span>)(value / 10));
<a name="l00317"></a>00317 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39;0&#39;</span> + (<span class="keywordtype">int</span>)(value % 10));
<a name="l00318"></a>00318 <span class="keywordflow">return</span> 2;
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> divisor = 100;
<a name="l00321"></a>00321 <span class="keywordflow">while</span> ((value / divisor) &gt;= 10)
<a name="l00322"></a>00322 divisor *= 10;
<a name="l00323"></a>00323 <span class="keywordtype">int</span> digits = 0;
<a name="l00324"></a>00324 <span class="keywordflow">while</span> (divisor &gt; 0) {
<a name="l00325"></a>00325 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()-&gt;write(<span class="charliteral">&#39;0&#39;</span> + (<span class="keywordtype">int</span>)((value / divisor) % 10));
<a name="l00326"></a>00326 divisor /= 10;
<a name="l00327"></a>00327 ++digits;
<a name="l00328"></a>00328 }
<a name="l00329"></a>00329 <span class="keywordflow">return</span> digits;
<a name="l00330"></a>00330 }
</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">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</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 Sun Jun 10 2012 10:51:56 for ArduinoLibs by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>