You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MicroDexed/third-party/Bounce2/docs/files/_bounce2_8h_source.html

272 lines
38 KiB

<!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.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Bounce2: src/Bounce2.h Source File</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">Bounce2
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @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&amp;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>
<!-- 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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Bounce2.h</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment"> The MIT License (MIT)</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> Copyright (c) 2013 thomasfredericks</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> Permission is hereby granted, free of charge, to any person obtaining a copy of</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment"> this software and associated documentation files (the &quot;Software&quot;), to deal in</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment"> the Software without restriction, including without limitation the rights to</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment"> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment"> the Software, and to permit persons to whom the Software is furnished to do so,</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment"> subject to the following conditions:</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"> The above copyright notice and this permission notice shall be included in all</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment"> copies or substantial portions of the Software.</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment"> THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment"> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment"> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="comment"> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="comment"> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="comment"> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="comment">*/</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="comment">/* * * * * * * * * * * * * * * * * * * * * * * * * * * *</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="comment"> Main code by Thomas O Fredericks (tof@t-o-f.info)</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="comment"> Previous contributions by Eric Lowry, Jim Schimpf and Tom Harkaway</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="comment"> * * * * * * * * * * * * * * * * * * * * * * * * * * * * */</span></div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; </div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="preprocessor">#ifndef Bounce2_h</span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;<span class="preprocessor">#define Bounce2_h</span></div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; </div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;<span class="preprocessor">#if defined(ARDUINO) &amp;&amp; ARDUINO &gt;= 100</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160;<span class="preprocessor">#include &quot;Arduino.h&quot;</span></div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="preprocessor">#include &quot;WProgram.h&quot;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="comment">// Uncomment the following line for &quot;LOCK-OUT&quot; debounce method</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="comment">//#define BOUNCE_LOCK_OUT</span></div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160;<span class="comment">// Uncomment the following line for &quot;BOUNCE_WITH_PROMPT_DETECTION&quot; debounce method</span></div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160;<span class="comment">//#define BOUNCE_WITH_PROMPT_DETECTION</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; </div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160;<span class="preprocessor">#include &lt;inttypes.h&gt;</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; </div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="class_debouncer.html"> 62</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_debouncer.html">Debouncer</a></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160;{</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="comment">// Note : this is private as it migh change in the futur</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <span class="keyword">static</span> <span class="keyword">const</span> uint8_t DEBOUNCED_STATE = 0b00000001;</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="keyword">static</span> <span class="keyword">const</span> uint8_t UNSTABLE_STATE = 0b00000010;</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="keyword">static</span> <span class="keyword">const</span> uint8_t CHANGED_STATE = 0b00000100;</div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="keyword">inline</span> <span class="keywordtype">void</span> changeState();</div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="keyword">inline</span> <span class="keywordtype">void</span> setStateFlag(<span class="keyword">const</span> uint8_t flag) {state |= flag;}</div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keyword">inline</span> <span class="keywordtype">void</span> unsetStateFlag(<span class="keyword">const</span> uint8_t flag) {state &amp;= ~flag;}</div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <span class="keyword">inline</span> <span class="keywordtype">void</span> toggleStateFlag(<span class="keyword">const</span> uint8_t flag) {state ^= flag;}</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keyword">inline</span> <span class="keywordtype">bool</span> getStateFlag(<span class="keyword">const</span> uint8_t flag) {<span class="keywordflow">return</span>((state &amp; flag) != 0);}</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; <a class="code" href="class_debouncer.html#a34c46ca04d4178933cc0049436d10fe6">Debouncer</a>();</div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; <span class="keywordtype">void</span> <a class="code" href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">interval</a>(uint16_t interval_millis);</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; </div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06">update</a>();</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; </div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a2cae68910c19c778507f257842fc41bf">read</a>();</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a1ef5a04b4ebe97352ff3bb227476035c">fell</a>();</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; </div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a9990de6fa7256842c35c246d7dea8dbb">rose</a>();</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; </div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; </div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; </div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00129"></a><span class="lineno"><a class="line" href="class_debouncer.html#a47c83f13a03920d21fbfafd8469ec06b"> 129</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a47c83f13a03920d21fbfafd8469ec06b">changed</a>( ) { <span class="keywordflow">return</span> getStateFlag(CHANGED_STATE); }</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; </div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448">duration</a>();</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; </div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="class_debouncer.html#a89ab95e7ac24874bb8cb684dc36a98b9">previousDuration</a>(); </div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; </div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160; <span class="keywordtype">void</span> begin();</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">bool</span> readCurrentState() =0;</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> previous_millis;</div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; uint16_t interval_millis;</div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; uint8_t state;</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> stateChangeLastTime;</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160; <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> durationOfPreviousState;</div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; </div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160;};</div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; </div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; </div>
<div class="line"><a name="l00166"></a><span class="lineno"><a class="line" href="class_bounce.html"> 166</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_bounce.html">Bounce</a> : <span class="keyword">public</span> <a class="code" href="class_debouncer.html">Debouncer</a></div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160;{</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; </div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; </div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; </div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160; <a class="code" href="class_bounce.html#aa62a2e2b5ad0ee6913a95f2f2a0e7606">Bounce</a>();</div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; </div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; <span class="keywordtype">void</span> <a class="code" href="class_bounce.html#aba08e592941465d033e3eba3dde66eaf">attach</a>(<span class="keywordtype">int</span> <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, <span class="keywordtype">int</span> mode);</div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160; </div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; <span class="keywordtype">void</span> <a class="code" href="class_bounce.html#aba08e592941465d033e3eba3dde66eaf">attach</a>(<span class="keywordtype">int</span> <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>);</div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; </div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; <a class="code" href="class_bounce.html#aa62a2e2b5ad0ee6913a95f2f2a0e7606">Bounce</a>(uint8_t <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> interval_millis ) : <a class="code" href="class_bounce.html#aa62a2e2b5ad0ee6913a95f2f2a0e7606">Bounce</a>() {</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <a class="code" href="class_bounce.html#aba08e592941465d033e3eba3dde66eaf">attach</a>(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>);</div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <a class="code" href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">interval</a>(interval_millis);</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; }</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; </div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; <span class="comment">// Deprecated //</span></div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00212"></a><span class="lineno"><a class="line" href="class_bounce.html#a3417beb80eb6593d768c2e9884c57aa0"> 212</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_bounce.html#a3417beb80eb6593d768c2e9884c57aa0">risingEdge</a>() { <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a9990de6fa7256842c35c246d7dea8dbb">rose</a>(); }</div>
<div class="line"><a name="l00216"></a><span class="lineno"><a class="line" href="class_bounce.html#ac756559419bfa1c5060e5e4a4ad6406f"> 216</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="class_bounce.html#ac756559419bfa1c5060e5e4a4ad6406f">fallingEdge</a>() { <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a1ef5a04b4ebe97352ff3bb227476035c">fell</a>(); }</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; </div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; </div>
<div class="line"><a name="l00225"></a><span class="lineno"><a class="line" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a"> 225</a></span>&#160; uint8_t <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>;</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; </div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">bool</span> readCurrentState() { <span class="keywordflow">return</span> digitalRead(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>); }</div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <span class="keyword">virtual</span> <span class="keywordtype">void</span> setPinMode(<span class="keywordtype">int</span> <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, <span class="keywordtype">int</span> mode) {</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160;<span class="preprocessor">#if defined(ARDUINO_ARCH_STM32F1)</span></div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; pinMode(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, (WiringPinMode)mode);</div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; pinMode(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, mode);</div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; }</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; </div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; </div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160;};</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; </div>
<div class="line"><a name="l00243"></a><span class="lineno"><a class="line" href="namespace_bounce2.html"> 243</a></span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_bounce2.html">Bounce2</a> {</div>
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; <span class="comment">// code declarations</span></div>
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; </div>
<div class="line"><a name="l00246"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html"> 246</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_bounce2_1_1_button.html">Button</a> : <span class="keyword">public</span> <a class="code" href="class_bounce.html">Bounce</a>{</div>
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; <span class="keywordtype">bool</span> stateForPressed = 1; <span class="comment">// </span></div>
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00260"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a18710b645862d2b8f058a73aabbaf7ad"> 260</a></span>&#160; <a class="code" href="class_bounce2_1_1_button.html#a18710b645862d2b8f058a73aabbaf7ad">Button</a>(){ }</div>
<div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; </div>
<div class="line"><a name="l00269"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a3c88b7938b26bca9dc2c7e72aedc442e"> 269</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="class_bounce2_1_1_button.html#a3c88b7938b26bca9dc2c7e72aedc442e">setPressedState</a>(<span class="keywordtype">bool</span> state){</div>
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; stateForPressed = state;</div>
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160; }</div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; </div>
<div class="line"><a name="l00276"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#ab9e2b89ad499fa4b052370140730b6ba"> 276</a></span>&#160; <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#ab9e2b89ad499fa4b052370140730b6ba">getPressedState</a>() {</div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160; <span class="keywordflow">return</span> stateForPressed;</div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160; };</div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160; </div>
<div class="line"><a name="l00283"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a94c31de8109c89d6ee577ed9b14ea676"> 283</a></span>&#160; <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a94c31de8109c89d6ee577ed9b14ea676">isPressed</a>() {</div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a2cae68910c19c778507f257842fc41bf">read</a>() == <a class="code" href="class_bounce2_1_1_button.html#ab9e2b89ad499fa4b052370140730b6ba">getPressedState</a>();</div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; };</div>
<div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; </div>
<div class="line"><a name="l00290"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a3fbacfb9a631e03afcfaa5dc39686bad"> 290</a></span>&#160; <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a3fbacfb9a631e03afcfaa5dc39686bad">pressed</a>() {</div>
<div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160; <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a47c83f13a03920d21fbfafd8469ec06b">changed</a>() &amp;&amp; <a class="code" href="class_bounce2_1_1_button.html#a94c31de8109c89d6ee577ed9b14ea676">isPressed</a>();</div>
<div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160; };</div>
<div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160; </div>
<div class="line"><a name="l00297"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a902d9df3cd993f80f59bcb205ed4be37"> 297</a></span>&#160; <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a902d9df3cd993f80f59bcb205ed4be37">released</a>() {</div>
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>&#160; <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a47c83f13a03920d21fbfafd8469ec06b">changed</a>() &amp;&amp; !<a class="code" href="class_bounce2_1_1_button.html#a94c31de8109c89d6ee577ed9b14ea676">isPressed</a>();</div>
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>&#160; };</div>
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160; </div>
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>&#160;};</div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>&#160;};</div>
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>&#160; </div>
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_bounce2_1_1_button_html"><div class="ttname"><a href="class_bounce2_1_1_button.html">Bounce2::Button</a></div><div class="ttdef"><b>Definition:</b> Bounce2.h:246</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_ab9e2b89ad499fa4b052370140730b6ba"><div class="ttname"><a href="class_bounce2_1_1_button.html#ab9e2b89ad499fa4b052370140730b6ba">Bounce2::Button::getPressedState</a></div><div class="ttdeci">bool getPressedState()</div><div class="ttdoc">Get the electrical state (HIGH/LOW) that corresponds to a physical press.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:276</div></div>
<div class="ttc" id="aclass_debouncer_html_a1ef5a04b4ebe97352ff3bb227476035c"><div class="ttname"><a href="class_debouncer.html#a1ef5a04b4ebe97352ff3bb227476035c">Debouncer::fell</a></div><div class="ttdeci">bool fell()</div><div class="ttdoc">Returns true if pin signal transitions from high to low.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:128</div></div>
<div class="ttc" id="aclass_debouncer_html_a930bf3945e698d77b889f6309079857d"><div class="ttname"><a href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">Debouncer::interval</a></div><div class="ttdeci">void interval(uint16_t interval_millis)</div><div class="ttdoc">Sets the debounce interval in milliseconds.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:14</div></div>
<div class="ttc" id="aclass_debouncer_html_a2cae68910c19c778507f257842fc41bf"><div class="ttname"><a href="class_debouncer.html#a2cae68910c19c778507f257842fc41bf">Debouncer::read</a></div><div class="ttdeci">bool read()</div><div class="ttdoc">Returns the pin's state (HIGH or LOW).</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:118</div></div>
<div class="ttc" id="aclass_bounce_html_aa62a2e2b5ad0ee6913a95f2f2a0e7606"><div class="ttname"><a href="class_bounce.html#aa62a2e2b5ad0ee6913a95f2f2a0e7606">Bounce::Bounce</a></div><div class="ttdeci">Bounce()</div><div class="ttdoc">Create an instance of the Bounce class.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:138</div></div>
<div class="ttc" id="aclass_debouncer_html_a47c83f13a03920d21fbfafd8469ec06b"><div class="ttname"><a href="class_debouncer.html#a47c83f13a03920d21fbfafd8469ec06b">Debouncer::changed</a></div><div class="ttdeci">bool changed()</div><div class="ttdoc">Returns true if the state changed on last update.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:129</div></div>
<div class="ttc" id="aclass_debouncer_html_a462994f1f9a20876b2ee239eeee97448"><div class="ttname"><a href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448">Debouncer::duration</a></div><div class="ttdeci">unsigned long duration()</div><div class="ttdoc">Returns the duration in milliseconds of the current state.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:107</div></div>
<div class="ttc" id="aclass_debouncer_html_a9990de6fa7256842c35c246d7dea8dbb"><div class="ttname"><a href="class_debouncer.html#a9990de6fa7256842c35c246d7dea8dbb">Debouncer::rose</a></div><div class="ttdeci">bool rose()</div><div class="ttdoc">Returns true if pin signal transitions from low to high.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:123</div></div>
<div class="ttc" id="aclass_bounce_html_a1cb79cb0ba2379cd12cc7c098d97053a"><div class="ttname"><a href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">Bounce::pin</a></div><div class="ttdeci">uint8_t pin</div><div class="ttdoc">Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:225</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_a902d9df3cd993f80f59bcb205ed4be37"><div class="ttname"><a href="class_bounce2_1_1_button.html#a902d9df3cd993f80f59bcb205ed4be37">Bounce2::Button::released</a></div><div class="ttdeci">bool released()</div><div class="ttdoc">Returns true if the button was physically released</div><div class="ttdef"><b>Definition:</b> Bounce2.h:297</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_a94c31de8109c89d6ee577ed9b14ea676"><div class="ttname"><a href="class_bounce2_1_1_button.html#a94c31de8109c89d6ee577ed9b14ea676">Bounce2::Button::isPressed</a></div><div class="ttdeci">bool isPressed()</div><div class="ttdoc">Returns true if the button is currently physically pressed.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:283</div></div>
<div class="ttc" id="aclass_bounce_html_a3417beb80eb6593d768c2e9884c57aa0"><div class="ttname"><a href="class_bounce.html#a3417beb80eb6593d768c2e9884c57aa0">Bounce::risingEdge</a></div><div class="ttdeci">bool risingEdge()</div><div class="ttdoc">Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:212</div></div>
<div class="ttc" id="aclass_debouncer_html_a72f3e8d483555031d2ac21b0b7702c06"><div class="ttname"><a href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06">Debouncer::update</a></div><div class="ttdeci">bool update()</div><div class="ttdoc">Updates the pin's state.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:32</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_a18710b645862d2b8f058a73aabbaf7ad"><div class="ttname"><a href="class_bounce2_1_1_button.html#a18710b645862d2b8f058a73aabbaf7ad">Bounce2::Button::Button</a></div><div class="ttdeci">Button()</div><div class="ttdoc">Create an instance of the Button class. By default, the pressed state is matched to a HIGH electrical...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:260</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_a3fbacfb9a631e03afcfaa5dc39686bad"><div class="ttname"><a href="class_bounce2_1_1_button.html#a3fbacfb9a631e03afcfaa5dc39686bad">Bounce2::Button::pressed</a></div><div class="ttdeci">bool pressed()</div><div class="ttdoc">Returns true if the button was physically pressed</div><div class="ttdef"><b>Definition:</b> Bounce2.h:290</div></div>
<div class="ttc" id="aclass_debouncer_html_a89ab95e7ac24874bb8cb684dc36a98b9"><div class="ttname"><a href="class_debouncer.html#a89ab95e7ac24874bb8cb684dc36a98b9">Debouncer::previousDuration</a></div><div class="ttdeci">unsigned long previousDuration()</div><div class="ttdoc">Returns the duration in milliseconds of the previous state.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:103</div></div>
<div class="ttc" id="aclass_bounce_html"><div class="ttname"><a href="class_bounce.html">Bounce</a></div><div class="ttdoc">The Debouncer:Bounce class. Links the Deboucing class to a hardware pin.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:166</div></div>
<div class="ttc" id="aclass_debouncer_html"><div class="ttname"><a href="class_debouncer.html">Debouncer</a></div><div class="ttdoc">The Debouce class. Just the deboucing code separated from all harware.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:62</div></div>
<div class="ttc" id="aclass_bounce2_1_1_button_html_a3c88b7938b26bca9dc2c7e72aedc442e"><div class="ttname"><a href="class_bounce2_1_1_button.html#a3c88b7938b26bca9dc2c7e72aedc442e">Bounce2::Button::setPressedState</a></div><div class="ttdeci">void setPressedState(bool state)</div><div class="ttdoc">Set the electrical state (HIGH/LOW) that corresponds to a physical press. By default,...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:269</div></div>
<div class="ttc" id="aclass_bounce_html_ac756559419bfa1c5060e5e4a4ad6406f"><div class="ttname"><a href="class_bounce.html#ac756559419bfa1c5060e5e4a4ad6406f">Bounce::fallingEdge</a></div><div class="ttdeci">bool fallingEdge()</div><div class="ttdoc">Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce ver...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:216</div></div>
<div class="ttc" id="aclass_bounce_html_aba08e592941465d033e3eba3dde66eaf"><div class="ttname"><a href="class_bounce.html#aba08e592941465d033e3eba3dde66eaf">Bounce::attach</a></div><div class="ttdeci">void attach(int pin, int mode)</div><div class="ttdoc">Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT).</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:149</div></div>
<div class="ttc" id="anamespace_bounce2_html"><div class="ttname"><a href="namespace_bounce2.html">Bounce2</a></div><div class="ttdoc">The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:243</div></div>
<div class="ttc" id="aclass_debouncer_html_a34c46ca04d4178933cc0049436d10fe6"><div class="ttname"><a href="class_debouncer.html#a34c46ca04d4178933cc0049436d10fe6">Debouncer::Debouncer</a></div><div class="ttdeci">Debouncer()</div><div class="ttdoc">Create an instance of the Debounce class.</div><div class="ttdef"><b>Definition:</b> Bounce2.cpp:10</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>