123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <!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&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&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> <span class="comment">/*</span></div>
- <div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> The MIT License (MIT)</span></div>
- <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"></span> </div>
- <div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> Copyright (c) 2013 thomasfredericks</span></div>
- <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"></span> </div>
- <div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <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> <span class="comment"> this software and associated documentation files (the "Software"), to deal in</span></div>
- <div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <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> <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> <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> <span class="comment"> subject to the following conditions:</span></div>
- <div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"></span> </div>
- <div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <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> <span class="comment"> copies or substantial portions of the Software.</span></div>
- <div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"></span> </div>
- <div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div>
- <div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <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> <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> <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> <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> <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> <span class="comment">*/</span></div>
- <div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  </div>
- <div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment">/* * * * * * * * * * * * * * * * * * * * * * * * * * * *</span></div>
- <div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <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> <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> <span class="comment"> * * * * * * * * * * * * * * * * * * * * * * * * * * * * */</span></div>
- <div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  </div>
- <div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  </div>
- <div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor">#ifndef Bounce2_h</span></div>
- <div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#define Bounce2_h</span></div>
- <div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  </div>
- <div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#if defined(ARDUINO) && ARDUINO >= 100</span></div>
- <div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include "Arduino.h"</span></div>
- <div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#else</span></div>
- <div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="preprocessor">#include "WProgram.h"</span></div>
- <div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="preprocessor">#endif</span></div>
- <div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  </div>
- <div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="comment">// Uncomment the following line for "LOCK-OUT" debounce method</span></div>
- <div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="comment">//#define BOUNCE_LOCK_OUT</span></div>
- <div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  </div>
- <div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="comment">// Uncomment the following line for "BOUNCE_WITH_PROMPT_DETECTION" debounce method</span></div>
- <div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="comment">//#define BOUNCE_WITH_PROMPT_DETECTION</span></div>
- <div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  </div>
- <div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="preprocessor">#include <inttypes.h></span></div>
- <div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  </div>
- <div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="class_debouncer.html"> 62</a></span> <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> {</div>
- <div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <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> <span class="keyword">private</span>:</div>
- <div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="keyword">static</span> <span class="keyword">const</span> uint8_t DEBOUNCED_STATE = 0b00000001; <span class="comment">// Final returned calculated debounced state</span></div>
- <div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keyword">static</span> <span class="keyword">const</span> uint8_t UNSTABLE_STATE = 0b00000010; <span class="comment">// Actual last state value behind the scene</span></div>
- <div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="keyword">static</span> <span class="keyword">const</span> uint8_t CHANGED_STATE = 0b00000100; <span class="comment">// The DEBOUNCED_STATE has changed since last update()</span></div>
- <div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  </div>
- <div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="comment">// Note : this is private as it migh change in the futur</span></div>
- <div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="keyword">private</span>:</div>
- <div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keyword">inline</span> <span class="keywordtype">void</span> changeState();</div>
- <div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <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="l00074"></a><span class="lineno"> 74</span>  <span class="keyword">inline</span> <span class="keywordtype">void</span> unsetStateFlag(<span class="keyword">const</span> uint8_t flag) {state &= ~flag;}</div>
- <div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <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="l00076"></a><span class="lineno"> 76</span>  <span class="keyword">inline</span> <span class="keywordtype">bool</span> getStateFlag(<span class="keyword">const</span> uint8_t flag)<span class="keyword"> const </span>{<span class="keywordflow">return</span>((state & flag) != 0);}</div>
- <div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  </div>
- <div class="line"><a name="l00078"></a><span class="lineno"> 78</span> <span class="keyword">public</span>:</div>
- <div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <a class="code" href="class_debouncer.html#a34c46ca04d4178933cc0049436d10fe6">Debouncer</a>();</div>
- <div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  </div>
- <div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <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="l00094"></a><span class="lineno"> 94</span>  </div>
- <div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a72f3e8d483555031d2ac21b0b7702c06">update</a>();</div>
- <div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  </div>
- <div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#aa5fcde9156f700c362fd49af5dd92ecd">read</a>() <span class="keyword">const</span>;</div>
- <div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  </div>
- <div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a80315de311b855f9787b4b6d5b7899e0">fell</a>() <span class="keyword">const</span>;</div>
- <div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  </div>
- <div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#ab61244e043754ebdc7a156da1e1824bf">rose</a>() <span class="keyword">const</span>;</div>
- <div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  </div>
- <div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  </div>
- <div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  </div>
- <div class="line"><a name="l00124"></a><span class="lineno"> 124</span> <span class="keyword">public</span>:</div>
- <div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248"> 130</a></span>  <span class="keywordtype">bool</span> <a class="code" href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">changed</a>( )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> getStateFlag(CHANGED_STATE); }</div>
- <div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  </div>
- <div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  </div>
- <div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  </div>
- <div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  </div>
- <div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11">currentDuration</a>() <span class="keyword">const</span>;</div>
- <div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  </div>
- <div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  </div>
- <div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="class_debouncer.html#ac6af22dc9c6ae84462fe356b7430659e">previousDuration</a>() <span class="keyword">const</span>;</div>
- <div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  </div>
- <div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  [[deprecated]]</div>
- <div class="line"><a name="l00164"></a><span class="lineno"><a class="line" href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448"> 164</a></span>  <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="l00165"></a><span class="lineno"> 165</span>  <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a883645ca26b4df6e5823586432104d11">currentDuration</a>();</div>
- <div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  };</div>
- <div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  </div>
- <div class="line"><a name="l00168"></a><span class="lineno"> 168</span> <span class="keyword">protected</span>:</div>
- <div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordtype">void</span> begin();</div>
- <div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> readCurrentState() =0;</div>
- <div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> previous_millis;</div>
- <div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  uint16_t interval_millis;</div>
- <div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  uint8_t state;</div>
- <div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> stateChangeLastTime;</div>
- <div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> durationOfPreviousState;</div>
- <div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  </div>
- <div class="line"><a name="l00177"></a><span class="lineno"> 177</span> };</div>
- <div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  </div>
- <div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  </div>
- <div class="line"><a name="l00184"></a><span class="lineno"><a class="line" href="class_bounce.html"> 184</a></span> <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="l00185"></a><span class="lineno"> 185</span> {</div>
- <div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  </div>
- <div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  </div>
- <div class="line"><a name="l00188"></a><span class="lineno"> 188</span> <span class="keyword">public</span>:</div>
- <div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  </div>
- <div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <a class="code" href="class_bounce.html#aa62a2e2b5ad0ee6913a95f2f2a0e7606">Bounce</a>();</div>
- <div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  </div>
- <div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  </div>
- <div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <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="l00212"></a><span class="lineno"> 212</span>  </div>
- <div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  <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="l00217"></a><span class="lineno"> 217</span>  </div>
- <div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  <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="l00219"></a><span class="lineno"> 219</span>  <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="l00220"></a><span class="lineno"> 220</span>  <a class="code" href="class_debouncer.html#a930bf3945e698d77b889f6309079857d">interval</a>(interval_millis);</div>
- <div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  }</div>
- <div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  </div>
- <div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  </div>
- <div class="line"><a name="l00229"></a><span class="lineno"><a class="line" href="class_bounce.html#a114878745aa1f29d3c0c293538280646"> 229</a></span>  <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_bounce.html#a114878745aa1f29d3c0c293538280646">getPin</a>()<span class="keyword"> const </span>{</div>
- <div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <span class="keywordflow">return</span> this-><a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>;</div>
- <div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  };</div>
- <div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  </div>
- <div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  <span class="comment">// Deprecated //</span></div>
- <div class="line"><a name="l00236"></a><span class="lineno"> 236</span> <span class="comment"></span> </div>
- <div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  [[deprecated]]</div>
- <div class="line"><a name="l00241"></a><span class="lineno"><a class="line" href="class_bounce.html#adff02eed264355c2bf90d131768f84c2"> 241</a></span>  <span class="keywordtype">bool</span> <a class="code" href="class_bounce.html#adff02eed264355c2bf90d131768f84c2">risingEdge</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#ab61244e043754ebdc7a156da1e1824bf">rose</a>(); }</div>
- <div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  [[deprecated]]</div>
- <div class="line"><a name="l00246"></a><span class="lineno"><a class="line" href="class_bounce.html#a3ef5b85db62a7a7807f0050c86cc735f"> 246</a></span>  <span class="keywordtype">bool</span> <a class="code" href="class_bounce.html#a3ef5b85db62a7a7807f0050c86cc735f">fallingEdge</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a80315de311b855f9787b4b6d5b7899e0">fell</a>(); }</div>
- <div class="line"><a name="l00252"></a><span class="lineno"> 252</span> <span class="keyword">protected</span>:</div>
- <div class="line"><a name="l00253"></a><span class="lineno"> 253</span>  </div>
- <div class="line"><a name="l00254"></a><span class="lineno"> 254</span>  </div>
- <div class="line"><a name="l00255"></a><span class="lineno"><a class="line" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a"> 255</a></span>  uint8_t <a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>;</div>
- <div class="line"><a name="l00256"></a><span class="lineno"> 256</span>  </div>
- <div class="line"><a name="l00257"></a><span class="lineno"> 257</span>  <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="l00258"></a><span class="lineno"> 258</span>  <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="l00259"></a><span class="lineno"> 259</span> <span class="preprocessor">#if defined(ARDUINO_ARCH_STM32F1)</span></div>
- <div class="line"><a name="l00260"></a><span class="lineno"> 260</span>  pinMode(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, (WiringPinMode)mode);</div>
- <div class="line"><a name="l00261"></a><span class="lineno"> 261</span> <span class="preprocessor">#else</span></div>
- <div class="line"><a name="l00262"></a><span class="lineno"> 262</span>  pinMode(<a class="code" href="class_bounce.html#a1cb79cb0ba2379cd12cc7c098d97053a">pin</a>, mode);</div>
- <div class="line"><a name="l00263"></a><span class="lineno"> 263</span> <span class="preprocessor">#endif</span></div>
- <div class="line"><a name="l00264"></a><span class="lineno"> 264</span>  }</div>
- <div class="line"><a name="l00265"></a><span class="lineno"> 265</span>  </div>
- <div class="line"><a name="l00266"></a><span class="lineno"> 266</span>  </div>
- <div class="line"><a name="l00267"></a><span class="lineno"> 267</span>  </div>
- <div class="line"><a name="l00268"></a><span class="lineno"> 268</span> };</div>
- <div class="line"><a name="l00269"></a><span class="lineno"> 269</span>  </div>
- <div class="line"><a name="l00273"></a><span class="lineno"><a class="line" href="namespace_bounce2.html"> 273</a></span> <span class="keyword">namespace </span><a class="code" href="namespace_bounce2.html">Bounce2</a> {</div>
- <div class="line"><a name="l00274"></a><span class="lineno"> 274</span>  <span class="comment">// code declarations</span></div>
- <div class="line"><a name="l00275"></a><span class="lineno"> 275</span>  </div>
- <div class="line"><a name="l00276"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html"> 276</a></span> <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="l00277"></a><span class="lineno"> 277</span> <span class="keyword">protected</span>:</div>
- <div class="line"><a name="l00278"></a><span class="lineno"> 278</span>  <span class="keywordtype">bool</span> stateForPressed = 1; <span class="comment">// </span></div>
- <div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keyword">public</span>:</div>
- <div class="line"><a name="l00290"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a18710b645862d2b8f058a73aabbaf7ad"> 290</a></span>  <a class="code" href="class_bounce2_1_1_button.html#a18710b645862d2b8f058a73aabbaf7ad">Button</a>(){ }</div>
- <div class="line"><a name="l00291"></a><span class="lineno"> 291</span>  </div>
- <div class="line"><a name="l00299"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a3c88b7938b26bca9dc2c7e72aedc442e"> 299</a></span>  <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="l00300"></a><span class="lineno"> 300</span>  stateForPressed = state;</div>
- <div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  }</div>
- <div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  </div>
- <div class="line"><a name="l00306"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a1f90c647e0c75d243cdafed16c6eb28c"> 306</a></span>  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a1f90c647e0c75d243cdafed16c6eb28c">getPressedState</a>()<span class="keyword"> const </span>{</div>
- <div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="keywordflow">return</span> stateForPressed;</div>
- <div class="line"><a name="l00308"></a><span class="lineno"> 308</span>  };</div>
- <div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  </div>
- <div class="line"><a name="l00313"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a73c7c9ef574afe8bf1a9f3eb492bfa7f"> 313</a></span>  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a73c7c9ef574afe8bf1a9f3eb492bfa7f">isPressed</a>()<span class="keyword"> const </span>{</div>
- <div class="line"><a name="l00314"></a><span class="lineno"> 314</span>  <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#aa5fcde9156f700c362fd49af5dd92ecd">read</a>() == <a class="code" href="class_bounce2_1_1_button.html#a1f90c647e0c75d243cdafed16c6eb28c">getPressedState</a>();</div>
- <div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  };</div>
- <div class="line"><a name="l00316"></a><span class="lineno"> 316</span>  </div>
- <div class="line"><a name="l00320"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#a61541ae21354cb7f5cc5bc8c05db59dd"> 320</a></span>  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#a61541ae21354cb7f5cc5bc8c05db59dd">pressed</a>()<span class="keyword"> const </span>{</div>
- <div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">changed</a>() && <a class="code" href="class_bounce2_1_1_button.html#a73c7c9ef574afe8bf1a9f3eb492bfa7f">isPressed</a>();</div>
- <div class="line"><a name="l00322"></a><span class="lineno"> 322</span>  };</div>
- <div class="line"><a name="l00323"></a><span class="lineno"> 323</span>  </div>
- <div class="line"><a name="l00327"></a><span class="lineno"><a class="line" href="class_bounce2_1_1_button.html#ae9bc1365cf132e57feda6dff112edbad"> 327</a></span>  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_bounce2_1_1_button.html#ae9bc1365cf132e57feda6dff112edbad">released</a>()<span class="keyword"> const </span>{</div>
- <div class="line"><a name="l00328"></a><span class="lineno"> 328</span>  <span class="keywordflow">return</span> <a class="code" href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">changed</a>() && !<a class="code" href="class_bounce2_1_1_button.html#a73c7c9ef574afe8bf1a9f3eb492bfa7f">isPressed</a>();</div>
- <div class="line"><a name="l00329"></a><span class="lineno"> 329</span>  };</div>
- <div class="line"><a name="l00330"></a><span class="lineno"> 330</span>  </div>
- <div class="line"><a name="l00331"></a><span class="lineno"> 331</span> };</div>
- <div class="line"><a name="l00332"></a><span class="lineno"> 332</span> };</div>
- <div class="line"><a name="l00333"></a><span class="lineno"> 333</span>  </div>
- <div class="line"><a name="l00334"></a><span class="lineno"> 334</span> <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:276</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_ac6af22dc9c6ae84462fe356b7430659e"><div class="ttname"><a href="class_debouncer.html#ac6af22dc9c6ae84462fe356b7430659e">Debouncer::previousDuration</a></div><div class="ttdeci">unsigned long previousDuration() const</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_bounce2_1_1_button_html_a1f90c647e0c75d243cdafed16c6eb28c"><div class="ttname"><a href="class_bounce2_1_1_button.html#a1f90c647e0c75d243cdafed16c6eb28c">Bounce2::Button::getPressedState</a></div><div class="ttdeci">bool getPressedState() const</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:306</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_a462994f1f9a20876b2ee239eeee97448"><div class="ttname"><a href="class_debouncer.html#a462994f1f9a20876b2ee239eeee97448">Debouncer::duration</a></div><div class="ttdeci">unsigned long duration()</div><div class="ttdoc">DEPRECATED (i.e. do not use). Renamed currentDuration().</div><div class="ttdef"><b>Definition:</b> Bounce2.h:164</div></div>
- <div class="ttc" id="aclass_bounce_html_a3ef5b85db62a7a7807f0050c86cc735f"><div class="ttname"><a href="class_bounce.html#a3ef5b85db62a7a7807f0050c86cc735f">Bounce::fallingEdge</a></div><div class="ttdeci">bool fallingEdge() const</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:246</div></div>
- <div class="ttc" id="aclass_debouncer_html_ab61244e043754ebdc7a156da1e1824bf"><div class="ttname"><a href="class_debouncer.html#ab61244e043754ebdc7a156da1e1824bf">Debouncer::rose</a></div><div class="ttdeci">bool rose() const</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:255</div></div>
- <div class="ttc" id="aclass_bounce2_1_1_button_html_a61541ae21354cb7f5cc5bc8c05db59dd"><div class="ttname"><a href="class_bounce2_1_1_button.html#a61541ae21354cb7f5cc5bc8c05db59dd">Bounce2::Button::pressed</a></div><div class="ttdeci">bool pressed() const</div><div class="ttdoc">Returns true if the button was physically pressed</div><div class="ttdef"><b>Definition:</b> Bounce2.h:320</div></div>
- <div class="ttc" id="aclass_debouncer_html_a883645ca26b4df6e5823586432104d11"><div class="ttname"><a href="class_debouncer.html#a883645ca26b4df6e5823586432104d11">Debouncer::currentDuration</a></div><div class="ttdeci">unsigned long currentDuration() const</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_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:290</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. This class is odly named,...</div><div class="ttdef"><b>Definition:</b> Bounce2.h:184</div></div>
- <div class="ttc" id="aclass_bounce_html_a114878745aa1f29d3c0c293538280646"><div class="ttname"><a href="class_bounce.html#a114878745aa1f29d3c0c293538280646">Bounce::getPin</a></div><div class="ttdeci">int getPin() const</div><div class="ttdoc">Return pin that this Bounce is attached to.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:229</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:299</div></div>
- <div class="ttc" id="aclass_debouncer_html_a80315de311b855f9787b4b6d5b7899e0"><div class="ttname"><a href="class_debouncer.html#a80315de311b855f9787b4b6d5b7899e0">Debouncer::fell</a></div><div class="ttdeci">bool fell() const</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_bounce2_1_1_button_html_ae9bc1365cf132e57feda6dff112edbad"><div class="ttname"><a href="class_bounce2_1_1_button.html#ae9bc1365cf132e57feda6dff112edbad">Bounce2::Button::released</a></div><div class="ttdeci">bool released() const</div><div class="ttdoc">Returns true if the button was physically released</div><div class="ttdef"><b>Definition:</b> Bounce2.h:327</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="aclass_bounce2_1_1_button_html_a73c7c9ef574afe8bf1a9f3eb492bfa7f"><div class="ttname"><a href="class_bounce2_1_1_button.html#a73c7c9ef574afe8bf1a9f3eb492bfa7f">Bounce2::Button::isPressed</a></div><div class="ttdeci">bool isPressed() const</div><div class="ttdoc">Returns true if the button is currently physically pressed.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:313</div></div>
- <div class="ttc" id="aclass_debouncer_html_aa5fcde9156f700c362fd49af5dd92ecd"><div class="ttname"><a href="class_debouncer.html#aa5fcde9156f700c362fd49af5dd92ecd">Debouncer::read</a></div><div class="ttdeci">bool read() const</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_adff02eed264355c2bf90d131768f84c2"><div class="ttname"><a href="class_bounce.html#adff02eed264355c2bf90d131768f84c2">Bounce::risingEdge</a></div><div class="ttdeci">bool risingEdge() const</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:241</div></div>
- <div class="ttc" id="aclass_debouncer_html_a1bbd627f9d8809b5ee9e64e9fb21e248"><div class="ttname"><a href="class_debouncer.html#a1bbd627f9d8809b5ee9e64e9fb21e248">Debouncer::changed</a></div><div class="ttdeci">bool changed() const</div><div class="ttdoc">Returns true if the state changed on last update.</div><div class="ttdef"><b>Definition:</b> Bounce2.h:130</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:273</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  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.17
- </small></address>
- </body>
- </html>
|