Updated documentation

This commit is contained in:
Thomas O Fredericks
2020-08-08 10:21:57 -04:00
parent 172e3e0835
commit 3ddefb4ba4
15 changed files with 310 additions and 140 deletions
+1 -1
View File
@@ -906,7 +906,7 @@ EXCLUDE_SYMBOLS =
# that contain example code fragments that are included (see the \include
# command).
EXAMPLE_PATH = examples/bounce/bounce.ino examples/change/change.ino examples/bounce_multiple/bounce_multiple.ino examples/bounce2buttons/bounce2buttons.ino
EXAMPLE_PATH = examples/bounce_basic/bounce_basic.ino examples/change/button_basic.ino
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
File diff suppressed because one or more lines are too long
+75
View File
@@ -0,0 +1,75 @@
<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Bounce2: bounce_basic.ino</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.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">bounce_basic.ino</div> </div>
</div><!--header-->
<div class="contents">
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>Make Bounce2 more abstract. Split it from the hardware layer. Remove deboucing code from Bounce2 and make a new Debounce class from that code. Bounce2 should extend Debounce. </dd></dl>
<p>Basic example of the <a class="el" href="class_bounce.html" title="The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. ">Bounce</a> class.</p>
<div class="fragment"><div class="line"></div><div class="line">/*</div><div class="line"> DESCRIPTION</div><div class="line"> ====================</div><div class="line"> Simple example of the Bounce library that switches a LED when</div><div class="line"> a state change (from HIGH to LOW) is triggered (for example when a button is pressed).</div><div class="line"></div><div class="line"> Set BOUNCE_PIN to the pin attached to the input (a button for example).</div><div class="line"> Set LED_PIN to the pin attached to a LED.</div><div class="line"></div><div class="line">*/</div><div class="line"></div><div class="line">// WE WILL attach() THE Bounce INSTANCE TO THE FOLLOWING PIN IN setup()</div><div class="line">#define BOUNCE_PIN 2</div><div class="line"></div><div class="line">// DEFINE THE PIN FOR THE LED :</div><div class="line">// 1) SOME BOARDS HAVE A DEFAULT LED (LED_BUILTIN)</div><div class="line">#define LED_PIN LED_BUILTIN</div><div class="line">// 2) OTHERWISE SET YOUR OWN PIN</div><div class="line">// #define LED_PIN 13</div><div class="line"></div><div class="line">// Include the Bounce2 library found here :</div><div class="line">// https://github.com/thomasfredericks/Bounce2</div><div class="line">#include &lt;Bounce2.h&gt;</div><div class="line"></div><div class="line"></div><div class="line">// INSTANTIATE A Bounce OBJECT</div><div class="line">Bounce bounce = Bounce();</div><div class="line"></div><div class="line">// SET A VARIABLE TO STORE THE LED STATE</div><div class="line">bool ledState = LOW;</div><div class="line"></div><div class="line">void setup() {</div><div class="line"></div><div class="line"> // BOUNCE SETUP</div><div class="line"></div><div class="line"> // SELECT ONE OF THE FOLLOWING :</div><div class="line"> // 1) IF YOUR INPUT HAS AN INTERNAL PULL-UP</div><div class="line"> // bounce.attach( BOUNCE_PIN , INPUT_PULLUP ); // USE INTERNAL PULL-UP</div><div class="line"> // 2) IF YOUR INPUT USES AN EXTERNAL PULL-UP</div><div class="line"> bounce.attach( BOUNCE_PIN, INPUT ); // USE EXTERNAL PULL-UP</div><div class="line"></div><div class="line"> // DEBOUNCE INTERVAL IN MILLISECONDS</div><div class="line"> bounce.interval(5); // interval in ms</div><div class="line"></div><div class="line"> // LED SETUP</div><div class="line"> pinMode(LED_PIN, OUTPUT);</div><div class="line"> digitalWrite(LED_PIN, ledState);</div><div class="line"></div><div class="line">}</div><div class="line"></div><div class="line">void loop() {</div><div class="line"> // Update the Bounce instance (YOU MUST DO THIS EVERY LOOP)</div><div class="line"> bounce.update();</div><div class="line"></div><div class="line"> // &lt;Bounce&gt;.changed() RETURNS true IF THE STATE CHANGED (FROM HIGH TO LOW OR LOW TO HIGH)</div><div class="line"> if ( bounce.changed() ) {</div><div class="line"> // THE STATE OF THE INPUT CHANGED</div><div class="line"> // GET THE STATE</div><div class="line"> int deboucedInput = bounce.read();</div><div class="line"> // IF THE CHANGED VALUE IS LOW</div><div class="line"> if ( deboucedInput == LOW ) {</div><div class="line"> ledState = !ledState; // SET ledState TO THE OPPOSITE OF ledState</div><div class="line"> digitalWrite(LED_PIN,ledState); // WRITE THE NEW ledState</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- 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.13
</small></address>
</body>
</html>
+74
View File
@@ -0,0 +1,74 @@
<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Bounce2: button_basic.ino</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.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">button_basic.ino</div> </div>
</div><!--header-->
<div class="contents">
<p>Basic example of the <a class="el" href="class_button.html" title="The Debouncer:Bounce:Button class. The Button class matches an electrical state to a physical action...">Button</a> class.</p>
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
<!-- 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.13
</small></address>
</body>
</html>
+2 -6
View File
@@ -63,13 +63,9 @@ $(function() {
</div><!--header-->
<div class="contents">
<div class="textblock">Here is a list of all examples:</div><ul>
<li><a class="el" href="bounce_8ino-example.html">bounce.ino</a></li>
<li><a class="el" href="bounce_basic_8ino-example.html">bounce_basic.ino</a></li>
<li><a class="el" href="bounce2buttons_8ino-example.html">bounce2buttons.ino</a></li>
<li><a class="el" href="bounce_multiple_8ino-example.html">bounce_multiple.ino</a></li>
<li><a class="el" href="change_8ino-example.html">change.ino</a></li>
<li><a class="el" href="button_basic_8ino-example.html">button_basic.ino</a></li>
</ul>
</div><!-- contents -->
-48
View File
@@ -1,48 +0,0 @@
/*
DESCRIPTION
====================
Simple example of the Bounce library that switches the debug LED when a button is pressed.
*/
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
#define BUTTON_PIN 2
#define LED_PIN 13
// Instantiate a Bounce object
Bounce debouncer = Bounce();
void setup() {
// Setup the button with an internal pull-up :
pinMode(BUTTON_PIN,INPUT_PULLUP);
// After setting up the button, setup the Bounce instance :
debouncer.attach(BUTTON_PIN);
debouncer.interval(5); // interval in ms
//Setup the LED :
pinMode(LED_PIN,OUTPUT);
}
void loop() {
// Update the Bounce instance :
debouncer.update();
// Get the updated value :
int value = debouncer.read();
// Turn on or off the LED as determined by the state :
if ( value == LOW ) {
digitalWrite(LED_PIN, HIGH );
}
else {
digitalWrite(LED_PIN, LOW );
}
}
+70
View File
@@ -0,0 +1,70 @@
/*
DESCRIPTION
====================
Simple example of the Bounce library that switches a LED when
a state change (from HIGH to LOW) is triggered (for example when a button is pressed).
Set BOUNCE_PIN to the pin attached to the input (a button for example).
Set LED_PIN to the pin attached to a LED.
*/
// WE WILL attach() THE Bounce INSTANCE TO THE FOLLOWING PIN IN setup()
#define BOUNCE_PIN 2
// DEFINE THE PIN FOR THE LED :
// 1) SOME BOARDS HAVE A DEFAULT LED (LED_BUILTIN)
#define LED_PIN LED_BUILTIN
// 2) OTHERWISE SET YOUR OWN PIN
// #define LED_PIN 13
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
// INSTANTIATE A Bounce OBJECT
Bounce bounce = Bounce();
// SET A VARIABLE TO STORE THE LED STATE
bool ledState = LOW;
void setup() {
// BOUNCE SETUP
// SELECT ONE OF THE FOLLOWING :
// 1) IF YOUR INPUT HAS AN INTERNAL PULL-UP
// bounce.attach( BOUNCE_PIN , INPUT_PULLUP ); // USE INTERNAL PULL-UP
// 2) IF YOUR INPUT USES AN EXTERNAL PULL-UP
bounce.attach( BOUNCE_PIN, INPUT ); // USE EXTERNAL PULL-UP
// DEBOUNCE INTERVAL IN MILLISECONDS
bounce.interval(5); // interval in ms
// LED SETUP
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, ledState);
}
void loop() {
// Update the Bounce instance (YOU MUST DO THIS EVERY LOOP)
bounce.update();
// <Bounce>.changed() RETURNS true IF THE STATE CHANGED (FROM HIGH TO LOW OR LOW TO HIGH)
if ( bounce.changed() ) {
// THE STATE OF THE INPUT CHANGED
// GET THE STATE
int deboucedInput = bounce.read();
// IF THE CHANGED VALUE IS LOW
if ( deboucedInput == LOW ) {
ledState = !ledState; // SET ledState TO THE OPPOSITE OF ledState
digitalWrite(LED_PIN,ledState); // WRITE THE NEW ledState
}
}
}
+72
View File
@@ -0,0 +1,72 @@
/*
DESCRIPTION
====================
Pressing a physical button switches a LED on or off.
Simple example of the Button class from the Bounce library.
The Button class matches an electrical state to a physical action
with <Button>.setPressedState(LOW or HIGH).
Set BUTTON_PIN to the pin attached to the button.
Set LED_PIN to the pin attached to a LED.
*/
// WE WILL attach() THE BUTTON TO THE FOLLOWING PIN IN setup()
#define BUTTON_PIN 2
// DEFINE THE PIN FOR THE LED :
// 1) SOME BOARDS HAVE A DEFAULT LED (LED_BUILTIN)
//#define LED_PIN LED_BUILTIN
// 2) OTHERWISE SET YOUR OWN PIN
#define LED_PIN 13
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
// INSTANTIATE A Button OBJECT
Button button = Button();
// SET A VARIABLE TO STORE THE LED STATE
bool ledState = LOW;
void setup() {
// BUTTON SETUP
// SELECT ONE OF THE FOLLOWING :
// 1) IF YOUR BUTTON HAS AN INTERNAL PULL-UP
// button.attach( BUTTON_PIN , INPUT_PULLUP ); // USE INTERNAL PULL-UP
// 2) IF YOUR BUTTON USES AN EXTERNAL PULL-UP
button.attach( BUTTON_PIN, INPUT ); // USE EXTERNAL PULL-UP
// DEBOUNCE INTERVAL IN MILLISECONDS
button.interval(5);
// INDICATE THAT THE LOW STATE CORRESPONDS TO PHYSICALLY PRESSING THE BUTTON
button.setPressedState(LOW);
// LED SETUP
pinMode(LED_PIN,OUTPUT);
digitalWrite(LED_PIN,ledState);
}
void loop() {
// UPDATE THE BUTTON
// YOU MUST CALL THIS EVERY LOOP
button.update();
// <Button>.pressed() RETURNS true IF THE STATE CHANGED
// AND THE CURRENT STATE MATCHES <Button>.setPressedState(<HIGH or LOW>);
if ( button.pressed() ) {
// TOGGLE THE LED STATE :
ledState = !ledState; // SET ledState TO THE OPPOSITE OF ledState
digitalWrite(LED_PIN,ledState); // WRITE THE NEW ledState
}
}
-59
View File
@@ -1,59 +0,0 @@
/*
DESCRIPTION
====================
Simple example of the Button class from the Bounce library.
The Button class matches an electrical state to a physical action.
that switches the debug LED when
either of 2 buttons are pressed.
*/
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
#define BUTTON_PIN_A 2
#define BUTTON_PIN_B 3
#define LED_PIN LED_BUILTIN
// Instantiate a Button object
Button buttonA = Button();
// Instantiate another Button object
Button buttonB = Button();
void setup() {
// SETUP BUTTON A
buttonA.attach( BUTTON_PIN_A , INPUT_PULLUP );
buttonA.interval(5); // interval in ms
buttonA.setPressedState(LOW); // INDICATE THAT THE LOW STATE CORRESPONDS TO PHYSICALLY PRESSING THE BUTTON
// SETUP BUTTON B
buttonB.attach( BUTTON_PIN_B , INPUT_PULLUP );
buttonB.interval(5); // interval in ms
buttonB.setPressedState(LOW); // INDICATE THAT THE LOW STATE CORRESPONDS TO PHYSICALLY PRESSING THE BUTTON
// SETUP LED
pinMode(LED_PIN,OUTPUT);
}
void loop() {
// UPDATE THE BUTTONS
buttonA.update();
buttonB.update();
// TOGGLE THE LED IF EITHER BUTTON IS PRESSED
if ( buttonA.pressed() || buttonB.pressed() ) {
digitalWrite(LED_PIN, !digitalRead(LED_PIN) );
}
}
+4 -14
View File
@@ -50,25 +50,15 @@
#include <inttypes.h>
/**
@example bounce.ino
Simple example of the Bounce library that switches the debug LED when a button is pressed.
@example bounce_basic.ino
Basic example of the Bounce class.
*/
/**
@example change.ino
This example toggles the debug LED (pin 13) on or off when a button on pin 2 is pressed.
@example button_basic.ino
Basic example of the Button class.
*/
/**
@example bounce_multiple.ino
Detect the falling edge of multiple buttons. Eight buttons with internal pullups. Toggles a LED when any button is pressed. Buttons on pins 2,3,4,5,6,7,8,9
*/
/**
@example bounce2buttons.ino
Example of two instances of the Bounce class that switches the debug LED when either one of the two buttons is pressed.
*/
/**