Skip to content

Commit

Permalink
Code optimization, examples added as of 2024-09-23
Browse files Browse the repository at this point in the history
  • Loading branch information
GabyGold67 committed Sep 23, 2024
1 parent c00cfa3 commit 7aa514a
Show file tree
Hide file tree
Showing 36 changed files with 4,082 additions and 372 deletions.
2,925 changes: 2,925 additions & 0 deletions DevelopmentDocs/ButtonToSwitch_ESP32-Doxyfile.bak

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions DevelopmentDocs/changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# v4.0.4 Minor refactoring
- Some code cleanup.
# v4.0.5 Maintenance release
- DbncdMPBttn::init() conditional execution premises corrected (the condition resulted in a Paradox)
Pending of test on the STM32 implementation- DFA unconditional state changes allowed to cascade advancement in single step to improve speed and responsiveness for the DbncdMPBttn and DbncdDlydMPBttn classes.

# v4.0.4 Maintenance release
- Code cleanup.
- Auto documentation generation problems solved, documentation regenerated.
- Several examples added for most of the classes.

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# **Buttons to Switches Library** (ButtonToSwitch_ESP32)
## **The driving concept is pretty simple: stop checking an input pin voltage, start asking if your switch is On or Off.**

This library is an evolutionary refactoring based on my own, now discontinued, **mpbToSwitch** library.
This library is an evolutionary refactoring of my own -now archived- **mpbToSwitch** library.

## An ESP32-RTOS Arduino library that builds switch mechanisms replacements out of simple push buttons.
By using just a push button (a.k.a. momentary switches or momentary buttons, _**MPB**_ for short from here on) the classes implemented in this library will manage, calculate and update different parameters to **generate the behavior of standard electromechanical switches**. Those parameters include presses, releases, timings, counters or secondary input readings as needed.
Expand Down Expand Up @@ -34,6 +35,7 @@ While with the simulated switches this situation might be solved by just changin
* Want to keep the timed **lights-on** longer? Just a parameter.
* Want to turn off the pilot light because it bothers? Another parameter.
* Want to be sure the door mechanism isn't kept unlocked with an adhesive tape? Change the switch class.
* Want to ensure nobody turns on a dangerous appliance while it's internals are being cleaned? Invoke a method!

_**In an Industrial production machines environment**_ the operator's physical security policies enforcement implies that no time can be wasted and the switch must fit perfectly it's purpose, while still giving the chance to change it's working parameters to adjust the mechanism to changing production operations, or to use the security device in other kind of machine. In this case the development depending on a simple "OK to proceed"/"The security device is correctly activated" might become a dangerous issue if not correctly isolated and solved as a remove and replace solution. The security switches must comply with issues as:
- Activation enforcement
Expand Down Expand Up @@ -149,7 +151,7 @@ This is an **Abstract Class** meaning that no object can be instantiated from it
1. Validated Unlatch signal (or Validated Unlatch signal start).
2. Validated Unlatch Release signal (or Validated Unlatch signal end).

The class provides methods to generate those validated signals independently of the designated signal source to modify the instantiated object behavior if needed by the design requirements, Validated Unlatch signal (see LtchMPBttn::setUnlatchPend(const bool), Validated Unlatch Release signal (see LtchMPBttn::setUnlatchRlsPend(const bool), or to **set** both flags to generate an unlatch (see LtchMPBttn::unlatch().
The class provides methods to generate those validated signals independently of the designated signal source to modify the instantiated object behavior if needed by the design requirements, Validated Unlatch signal (see LtchMPBttn::setUnlatchPend(const bool) ), Validated Unlatch Release signal (see LtchMPBttn::setUnlatchRlsPend(const bool) ), or to **set** both flags to generate an unlatch (see LtchMPBttn::unlatch() ).


## **Added or Modified Methods for LtchMPBttn class**
Expand Down Expand Up @@ -269,9 +271,9 @@ The **External released toggle** (a.k.a. Emergency latched), keeps the On state
- A **short press** makes the MPB to behave as a Toggle LDD-MPB Switch (**ToLDD-MPB**) -designated as the **main behavior**-, swapping from the **Off state** to the **On state** and back as usual LDD-MPB.
- A **long press** activates an alternative behavior, allowing the single MPB to be used as a second MPB. That different behavior -designated as the **secondary behavior**- defines the sub-classes of the **DALDD-MPB** class.
Using a notation where the first component is the Off/On state of the main behavior and the second component the state of the secondary behavior the only possible combinations would be:
- **1.** Off-Off
- **2.** On-Off
- **3.** On-On
- **1.** Off - Off
- **2.** On - Off
- **3.** On - On

The presses patterns are:
- **1.** -> **2.**: short press.
Expand Down
22 changes: 11 additions & 11 deletions docs/_button_to_switch___e_s_p32_8cpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ButtonToSwitch Library for ESP32 (Arduino): C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp File Reference</title>
<title>ButtonToSwitch Library for ESP32 (Arduino): C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp File Reference</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>
Expand Down Expand Up @@ -106,19 +106,19 @@

<p>: Source file for the ButtonToSwitch_ESP32 library classes
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;<a class="el" href="_button_to_switch___e_s_p32_8h_source.html">ButtonToSwitch_ESP32.h</a>&gt;</code><br />
<div class="textblock"><code>#include &quot;<a class="el" href="_button_to_switch___e_s_p32_8h_source.html">ButtonToSwitch_ESP32.h</a>&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for ButtonToSwitch_ESP32.cpp:</div>
<div class="dyncontent">
<div class="center"><img src="_button_to_switch___e_s_p32_8cpp__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp">
<area shape="rect" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,266,96"/>
<area shape="rect" href="_button_to_switch___e_s_p32_8h.html" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="49,144,222,171"/>
<area shape="poly" title=" " alt="" coords="138,96,138,128,133,128,133,96"/>
<area shape="rect" title=" " alt="" coords="51,219,127,245"/>
<area shape="poly" title=" " alt="" coords="130,173,107,207,103,204,125,170"/>
<area shape="rect" title=" " alt="" coords="151,219,216,245"/>
<area shape="poly" title=" " alt="" coords="146,170,169,204,165,207,142,173"/>
<div class="center"><img src="_button_to_switch___e_s_p32_8cpp__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8cpp">
<area shape="rect" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,193,112"/>
<area shape="rect" href="_button_to_switch___e_s_p32_8h.html" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="13,160,185,187"/>
<area shape="poly" title=" " alt="" coords="102,112,102,144,96,144,96,112"/>
<area shape="rect" title=" " alt="" coords="14,235,90,261"/>
<area shape="poly" title=" " alt="" coords="93,189,71,223,66,220,89,186"/>
<area shape="rect" title=" " alt="" coords="115,235,179,261"/>
<area shape="poly" title=" " alt="" coords="110,186,133,220,128,223,105,189"/>
</map>
</div>
</div><table class="memberdecls">
Expand Down
16 changes: 8 additions & 8 deletions docs/_button_to_switch___e_s_p32_8cpp__incl.map
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp">
<area shape="rect" id="Node000001" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,266,96"/>
<area shape="rect" id="Node000002" href="$_button_to_switch___e_s_p32_8h.html" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="49,144,222,171"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="138,96,138,128,133,128,133,96"/>
<area shape="rect" id="Node000003" title=" " alt="" coords="51,219,127,245"/>
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="130,173,107,207,103,204,125,170"/>
<area shape="rect" id="Node000004" title=" " alt="" coords="151,219,216,245"/>
<area shape="poly" id="edge3_Node000002_Node000004" title=" " alt="" coords="146,170,169,204,165,207,142,173"/>
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.cpp">
<area shape="rect" id="Node000001" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,193,112"/>
<area shape="rect" id="Node000002" href="$_button_to_switch___e_s_p32_8h.html" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="13,160,185,187"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="102,112,102,144,96,144,96,112"/>
<area shape="rect" id="Node000003" title=" " alt="" coords="14,235,90,261"/>
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="93,189,71,223,66,220,89,186"/>
<area shape="rect" id="Node000004" title=" " alt="" coords="115,235,179,261"/>
<area shape="poly" id="edge3_Node000002_Node000004" title=" " alt="" coords="110,186,133,220,128,223,105,189"/>
</map>
2 changes: 1 addition & 1 deletion docs/_button_to_switch___e_s_p32_8cpp__incl.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
64db9fba5fb3b44f3f34da92346eebbe
039a6b20808204cde04332bf7b1f753c
Binary file modified docs/_button_to_switch___e_s_p32_8cpp__incl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions docs/_button_to_switch___e_s_p32_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ButtonToSwitch Library for ESP32 (Arduino): C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h File Reference</title>
<title>ButtonToSwitch Library for ESP32 (Arduino): C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h File Reference</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>
Expand Down Expand Up @@ -112,8 +112,8 @@
</div><div class="textblock"><div class="dynheader">
Include dependency graph for ButtonToSwitch_ESP32.h:</div>
<div class="dyncontent">
<div class="center"><img src="_button_to_switch___e_s_p32_8h__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h">
<div class="center"><img src="_button_to_switch___e_s_p32_8h__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8h">
<area shape="rect" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,252,96"/>
<area shape="rect" title=" " alt="" coords="44,144,120,171"/>
<area shape="poly" title=" " alt="" coords="111,97,96,131,91,129,106,95"/>
Expand All @@ -124,11 +124,11 @@
</div><div class="textblock"><div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dyncontent">
<div class="center"><img src="_button_to_switch___e_s_p32_8h__dep__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_momentary_push_button_tester_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep">
<area shape="rect" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="12,5,259,96"/>
<area shape="rect" href="_button_to_switch___e_s_p32_8cpp.html" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,144,266,235"/>
<area shape="poly" title=" " alt="" coords="138,112,138,143,133,143,133,112"/>
<div class="center"><img src="_button_to_switch___e_s_p32_8h__dep__incl.png" border="0" usemap="#a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep" alt=""/></div>
<map name="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep" id="a_c_1_2_users_2_dev_padawan_2_documents_2_my_01_projects_2_training_01_projects_2_libs_dev___e_s_p32_2lib_2_button_to_switch___e_s_p32_2src_2_button_to_switch___e_s_p32_8hdep">
<area shape="rect" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,252,96"/>
<area shape="rect" href="_button_to_switch___e_s_p32_8cpp.html" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="35,144,222,251"/>
<area shape="poly" title=" " alt="" coords="131,112,131,143,126,143,126,112"/>
</map>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/_button_to_switch___e_s_p32_8h__dep__incl.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h">
<area shape="rect" id="Node000001" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="12,5,259,96"/>
<area shape="rect" id="Node000002" href="$_button_to_switch___e_s_p32_8cpp.html" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,144,266,235"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="138,112,138,143,133,143,133,112"/>
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h">
<area shape="rect" id="Node000001" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,252,96"/>
<area shape="rect" id="Node000002" href="$_button_to_switch___e_s_p32_8cpp.html" title=": Source file for the ButtonToSwitch_ESP32 library classes" alt="" coords="35,144,222,251"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="131,112,131,143,126,143,126,112"/>
</map>
2 changes: 1 addition & 1 deletion docs/_button_to_switch___e_s_p32_8h__dep__incl.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e1e33e1181af5d1d32b583b17bcb1538
d99bb88da1bc720f64bdae96b1630c2f
Binary file modified docs/_button_to_switch___e_s_p32_8h__dep__incl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/_button_to_switch___e_s_p32_8h__incl.map
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/MomentaryPushButtonTester/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h">
<map id="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h" name="C:/Users/DevPadawan/Documents/My Projects/Training Projects/LibsDev_ESP32/lib/ButtonToSwitch_ESP32/src/ButtonToSwitch_ESP32.h">
<area shape="rect" id="Node000001" title=": Header file for the ButtonToSwitch_ESP32 library classes" alt="" coords="5,5,252,96"/>
<area shape="rect" id="Node000002" title=" " alt="" coords="44,144,120,171"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="111,97,96,131,91,129,106,95"/>
Expand Down
2 changes: 1 addition & 1 deletion docs/_button_to_switch___e_s_p32_8h__incl.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c96234a87e2e40217c29a1dae33cbea9
a9b615fb5b7a39a08defc2915bc5ed60
Binary file modified docs/_button_to_switch___e_s_p32_8h__incl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7aa514a

Please sign in to comment.