diff --git a/DevelopmentDocs/changes.txt b/DevelopmentDocs/changes.txt index 27c52de..d58e1ec 100644 --- a/DevelopmentDocs/changes.txt +++ b/DevelopmentDocs/changes.txt @@ -1,3 +1,8 @@ +# v4.0.4 Minor refactoring +- Some code cleanup. +- Auto documentation generation problems solved, documentation regenerated. +- Several examples added for most of the classes. + # v4.0.3 Minor debugging - The clearStatus() method for the HntdTmLtchMPBttn class ignored the resetting of some flags that left open the possibility of uncomplete state clearing. Corrected. - Several examples added for most of the classes. diff --git a/docs/_button_to_switch___e_s_p32_8cpp.html b/docs/_button_to_switch___e_s_p32_8cpp.html index 65e4583..f23703e 100644 --- a/docs/_button_to_switch___e_s_p32_8cpp.html +++ b/docs/_button_to_switch___e_s_p32_8cpp.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
@@ -132,7 +132,7 @@

: Source file for the ButtonToSwitch_ESP32 library classes

The library implements classes that model several switch mechanisms replacements out of simple push buttons or similar equivalent digital signal inputs. By using just a button (a.k.a. momentary switches or momentary push buttons, MPB for short from here on) the classes implemented in this library will manage, calculate and update several parameters to generate the embedded behavior of standard electromechanical switches.

Author
: Gabriel D. Goldman
-
Version
v4.0.2
+
Version
v4.0.4
Date
: Created on: 06/11/2023 : Last modification: 15/09/2024
Attention
This library was developed as part of the refactoring process for an industrial machines security enforcement and productivity control (hardware & firmware update). As such every class included complies AT LEAST with the provision of the attributes and methods to make the hardware & firmware replacement transparent to the controlled machines. Generic use attribute and methods were added to extend the usability to other projects and application environments, but no fitness nor completeness of those are given but for the intended refactoring project.
diff --git a/docs/_button_to_switch___e_s_p32_8h.html b/docs/_button_to_switch___e_s_p32_8h.html index 2c7b34c..0af546a 100644 --- a/docs/_button_to_switch___e_s_p32_8h.html +++ b/docs/_button_to_switch___e_s_p32_8h.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
@@ -189,7 +189,7 @@

: Header file for the ButtonToSwitch_ESP32 library classes

The library implements classes that model several switch mechanisms replacements out of simple push buttons or similar equivalent digital signal inputs. By using just a button (a.k.a. momentary switches or momentary push buttons, MPB for short from here on) the classes implemented in this library will manage, calculate and update several parameters to generate the embedded behavior of standard electromechanical switches.

Author
: Gabriel D. Goldman
-
Version
v4.0.1
+
Version
v4.0.4
Date
: Created on: 06/11/2023 : Last modification: 28/08/2024
Attention
This library was developed as part of the refactoring process for an industrial machines security enforcement and productivity control (hardware & firmware update). As such every class included complies AT LEAST with the provision of the attributes and methods to make the hardware & firmware replacement transparent to the controlled machines. Generic use attribute and methods were added to extend the usability to other projects and application environments, but no fitness nor completeness of those are given but for the intended refactoring project.
diff --git a/docs/_button_to_switch___e_s_p32_8h_source.html b/docs/_button_to_switch___e_s_p32_8h_source.html index de028b8..2f133af 100644 --- a/docs/_button_to_switch___e_s_p32_8h_source.html +++ b/docs/_button_to_switch___e_s_p32_8h_source.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
@@ -633,148 +633,148 @@
1688//==========================================================>>
1689
1690#endif /*_BUTTONTOSWITCH_ESP32_H_*/
-
MpbOtpts_t otptsSttsUnpkg(uint32_t pkgOtpts)
Unpackages a 32-bit value into a DbncdMPBttn object status.
Definition ButtonToSwitch_ESP32.cpp:3158
+
MpbOtpts_t otptsSttsUnpkg(uint32_t pkgOtpts)
Unpackages a 32-bit value into a DbncdMPBttn object status.
Definition ButtonToSwitch_ESP32.cpp:3145
Models a Debounced Delayed Double Action Latched MPB combo switch (Debounced Delayed DALDD-MPB - DD-D...
Definition ButtonToSwitch_ESP32.h:1142
-
void clrStatus(bool clrIsOn=true)
See DbncddMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:2199
-
~DDlydDALtchMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2195
-
DDlydDALtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2190
+
void clrStatus(bool clrIsOn=true)
See DbncddMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:2186
+
~DDlydDALtchMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2182
+
DDlydDALtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2177
Abstract class, base to model Double Action LDD-MPBs (DALDD-MPBs).
Definition ButtonToSwitch_ESP32.h:979
-
bool setScndModActvDly(const unsigned long &newVal)
Sets a new value for the scndModActvDly class attribute.
Definition ButtonToSwitch_ESP32.cpp:1883
-
void setFnWhnTrnOnScndryPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object enters the Secondary On State.
Definition ButtonToSwitch_ESP32.cpp:1871
-
const TaskHandle_t getTaskWhileOnScndry()
Returns the task to be run while the object is in the Secondary On state.
Definition ButtonToSwitch_ESP32.cpp:1825
-
fncPtrType getFnWhnTrnOnScndry()
Returns the function that is set to execute every time the object enters the Secondary On State.
Definition ButtonToSwitch_ESP32.cpp:1810
-
void clrStatus(bool clrIsOn=true)
See DbncddMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1791
-
bool getIsOnScndry()
Returns the current value of the isOnScndry attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1815
-
void setTaskWhileOnScndry(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:1901
-
unsigned long getScndModActvDly()
Returns the current value of the scndModActvDly class attribute.
Definition ButtonToSwitch_ESP32.cpp:1820
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1767
-
void setFnWhnTrnOffScndryPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object enters the Secondary Off State...
Definition ButtonToSwitch_ESP32.cpp:1860
-
fncPtrType getFnWhnTrnOffScndry()
returns the function that is set to execute every time the object enters the Secondary Off State.
Definition ButtonToSwitch_ESP32.cpp:1805
-
~DblActnLtchMPBttn()
Virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:1763
-
DblActnLtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Abstract Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1758
+
bool setScndModActvDly(const unsigned long &newVal)
Sets a new value for the scndModActvDly class attribute.
Definition ButtonToSwitch_ESP32.cpp:1870
+
void setFnWhnTrnOnScndryPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object enters the Secondary On State.
Definition ButtonToSwitch_ESP32.cpp:1858
+
const TaskHandle_t getTaskWhileOnScndry()
Returns the task to be run while the object is in the Secondary On state.
Definition ButtonToSwitch_ESP32.cpp:1812
+
fncPtrType getFnWhnTrnOnScndry()
Returns the function that is set to execute every time the object enters the Secondary On State.
Definition ButtonToSwitch_ESP32.cpp:1797
+
void clrStatus(bool clrIsOn=true)
See DbncddMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1778
+
bool getIsOnScndry()
Returns the current value of the isOnScndry attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1802
+
void setTaskWhileOnScndry(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:1888
+
unsigned long getScndModActvDly()
Returns the current value of the scndModActvDly class attribute.
Definition ButtonToSwitch_ESP32.cpp:1807
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1754
+
void setFnWhnTrnOffScndryPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object enters the Secondary Off State...
Definition ButtonToSwitch_ESP32.cpp:1847
+
fncPtrType getFnWhnTrnOffScndry()
returns the function that is set to execute every time the object enters the Secondary Off State.
Definition ButtonToSwitch_ESP32.cpp:1792
+
~DblActnLtchMPBttn()
Virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:1750
+
DblActnLtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Abstract Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1745
Models a Debounced Delayed MPB (DD-MPB).
Definition ButtonToSwitch_ESP32.h:455
-
DbncdDlydMPBttn()
Default constructor.
Definition ButtonToSwitch_ESP32.cpp:742
-
void setStrtDelay(const unsigned long int &newStrtDelay)
Sets a new value to the "Start Delay" strtDelay attribute.
Definition ButtonToSwitch_ESP32.cpp:763
-
bool init(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
see DbncdMPBttn::init(const uint8_t, const bool, const bool, const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:753
+
DbncdDlydMPBttn()
Default constructor.
Definition ButtonToSwitch_ESP32.cpp:732
+
void setStrtDelay(const unsigned long int &newStrtDelay)
Sets a new value to the "Start Delay" strtDelay attribute.
Definition ButtonToSwitch_ESP32.cpp:753
+
bool init(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
see DbncdMPBttn::init(const uint8_t, const bool, const bool, const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:743
Base class, models a Debounced Momentary Push Button (D-MPB).
Definition ButtonToSwitch_ESP32.h:95
-
fncPtrType getFnWhnTrnOn()
Returns the function that is set to execute every time the object enters the On State.
Definition ButtonToSwitch_ESP32.cpp:162
-
void resetFda()
Resets the MPB behavior automaton to it's Initial or Start State
Definition ButtonToSwitch_ESP32.cpp:317
+
fncPtrType getFnWhnTrnOn()
Returns the function that is set to execute every time the object enters the On State.
Definition ButtonToSwitch_ESP32.cpp:158
+
void resetFda()
Resets the MPB behavior automaton to it's Initial or Start State
Definition ButtonToSwitch_ESP32.cpp:313
void clrStatus(bool clrIsOn=true)
Clears and resets flags, timers and counters modified through the object's signals processing.
Definition ButtonToSwitch_ESP32.cpp:94
-
const unsigned long int getCurDbncTime() const
Returns the current debounce period time set for the object.
Definition ButtonToSwitch_ESP32.cpp:152
-
const TaskHandle_t getTaskWhileOn()
Returns the task to be run (resumed) while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:207
-
void enable()
Enables the input signal processing.
Definition ButtonToSwitch_ESP32.cpp:127
-
bool pause()
Pauses the software timer updating the computation of the object's internal flags value.
Definition ButtonToSwitch_ESP32.cpp:293
-
const TaskHandle_t getTaskToNotify() const
Returns the task to be notified by the object when its output flags changes.
Definition ButtonToSwitch_ESP32.cpp:202
+
const unsigned long int getCurDbncTime() const
Returns the current debounce period time set for the object.
Definition ButtonToSwitch_ESP32.cpp:148
+
const TaskHandle_t getTaskWhileOn()
Returns the task to be run (resumed) while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:203
+
void enable()
Enables the input signal processing.
Definition ButtonToSwitch_ESP32.cpp:125
+
bool pause()
Pauses the software timer updating the computation of the object's internal flags value.
Definition ButtonToSwitch_ESP32.cpp:289
+
const TaskHandle_t getTaskToNotify() const
Returns the task to be notified by the object when its output flags changes.
Definition ButtonToSwitch_ESP32.cpp:198
virtual ~DbncdMPBttn()
Default virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:65
-
virtual void setTaskWhileOn(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:471
-
void setIsOnDisabled(const bool &newIsOnDisabled)
Sets the value of the isOnDisabled attribute flag.
Definition ButtonToSwitch_ESP32.cpp:408
-
bool init(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0)
Initializes an object instantiated by the default constructor.
Definition ButtonToSwitch_ESP32.cpp:212
-
bool end()
Detaches the object from the timer that monitors the input pins, compute and updates the object's sta...
Definition ButtonToSwitch_ESP32.cpp:132
+
virtual void setTaskWhileOn(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:461
+
void setIsOnDisabled(const bool &newIsOnDisabled)
Sets the value of the isOnDisabled attribute flag.
Definition ButtonToSwitch_ESP32.cpp:400
+
bool init(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0)
Initializes an object instantiated by the default constructor.
Definition ButtonToSwitch_ESP32.cpp:208
+
bool end()
Detaches the object from the timer that monitors the input pins, compute and updates the object's sta...
Definition ButtonToSwitch_ESP32.cpp:130
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
Attaches the instantiated object to a timer that monitors the input pins and updates the object statu...
Definition ButtonToSwitch_ESP32.cpp:70
-
void resetDbncTime()
Resets the debounce process time of the object to the value used at instantiation.
Definition ButtonToSwitch_ESP32.cpp:311
+
void resetDbncTime()
Resets the debounce process time of the object to the value used at instantiation.
Definition ButtonToSwitch_ESP32.cpp:307
DbncdMPBttn()
Default class constructor.
Definition ButtonToSwitch_ESP32.cpp:39
-
void disable()
Disables the input signal processing, ignoring the changes of its values.
Definition ButtonToSwitch_ESP32.cpp:122
-
bool resume()
Restarts the software timer updating the calculation of the object internal flags.
Definition ButtonToSwitch_ESP32.cpp:329
-
const bool getIsEnabled() const
Returns the value of the isEnabled attribute flag, indicating the Enabled or Disabled status of the o...
Definition ButtonToSwitch_ESP32.cpp:167
-
const bool getIsOnDisabled() const
Returns the value of the isOnDisabled attribute flag.
Definition ButtonToSwitch_ESP32.cpp:177
-
void setTaskToNotify(const TaskHandle_t &newTaskHandle)
Sets the handle to the task to be notified by the object when its output attribute flags changes.
Definition ButtonToSwitch_ESP32.cpp:447
-
void setFnWhnTrnOffPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object enters the Off State.
Definition ButtonToSwitch_ESP32.cpp:363
-
const bool getOutputsChange() const
Returns the value of the outputsChange attribute flag.
Definition ButtonToSwitch_ESP32.cpp:192
-
const bool getIsOn() const
Returns the value of the isOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:172
-
void setFnWhnTrnOnPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object enters the On State.
Definition ButtonToSwitch_ESP32.cpp:375
-
unsigned long int getStrtDelay()
Returns the current value of strtDelay attribute.
Definition ButtonToSwitch_ESP32.cpp:197
-
const uint32_t getOtptsSttsPkgd()
Returns the relevant attribute flags values for the object state encoded as a 32 bits value,...
Definition ButtonToSwitch_ESP32.cpp:187
-
fncPtrType getFnWhnTrnOff()
Returns the function that is set to execute every time the object enters the Off State.
Definition ButtonToSwitch_ESP32.cpp:157
-
void setOutputsChange(bool newOutputsChange)
Sets the value of the attribute flag indicating if a change took place in any of the output attribute...
Definition ButtonToSwitch_ESP32.cpp:430
-
bool setDbncTime(const unsigned long int &newDbncTime)
Sets the debounce process time.
Definition ButtonToSwitch_ESP32.cpp:345
+
void disable()
Disables the input signal processing, ignoring the changes of its values.
Definition ButtonToSwitch_ESP32.cpp:120
+
bool resume()
Restarts the software timer updating the calculation of the object internal flags.
Definition ButtonToSwitch_ESP32.cpp:325
+
const bool getIsEnabled() const
Returns the value of the isEnabled attribute flag, indicating the Enabled or Disabled status of the o...
Definition ButtonToSwitch_ESP32.cpp:163
+
const bool getIsOnDisabled() const
Returns the value of the isOnDisabled attribute flag.
Definition ButtonToSwitch_ESP32.cpp:173
+
void setTaskToNotify(const TaskHandle_t &newTaskHandle)
Sets the handle to the task to be notified by the object when its output attribute flags changes.
Definition ButtonToSwitch_ESP32.cpp:437
+
void setFnWhnTrnOffPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object enters the Off State.
Definition ButtonToSwitch_ESP32.cpp:357
+
const bool getOutputsChange() const
Returns the value of the outputsChange attribute flag.
Definition ButtonToSwitch_ESP32.cpp:188
+
const bool getIsOn() const
Returns the value of the isOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:168
+
void setFnWhnTrnOnPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object enters the On State.
Definition ButtonToSwitch_ESP32.cpp:368
+
unsigned long int getStrtDelay()
Returns the current value of strtDelay attribute.
Definition ButtonToSwitch_ESP32.cpp:193
+
const uint32_t getOtptsSttsPkgd()
Returns the relevant attribute flags values for the object state encoded as a 32 bits value,...
Definition ButtonToSwitch_ESP32.cpp:183
+
fncPtrType getFnWhnTrnOff()
Returns the function that is set to execute every time the object enters the Off State.
Definition ButtonToSwitch_ESP32.cpp:153
+
void setOutputsChange(bool newOutputsChange)
Sets the value of the attribute flag indicating if a change took place in any of the output attribute...
Definition ButtonToSwitch_ESP32.cpp:420
+
bool setDbncTime(const unsigned long int &newDbncTime)
Sets the debounce process time.
Definition ButtonToSwitch_ESP32.cpp:341
Models a Hinted Timer Latch DD-MPB, a.k.a. Staircase Switch (HTiLDD-MPB).
Definition ButtonToSwitch_ESP32.h:729
-
bool setSrvcTime(const unsigned long int &newSvcTime)
See TmLtchMPBttn::setSrvcTime(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1430
-
fncPtrType getFnWhnTrnOnPilot()
Returns the function that is set to execute every time the object's Pilot attribute flag enters the O...
Definition ButtonToSwitch_ESP32.cpp:1300
-
void setFnWhnTrnOffWrnngPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's Warning is reset.
Definition ButtonToSwitch_ESP32.cpp:1383
-
fncPtrType getFnWhnTrnOffWrnng()
Returns the function that is set to execute every time the object's Warning attribute flag enters the...
Definition ButtonToSwitch_ESP32.cpp:1295
-
const bool getWrnngOn() const
Returns the current value of the warningOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1315
-
void setFnWhnTrnOnPilotPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's Pilot is set.
Definition ButtonToSwitch_ESP32.cpp:1395
-
HntdTmLtchMPBttn(const uint8_t &mpbttnPin, const unsigned long int &svcTime, const unsigned int &wrnngPrctg=0, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1240
-
const bool getPilotOn() const
Returns the current value of the pilotOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1310
-
void clrStatus(bool clrIsOn=true)
see DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1270
-
fncPtrType getFnWhnTrnOffPilot()
Returns the function that is set to execute every time the object's Pilot attribute flag enters the O...
Definition ButtonToSwitch_ESP32.cpp:1290
-
void setFnWhnTrnOnWrnngPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's Wrnng is set.
Definition ButtonToSwitch_ESP32.cpp:1407
-
bool setWrnngPrctg(const unsigned int &newWrnngPrctg)
Sets the value for the percentage of service time for calculating the warningOn flag value.
Definition ButtonToSwitch_ESP32.cpp:1445
-
fncPtrType getFnWhnTrnOnWrnng()
Returns the function that is set to execute every time the object's Warning attribute flag enters the...
Definition ButtonToSwitch_ESP32.cpp:1305
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1246
-
void setFnWhnTrnOffPilotPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's Pilot is reset.
Definition ButtonToSwitch_ESP32.cpp:1371
-
void setKeepPilot(const bool &newKeepPilot)
Sets the configuration of the keepPilot service attribute.
Definition ButtonToSwitch_ESP32.cpp:1419
+
bool setSrvcTime(const unsigned long int &newSvcTime)
See TmLtchMPBttn::setSrvcTime(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1417
+
fncPtrType getFnWhnTrnOnPilot()
Returns the function that is set to execute every time the object's Pilot attribute flag enters the O...
Definition ButtonToSwitch_ESP32.cpp:1287
+
void setFnWhnTrnOffWrnngPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's Warning is reset.
Definition ButtonToSwitch_ESP32.cpp:1370
+
fncPtrType getFnWhnTrnOffWrnng()
Returns the function that is set to execute every time the object's Warning attribute flag enters the...
Definition ButtonToSwitch_ESP32.cpp:1282
+
const bool getWrnngOn() const
Returns the current value of the warningOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1302
+
void setFnWhnTrnOnPilotPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's Pilot is set.
Definition ButtonToSwitch_ESP32.cpp:1382
+
HntdTmLtchMPBttn(const uint8_t &mpbttnPin, const unsigned long int &svcTime, const unsigned int &wrnngPrctg=0, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1227
+
const bool getPilotOn() const
Returns the current value of the pilotOn attribute flag.
Definition ButtonToSwitch_ESP32.cpp:1297
+
void clrStatus(bool clrIsOn=true)
see DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1257
+
fncPtrType getFnWhnTrnOffPilot()
Returns the function that is set to execute every time the object's Pilot attribute flag enters the O...
Definition ButtonToSwitch_ESP32.cpp:1277
+
void setFnWhnTrnOnWrnngPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's Wrnng is set.
Definition ButtonToSwitch_ESP32.cpp:1394
+
bool setWrnngPrctg(const unsigned int &newWrnngPrctg)
Sets the value for the percentage of service time for calculating the warningOn flag value.
Definition ButtonToSwitch_ESP32.cpp:1432
+
fncPtrType getFnWhnTrnOnWrnng()
Returns the function that is set to execute every time the object's Warning attribute flag enters the...
Definition ButtonToSwitch_ESP32.cpp:1292
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1233
+
void setFnWhnTrnOffPilotPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's Pilot is reset.
Definition ButtonToSwitch_ESP32.cpp:1358
+
void setKeepPilot(const bool &newKeepPilot)
Sets the configuration of the keepPilot service attribute.
Definition ButtonToSwitch_ESP32.cpp:1406
Abstract class, base to model Latched Debounced Delayed MPBs (LDD-MPB).
Definition ButtonToSwitch_ESP32.h:511
-
const bool getIsLatched() const
Returns the value of the isLatched attribute flag, indicating the Latched or Unlatched condition of t...
Definition ButtonToSwitch_ESP32.cpp:818
-
bool unlatch()
Sets the values of the flags needed to unlatch a latched MPB.
Definition ButtonToSwitch_ESP32.cpp:903
-
const bool getUnlatchRlsPend() const
Returns the value of the "Valid Unlatch Release Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:833
-
LtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:776
-
const bool getUnlatchPend() const
Returns the value of the "Valid Unlatch Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:828
-
void setUnlatchPend(const bool &newVal)
Sets the value of the "Valid Unlatch Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:881
-
void setTrnOffASAP(const bool &newVal)
Sets the value of the trnOffASAP attribute.
Definition ButtonToSwitch_ESP32.cpp:869
-
bool getTrnOffASAP()
Returns the value of the trnOffASAP attribute flag.
Definition ButtonToSwitch_ESP32.cpp:823
-
void setUnlatchRlsPend(const bool &newVal)
Sets the value of the "Valid Unlatch Release Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:892
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:781
-
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:805
+
const bool getIsLatched() const
Returns the value of the isLatched attribute flag, indicating the Latched or Unlatched condition of t...
Definition ButtonToSwitch_ESP32.cpp:808
+
bool unlatch()
Sets the values of the flags needed to unlatch a latched MPB.
Definition ButtonToSwitch_ESP32.cpp:892
+
const bool getUnlatchRlsPend() const
Returns the value of the "Valid Unlatch Release Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:823
+
LtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:766
+
const bool getUnlatchPend() const
Returns the value of the "Valid Unlatch Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:818
+
void setUnlatchPend(const bool &newVal)
Sets the value of the "Valid Unlatch Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:870
+
void setTrnOffASAP(const bool &newVal)
Sets the value of the trnOffASAP attribute.
Definition ButtonToSwitch_ESP32.cpp:859
+
bool getTrnOffASAP()
Returns the value of the trnOffASAP attribute flag.
Definition ButtonToSwitch_ESP32.cpp:813
+
void setUnlatchRlsPend(const bool &newVal)
Sets the value of the "Valid Unlatch Release Pending" attribute.
Definition ButtonToSwitch_ESP32.cpp:881
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:771
+
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:795
Models a Slider Double Action LDD-MPB combo switch, a.k.a. off/on/dimmer, a.k.a. off/on/volume radio ...
Definition ButtonToSwitch_ESP32.h:1185
-
void clrStatus(bool clrIsOn=true)
Definition ButtonToSwitch_ESP32.cpp:2266
-
bool setOtptSldrSpd(const uint16_t &newVal)
Sets the output slider speed (otptSldrSpd) attribute.
Definition ButtonToSwitch_ESP32.cpp:2345
-
uint16_t getOtptValMax()
Returns the top output current value register setting.
Definition ButtonToSwitch_ESP32.cpp:2305
-
bool getOtptCurValIsMin()
Returns the result of comparing the Output Current Value to the Minimum value setting
Definition ButtonToSwitch_ESP32.cpp:2290
-
bool setSldrDirDn()
Sets the value of the curSldrDirUp attribute to false.
Definition ButtonToSwitch_ESP32.cpp:2449
-
bool setOtptValMax(const uint16_t &newVal)
Sets the output current value register maximum value attribute (otptValMax attribute).
Definition ButtonToSwitch_ESP32.cpp:2381
-
bool swapSldrDir()
Inverts the current curSldrDirUp attribute value.
Definition ButtonToSwitch_ESP32.cpp:2562
-
~SldrDALtchMPBttn()
Virtual class destructor.
Definition ButtonToSwitch_ESP32.cpp:2262
-
bool setOtptCurVal(const uint16_t &newVal)
Sets the output current value register.
Definition ButtonToSwitch_ESP32.cpp:2327
-
uint16_t getOtptCurVal()
Returns the Output Current Value (otpCurVal) attribute.
Definition ButtonToSwitch_ESP32.cpp:2280
-
bool setSldrDirUp()
Sets the value of the curSldrDirUp attribute to true.
Definition ButtonToSwitch_ESP32.cpp:2454
-
bool getSldrDirUp()
Returns the value of the curSldrDirUp attribute.
Definition ButtonToSwitch_ESP32.cpp:2315
-
bool setOtptSldrStpSize(const uint16_t &newVal)
Sets the output slider step size (otptSldrStpSize) attribute value.
Definition ButtonToSwitch_ESP32.cpp:2363
-
bool getOtptCurValIsMax()
Returns a boolean value indicating if the "Output Current Value" equals the maximum limit.
Definition ButtonToSwitch_ESP32.cpp:2285
-
SldrDALtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const uint16_t initVal=0xFFFF)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2256
-
void setSwpDirOnPrss(const bool &newVal)
Sets the value of the "Auto-Swap Direction On Press" (autoSwpDirOnPrss) attribute.
Definition ButtonToSwitch_ESP32.cpp:2466
-
bool setOtptValMin(const uint16_t &newVal)
Sets the output current value register minimum value attribute (otptValMin attribute).
Definition ButtonToSwitch_ESP32.cpp:2403
-
uint16_t getOtptValMin()
Returns the bottom output current value register setting.
Definition ButtonToSwitch_ESP32.cpp:2310
-
unsigned long getOtptSldrSpd()
Returns the current setting for the Output Slider Speed value.
Definition ButtonToSwitch_ESP32.cpp:2295
-
uint16_t getOtptSldrStpSize()
Returns the current setting for the Output Slider Step Size value.
Definition ButtonToSwitch_ESP32.cpp:2300
-
void setSwpDirOnEnd(const bool &newVal)
Sets the value of the "Auto-Swap Direction on Ends" (autoSwpDirOnEnd) attribute.
Definition ButtonToSwitch_ESP32.cpp:2459
+
void clrStatus(bool clrIsOn=true)
Definition ButtonToSwitch_ESP32.cpp:2253
+
bool setOtptSldrSpd(const uint16_t &newVal)
Sets the output slider speed (otptSldrSpd) attribute.
Definition ButtonToSwitch_ESP32.cpp:2332
+
uint16_t getOtptValMax()
Returns the top output current value register setting.
Definition ButtonToSwitch_ESP32.cpp:2292
+
bool getOtptCurValIsMin()
Returns the result of comparing the Output Current Value to the Minimum value setting
Definition ButtonToSwitch_ESP32.cpp:2277
+
bool setSldrDirDn()
Sets the value of the curSldrDirUp attribute to false.
Definition ButtonToSwitch_ESP32.cpp:2436
+
bool setOtptValMax(const uint16_t &newVal)
Sets the output current value register maximum value attribute (otptValMax attribute).
Definition ButtonToSwitch_ESP32.cpp:2368
+
bool swapSldrDir()
Inverts the current curSldrDirUp attribute value.
Definition ButtonToSwitch_ESP32.cpp:2549
+
~SldrDALtchMPBttn()
Virtual class destructor.
Definition ButtonToSwitch_ESP32.cpp:2249
+
bool setOtptCurVal(const uint16_t &newVal)
Sets the output current value register.
Definition ButtonToSwitch_ESP32.cpp:2314
+
uint16_t getOtptCurVal()
Returns the Output Current Value (otpCurVal) attribute.
Definition ButtonToSwitch_ESP32.cpp:2267
+
bool setSldrDirUp()
Sets the value of the curSldrDirUp attribute to true.
Definition ButtonToSwitch_ESP32.cpp:2441
+
bool getSldrDirUp()
Returns the value of the curSldrDirUp attribute.
Definition ButtonToSwitch_ESP32.cpp:2302
+
bool setOtptSldrStpSize(const uint16_t &newVal)
Sets the output slider step size (otptSldrStpSize) attribute value.
Definition ButtonToSwitch_ESP32.cpp:2350
+
bool getOtptCurValIsMax()
Returns a boolean value indicating if the "Output Current Value" equals the maximum limit.
Definition ButtonToSwitch_ESP32.cpp:2272
+
SldrDALtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const uint16_t initVal=0xFFFF)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2243
+
void setSwpDirOnPrss(const bool &newVal)
Sets the value of the "Auto-Swap Direction On Press" (autoSwpDirOnPrss) attribute.
Definition ButtonToSwitch_ESP32.cpp:2453
+
bool setOtptValMin(const uint16_t &newVal)
Sets the output current value register minimum value attribute (otptValMin attribute).
Definition ButtonToSwitch_ESP32.cpp:2390
+
uint16_t getOtptValMin()
Returns the bottom output current value register setting.
Definition ButtonToSwitch_ESP32.cpp:2297
+
unsigned long getOtptSldrSpd()
Returns the current setting for the Output Slider Speed value.
Definition ButtonToSwitch_ESP32.cpp:2282
+
uint16_t getOtptSldrStpSize()
Returns the current setting for the Output Slider Step Size value.
Definition ButtonToSwitch_ESP32.cpp:2287
+
void setSwpDirOnEnd(const bool &newVal)
Sets the value of the "Auto-Swap Direction on Ends" (autoSwpDirOnEnd) attribute.
Definition ButtonToSwitch_ESP32.cpp:2446
Models a Single Service Voidable DD-MPB a.k.a. Trigger switch (SSVDD-MPB)
Definition ButtonToSwitch_ESP32.h:1666
-
virtual void setTaskWhileOn(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:3123
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:3101
-
SnglSrvcVdblMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:3089
-
virtual ~SnglSrvcVdblMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:3097
+
virtual void setTaskWhileOn(const TaskHandle_t &newTaskHandle)
Sets the task to be run while the object is in the On state.
Definition ButtonToSwitch_ESP32.cpp:3110
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:3088
+
SnglSrvcVdblMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:3076
+
virtual ~SnglSrvcVdblMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:3084
Models a Toggle Latch DD-MPB, a.k.a. a Toggle Switch (ToLDD-MPB).
Definition ButtonToSwitch_ESP32.h:644
-
TgglLtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1118
+
TgglLtchMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1107
Models a Timer Latch DD-MPB, a.k.a. Timer Switch (TiLDD-MPB).
Definition ButtonToSwitch_ESP32.h:668
-
const unsigned long int getSrvcTime() const
Returns the configured Service Time.
Definition ButtonToSwitch_ESP32.cpp:1175
-
void setTmerRstbl(const bool &newIsRstbl)
Configures the timer for the Service Time to be reseted before it reaches unlatching time.
Definition ButtonToSwitch_ESP32.cpp:1198
-
bool setSrvcTime(const unsigned long int &newSrvcTime)
Sets a new value to the Service Time attribute.
Definition ButtonToSwitch_ESP32.cpp:1180
-
void clrStatus(bool clrIsOn=true)
see DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1164
-
TmLtchMPBttn(const uint8_t &mpbttnPin, const unsigned long int &svcTime, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1156
+
const unsigned long int getSrvcTime() const
Returns the configured Service Time.
Definition ButtonToSwitch_ESP32.cpp:1164
+
void setTmerRstbl(const bool &newIsRstbl)
Configures the timer for the Service Time to be reseted before it reaches unlatching time.
Definition ButtonToSwitch_ESP32.cpp:1185
+
bool setSrvcTime(const unsigned long int &newSrvcTime)
Sets a new value to the Service Time attribute.
Definition ButtonToSwitch_ESP32.cpp:1169
+
void clrStatus(bool clrIsOn=true)
see DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1153
+
TmLtchMPBttn(const uint8_t &mpbttnPin, const unsigned long int &svcTime, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1145
Models a Time Voidable DD-MPB, a.k.a. Anti-tampering switch (TVDD-MPB)
Definition ButtonToSwitch_ESP32.h:1597
-
virtual ~TmVdblMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2990
-
void clrStatus()
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:3016
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:2994
-
TmVdblMPBttn(const uint8_t &mpbttnPin, unsigned long int voidTime, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const bool &isOnDisabled=false)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2985
-
const unsigned long int getVoidTime() const
Returns the voidTime attribute current value.
Definition ButtonToSwitch_ESP32.cpp:3027
-
bool setVoidTime(const unsigned long int &newVoidTime)
Sets a new value to the Void Time attribute.
Definition ButtonToSwitch_ESP32.cpp:3032
+
virtual ~TmVdblMPBttn()
Class virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2977
+
void clrStatus()
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:3003
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:2981
+
TmVdblMPBttn(const uint8_t &mpbttnPin, unsigned long int voidTime, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const bool &isOnDisabled=false)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2972
+
const unsigned long int getVoidTime() const
Returns the voidTime attribute current value.
Definition ButtonToSwitch_ESP32.cpp:3014
+
bool setVoidTime(const unsigned long int &newVoidTime)
Sets a new value to the Void Time attribute.
Definition ButtonToSwitch_ESP32.cpp:3019
Abstract class, base to model Voidable DD-MPBs (VDD-MPB).
Definition ButtonToSwitch_ESP32.h:1441
-
bool setIsVoided()
Sets the value of the isVoided attribute flag to true.
Definition ButtonToSwitch_ESP32.cpp:2700
-
const bool getIsVoided() const
Returns the current value of the isVoided attribute flag.
Definition ButtonToSwitch_ESP32.cpp:2607
-
fncPtrType getFnWhnTrnOnVdd()
Returns the function that is set to execute every time the object enters the Voided or "Voided On" St...
Definition ButtonToSwitch_ESP32.cpp:2597
-
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:2579
-
void setFnWhnTrnOnVddPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's isVoided attribute flag is s...
Definition ButtonToSwitch_ESP32.cpp:2672
-
virtual ~VdblMPBttn()
Default virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2575
-
fncPtrType getFnWhnTrnOffVdd()
Returns the function that is set to execute every time the object exits the Voided State.
Definition ButtonToSwitch_ESP32.cpp:2592
-
void setFnWhnTrnOffVddPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's isVoided attribute flag is r...
Definition ButtonToSwitch_ESP32.cpp:2659
-
bool getFrcOtptLvlWhnVdd()
Returns the value of the frcOtptLvlWhnVdd attribute.
Definition ButtonToSwitch_ESP32.cpp:2602
-
bool getStOnWhnOtpFrcd()
Returns the value of the frcOtptLvlWhnVdd attribute.
Definition ButtonToSwitch_ESP32.cpp:2612
-
bool setIsNotVoided()
Sets the value of the isVoided attribute flag to false.
Definition ButtonToSwitch_ESP32.cpp:2695
-
VdblMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const bool &isOnDisabled=false)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2569
+
bool setIsVoided()
Sets the value of the isVoided attribute flag to true.
Definition ButtonToSwitch_ESP32.cpp:2687
+
const bool getIsVoided() const
Returns the current value of the isVoided attribute flag.
Definition ButtonToSwitch_ESP32.cpp:2594
+
fncPtrType getFnWhnTrnOnVdd()
Returns the function that is set to execute every time the object enters the Voided or "Voided On" St...
Definition ButtonToSwitch_ESP32.cpp:2584
+
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:2566
+
void setFnWhnTrnOnVddPtr(void(*newFnWhnTrnOn)())
Sets the function that will be called to execute every time the object's isVoided attribute flag is s...
Definition ButtonToSwitch_ESP32.cpp:2659
+
virtual ~VdblMPBttn()
Default virtual destructor.
Definition ButtonToSwitch_ESP32.cpp:2562
+
fncPtrType getFnWhnTrnOffVdd()
Returns the function that is set to execute every time the object exits the Voided State.
Definition ButtonToSwitch_ESP32.cpp:2579
+
void setFnWhnTrnOffVddPtr(void(*newFnWhnTrnOff)())
Sets the function that will be called to execute every time the object's isVoided attribute flag is r...
Definition ButtonToSwitch_ESP32.cpp:2646
+
bool getFrcOtptLvlWhnVdd()
Returns the value of the frcOtptLvlWhnVdd attribute.
Definition ButtonToSwitch_ESP32.cpp:2589
+
bool getStOnWhnOtpFrcd()
Returns the value of the frcOtptLvlWhnVdd attribute.
Definition ButtonToSwitch_ESP32.cpp:2599
+
bool setIsNotVoided()
Sets the value of the isVoided attribute flag to false.
Definition ButtonToSwitch_ESP32.cpp:2682
+
VdblMPBttn(const uint8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const bool &isOnDisabled=false)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:2556
Models an External Unlatch LDD-MPB, a.k.a. Emergency Latched Switch (XULDD-MPB)
Definition ButtonToSwitch_ESP32.h:910
-
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1711
-
XtrnUnltchMPBttn(const uint8_t &mpbttnPin, DbncdDlydMPBttn *unLtchBttn, const bool &pulledUp, const bool &typeNO, const unsigned long int &dbncTimeOrigSett, const unsigned long int &strtDelay)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1671
-
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1683
+
void clrStatus(bool clrIsOn=true)
See DbncdMPBttn::clrStatus(bool)
Definition ButtonToSwitch_ESP32.cpp:1698
+
XtrnUnltchMPBttn(const uint8_t &mpbttnPin, DbncdDlydMPBttn *unLtchBttn, const bool &pulledUp, const bool &typeNO, const unsigned long int &dbncTimeOrigSett, const unsigned long int &strtDelay)
Class constructor.
Definition ButtonToSwitch_ESP32.cpp:1658
+
virtual bool begin(const unsigned long int &pollDelayMs=_StdPollDelay)
See DbncdMPBttn::begin(const unsigned long int)
Definition ButtonToSwitch_ESP32.cpp:1670
Type to hold the complete set of output attribute flags from any DbncdMPBttn class and subclasses obj...
Definition ButtonToSwitch_ESP32.h:61
diff --git a/docs/annotated.html b/docs/annotated.html index d379250..8a450e3 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_d_dlyd_d_a_ltch_m_p_bttn-members.html b/docs/class_d_dlyd_d_a_ltch_m_p_bttn-members.html index b949636..72a51fa 100644 --- a/docs/class_d_dlyd_d_a_ltch_m_p_bttn-members.html +++ b/docs/class_d_dlyd_d_a_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_d_dlyd_d_a_ltch_m_p_bttn.html b/docs/class_d_dlyd_d_a_ltch_m_p_bttn.html index 94765b8..7313941 100644 --- a/docs/class_d_dlyd_d_a_ltch_m_p_bttn.html +++ b/docs/class_d_dlyd_d_a_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbl_actn_ltch_m_p_bttn-members.html b/docs/class_dbl_actn_ltch_m_p_bttn-members.html index 18b272a..d11c207 100644 --- a/docs/class_dbl_actn_ltch_m_p_bttn-members.html +++ b/docs/class_dbl_actn_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbl_actn_ltch_m_p_bttn.html b/docs/class_dbl_actn_ltch_m_p_bttn.html index 0b78e65..8b1493e 100644 --- a/docs/class_dbl_actn_ltch_m_p_bttn.html +++ b/docs/class_dbl_actn_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbncd_dlyd_m_p_bttn-members.html b/docs/class_dbncd_dlyd_m_p_bttn-members.html index d4fde06..cd7b2d8 100644 --- a/docs/class_dbncd_dlyd_m_p_bttn-members.html +++ b/docs/class_dbncd_dlyd_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbncd_dlyd_m_p_bttn.html b/docs/class_dbncd_dlyd_m_p_bttn.html index b36fdab..1d36bd6 100644 --- a/docs/class_dbncd_dlyd_m_p_bttn.html +++ b/docs/class_dbncd_dlyd_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbncd_m_p_bttn-members.html b/docs/class_dbncd_m_p_bttn-members.html index 2645425..e3bd14a 100644 --- a/docs/class_dbncd_m_p_bttn-members.html +++ b/docs/class_dbncd_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_dbncd_m_p_bttn.html b/docs/class_dbncd_m_p_bttn.html index 7ba0cc9..52c38f5 100644 --- a/docs/class_dbncd_m_p_bttn.html +++ b/docs/class_dbncd_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_hntd_tm_ltch_m_p_bttn-members.html b/docs/class_hntd_tm_ltch_m_p_bttn-members.html index dd805a3..5346821 100644 --- a/docs/class_hntd_tm_ltch_m_p_bttn-members.html +++ b/docs/class_hntd_tm_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_hntd_tm_ltch_m_p_bttn.html b/docs/class_hntd_tm_ltch_m_p_bttn.html index 5a5d0ed..4ce56bd 100644 --- a/docs/class_hntd_tm_ltch_m_p_bttn.html +++ b/docs/class_hntd_tm_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_ltch_m_p_bttn-members.html b/docs/class_ltch_m_p_bttn-members.html index 5da6737..8385456 100644 --- a/docs/class_ltch_m_p_bttn-members.html +++ b/docs/class_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_ltch_m_p_bttn.html b/docs/class_ltch_m_p_bttn.html index 215c5b3..4325879 100644 --- a/docs/class_ltch_m_p_bttn.html +++ b/docs/class_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_sldr_d_a_ltch_m_p_bttn-members.html b/docs/class_sldr_d_a_ltch_m_p_bttn-members.html index bce7ba6..5cb9a68 100644 --- a/docs/class_sldr_d_a_ltch_m_p_bttn-members.html +++ b/docs/class_sldr_d_a_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_sldr_d_a_ltch_m_p_bttn.html b/docs/class_sldr_d_a_ltch_m_p_bttn.html index 6a868ab..4961fb2 100644 --- a/docs/class_sldr_d_a_ltch_m_p_bttn.html +++ b/docs/class_sldr_d_a_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_sngl_srvc_vdbl_m_p_bttn-members.html b/docs/class_sngl_srvc_vdbl_m_p_bttn-members.html index a58e73c..df9cd9c 100644 --- a/docs/class_sngl_srvc_vdbl_m_p_bttn-members.html +++ b/docs/class_sngl_srvc_vdbl_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_sngl_srvc_vdbl_m_p_bttn.html b/docs/class_sngl_srvc_vdbl_m_p_bttn.html index 28d034c..ff43d1f 100644 --- a/docs/class_sngl_srvc_vdbl_m_p_bttn.html +++ b/docs/class_sngl_srvc_vdbl_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tggl_ltch_m_p_bttn-members.html b/docs/class_tggl_ltch_m_p_bttn-members.html index 83f6200..fefb20b 100644 --- a/docs/class_tggl_ltch_m_p_bttn-members.html +++ b/docs/class_tggl_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tggl_ltch_m_p_bttn.html b/docs/class_tggl_ltch_m_p_bttn.html index e5fb622..e936dd2 100644 --- a/docs/class_tggl_ltch_m_p_bttn.html +++ b/docs/class_tggl_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tm_ltch_m_p_bttn-members.html b/docs/class_tm_ltch_m_p_bttn-members.html index da2fa4b..30e10e1 100644 --- a/docs/class_tm_ltch_m_p_bttn-members.html +++ b/docs/class_tm_ltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tm_ltch_m_p_bttn.html b/docs/class_tm_ltch_m_p_bttn.html index 30acdf8..4ed81a9 100644 --- a/docs/class_tm_ltch_m_p_bttn.html +++ b/docs/class_tm_ltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tm_vdbl_m_p_bttn-members.html b/docs/class_tm_vdbl_m_p_bttn-members.html index 7257074..01e97f7 100644 --- a/docs/class_tm_vdbl_m_p_bttn-members.html +++ b/docs/class_tm_vdbl_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_tm_vdbl_m_p_bttn.html b/docs/class_tm_vdbl_m_p_bttn.html index 5668edf..84ecf06 100644 --- a/docs/class_tm_vdbl_m_p_bttn.html +++ b/docs/class_tm_vdbl_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_vdbl_m_p_bttn-members.html b/docs/class_vdbl_m_p_bttn-members.html index 0021ac1..99fc36c 100644 --- a/docs/class_vdbl_m_p_bttn-members.html +++ b/docs/class_vdbl_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_vdbl_m_p_bttn.html b/docs/class_vdbl_m_p_bttn.html index 57e6bb0..8f86234 100644 --- a/docs/class_vdbl_m_p_bttn.html +++ b/docs/class_vdbl_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_xtrn_unltch_m_p_bttn-members.html b/docs/class_xtrn_unltch_m_p_bttn-members.html index 3dca3c0..9fe704e 100644 --- a/docs/class_xtrn_unltch_m_p_bttn-members.html +++ b/docs/class_xtrn_unltch_m_p_bttn-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/class_xtrn_unltch_m_p_bttn.html b/docs/class_xtrn_unltch_m_p_bttn.html index 0b804d2..4336128 100644 --- a/docs/class_xtrn_unltch_m_p_bttn.html +++ b/docs/class_xtrn_unltch_m_p_bttn.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/classes.html b/docs/classes.html index 5e2d55a..e15ce3f 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 729e932..c813321 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/files.html b/docs/files.html index 08c41b2..ec2df57 100644 --- a/docs/files.html +++ b/docs/files.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/functions.html b/docs/functions.html index ccee24e..92614f6 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/functions_func.html b/docs/functions_func.html index 8cecd8e..d11c1bb 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/globals.html b/docs/globals.html index a91233e..dc4cdeb 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/globals_func.html b/docs/globals_func.html index bf1a039..6679817 100644 --- a/docs/globals_func.html +++ b/docs/globals_func.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/graph_legend.html b/docs/graph_legend.html index 95e8f7e..f79d86a 100644 --- a/docs/graph_legend.html +++ b/docs/graph_legend.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/hierarchy.html b/docs/hierarchy.html index 3976c5e..5ae85ad 100644 --- a/docs/hierarchy.html +++ b/docs/hierarchy.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/index.html b/docs/index.html index b3dd834..314fda1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/inherits.html b/docs/inherits.html index fc3ca1d..51c80b4 100644 --- a/docs/inherits.html +++ b/docs/inherits.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/struct_mpb_otpts__t-members.html b/docs/struct_mpb_otpts__t-members.html index abd6390..70138aa 100644 --- a/docs/struct_mpb_otpts__t-members.html +++ b/docs/struct_mpb_otpts__t-members.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/docs/struct_mpb_otpts__t.html b/docs/struct_mpb_otpts__t.html index e944fe4..9f6c8e8 100644 --- a/docs/struct_mpb_otpts__t.html +++ b/docs/struct_mpb_otpts__t.html @@ -28,7 +28,7 @@ Logo -
ButtonToSwitch Library for ESP32 (Arduino) v4.0.3 +
ButtonToSwitch Library for ESP32 (Arduino) v4.0.4
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
diff --git a/examples/01_DbncdMPBttn_1d/01_DbncdMPBttn_1d.ino b/examples/01_DbncdMPBttn_1d/01_DbncdMPBttn_1d.ino new file mode 100644 index 0000000..1da46b6 --- /dev/null +++ b/examples/01_DbncdMPBttn_1d/01_DbncdMPBttn_1d.ino @@ -0,0 +1,238 @@ +/** + ****************************************************************************** + * @file : 01_DbncdMPBttn_1d.ino + * @brief : Example for the ButtonToSwitch_ESP32 library DbncdMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a DbncdMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the DbncdMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. That second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 16/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + DbncdMPBttn dmpbBttn (dmpbSwitchPin); + DbncdMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 10000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(true); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/01_DbncdMPBttn_1e/01_DbncdMPBttn_1e.ino b/examples/01_DbncdMPBttn_1e/01_DbncdMPBttn_1e.ino new file mode 100644 index 0000000..f68b8b9 --- /dev/null +++ b/examples/01_DbncdMPBttn_1e/01_DbncdMPBttn_1e.ino @@ -0,0 +1,312 @@ +/** + ****************************************************************************** + * @file : 01_DbncdMPBttn_1e.ino + * @brief : Example for the ButtonToSwitch_ESP32 library DbncdMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a DbncdMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * - 1 led with it's corresponding resistor between GND and dmpbFnWhnTrnOnOffPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example created two dedicated functions + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the DbncdMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. The second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * - The first functions is to be executed when the MPB enters the "isOn state", please refer to the + * **setFnWhnTrnOnPtr()** method for details. + * + * - The second functions is to be executed when the MPB enters the "isOff state", please refer to the + * **setFnWhnTrnOffPtr()** method for details. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 19/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +const uint8_t dmpbFnWhnTrnOnOffPin{GPIO_NUM_4}; + + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +void fnExecTrnOn(); +void fnExecTrnOff(); + +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + pinMode(dmpbFnWhnTrnOnOffPin, OUTPUT); + + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + DbncdMPBttn dmpbBttn (dmpbSwitchPin); + DbncdMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 10000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(false); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.setFnWhnTrnOnPtr(&fnExecTrnOn); + dmpbBttn.setFnWhnTrnOffPtr(&fnExecTrnOff); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +void fnExecTrnOn(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOff() + */ + const unsigned long int swapTimeMs{100000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 2){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, HIGH); + + return; +} + +void fnExecTrnOff(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOn() + */ + const unsigned long int swapTimeMs{50000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 4){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, LOW); + + return; +} + +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/02_DbncdDlydMPBttn_1d/02_DbncdDlydMPBttn_1d.ino b/examples/02_DbncdDlydMPBttn_1d/02_DbncdDlydMPBttn_1d.ino new file mode 100644 index 0000000..cde2bfe --- /dev/null +++ b/examples/02_DbncdDlydMPBttn_1d/02_DbncdDlydMPBttn_1d.ino @@ -0,0 +1,238 @@ +/** + ****************************************************************************** + * @file : 02_DbncdDlydMPBttn_1d.ino + * @brief : Example for the ButtonToSwitch_ESP32 library DbncdDlydMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a DbncdDlydMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the DbncdDlydMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. That second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 16/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + DbncdDlydMPBttn dmpbBttn (dmpbSwitchPin, true, true, 50, 450); + DbncdMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 10000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(true); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/02_DbncdDlydMPBttn_1e/02_DbncdDlydMPBttn_1e.ino b/examples/02_DbncdDlydMPBttn_1e/02_DbncdDlydMPBttn_1e.ino new file mode 100644 index 0000000..5f18675 --- /dev/null +++ b/examples/02_DbncdDlydMPBttn_1e/02_DbncdDlydMPBttn_1e.ino @@ -0,0 +1,312 @@ +/** + ****************************************************************************** + * @file : 02_DbncdDlydMPBttn_1e.ino + * @brief : Example for the ButtonToSwitch_ESP32 library DbncdDlydMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a DbncdDlydMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * - 1 led with it's corresponding resistor between GND and dmpbFnWhnTrnOnOffPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example created two dedicated functions + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the DbncdDlydMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. The second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * - The first functions is to be executed when the MPB enters the "isOn state", please refer to the + * **setFnWhnTrnOnPtr()** method for details. + * + * - The second functions is to be executed when the MPB enters the "isOff state", please refer to the + * **setFnWhnTrnOffPtr()** method for details. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 19/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +const uint8_t dmpbFnWhnTrnOnOffPin{GPIO_NUM_4}; + + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +void fnExecTrnOn(); +void fnExecTrnOff(); + +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + pinMode(dmpbFnWhnTrnOnOffPin, OUTPUT); + + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + DbncdDlydMPBttn dmpbBttn (dmpbSwitchPin, true, true, 50, 450); + DbncdMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 10000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(false); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.setFnWhnTrnOnPtr(&fnExecTrnOn); + dmpbBttn.setFnWhnTrnOffPtr(&fnExecTrnOff); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +void fnExecTrnOn(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOff() + */ + const unsigned long int swapTimeMs{100000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 2){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, HIGH); + + return; +} + +void fnExecTrnOff(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOn() + */ + const unsigned long int swapTimeMs{50000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 4){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, LOW); + + return; +} + +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/05_TgglLtchMPBttn_1d/05_TgglLtchMPBttn_1d.ino b/examples/05_TgglLtchMPBttn_1d/05_TgglLtchMPBttn_1d.ino new file mode 100644 index 0000000..16b6646 --- /dev/null +++ b/examples/05_TgglLtchMPBttn_1d/05_TgglLtchMPBttn_1d.ino @@ -0,0 +1,238 @@ +/** + ****************************************************************************** + * @file : 05_TgglLtchMPBttn_1d.ino + * @brief : Example for the ButtonToSwitch_ESP32 library TgglLtchMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a TgglLtchMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the TgglLtchMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. That second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 16/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + TgglLtchMPBttn dmpbBttn (dmpbSwitchPin, true, true, 50, 250); + LtchMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 10000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(true); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/05_TgglLtchMPBttn_1e/05_TgglLtchMPBttn_1e.ino b/examples/05_TgglLtchMPBttn_1e/05_TgglLtchMPBttn_1e.ino new file mode 100644 index 0000000..c013082 --- /dev/null +++ b/examples/05_TgglLtchMPBttn_1e/05_TgglLtchMPBttn_1e.ino @@ -0,0 +1,312 @@ +/** + ****************************************************************************** + * @file : 05_TgglLtchMPBttn_1e.ino + * @brief : Example for the ButtonToSwitch_ESP32 library TgglLtchMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a TgglLtchMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * - 1 led with it's corresponding resistor between GND and dmpbFnWhnTrnOnOffPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example created two dedicated functions + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the TgglLtchMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. The second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * - The first functions is to be executed when the MPB enters the "isOn state", please refer to the + * **setFnWhnTrnOnPtr()** method for details. + * + * - The second functions is to be executed when the MPB enters the "isOff state", please refer to the + * **setFnWhnTrnOffPtr()** method for details. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 19/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +const uint8_t dmpbFnWhnTrnOnOffPin{GPIO_NUM_4}; + + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +void fnExecTrnOn(); +void fnExecTrnOff(); + +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + pinMode(dmpbFnWhnTrnOnOffPin, OUTPUT); + + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + TgglLtchMPBttn dmpbBttn (dmpbSwitchPin, true, true, 50, 250); + LtchMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 15000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(false); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.setFnWhnTrnOnPtr(&fnExecTrnOn); + dmpbBttn.setFnWhnTrnOffPtr(&fnExecTrnOff); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +void fnExecTrnOn(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOff() + */ + const unsigned long int swapTimeMs{100000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 2){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, HIGH); + + return; +} + +void fnExecTrnOff(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOn() + */ + const unsigned long int swapTimeMs{50000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 4){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, LOW); + + return; +} + +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/06_TmLtchMPBttn_1d/06_TmLtchMPBttn_1d.ino b/examples/06_TmLtchMPBttn_1d/06_TmLtchMPBttn_1d.ino new file mode 100644 index 0000000..444c3bd --- /dev/null +++ b/examples/06_TmLtchMPBttn_1d/06_TmLtchMPBttn_1d.ino @@ -0,0 +1,238 @@ +/** + ****************************************************************************** + * @file : 06_TmLtchMPBttn_1d.ino + * @brief : Example for the ButtonToSwitch_ESP32 library TmLtchMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a TmLtchMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the TmLtchMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. That second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 16/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + TmLtchMPBttn dmpbBttn (dmpbSwitchPin, 3000, true, true, 50, 100); + LtchMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 15000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(true); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/examples/06_TmLtchMPBttn_1e/06_TmLtchMPBttn_1e.ino b/examples/06_TmLtchMPBttn_1e/06_TmLtchMPBttn_1e.ino new file mode 100644 index 0000000..ba1989c --- /dev/null +++ b/examples/06_TmLtchMPBttn_1e/06_TmLtchMPBttn_1e.ino @@ -0,0 +1,311 @@ +/** + ****************************************************************************** + * @file : 06_TmLtchMPBttn_1e.ino + * @brief : Example for the ButtonToSwitch_ESP32 library TmLtchMPBttn class + * + * Framework: Arduino + * Platform: ESP32 + * + * The example instantiates a TmLtchMPBttn object using: + * - 1 push button between GND and dmpbSwitchPin + * - 1 led with it's corresponding resistor between GND and dmpbLoadPin + * - 1 led with it's corresponding resistor between GND and dmpbIsDisabledPin + * - 1 led with it's corresponding resistor between GND and dmpbTskWhlOnPin + * - 1 led with it's corresponding resistor between GND and dmpbFnWhnTrnOnOffPin + * + * ### This example creates three tasks and deletes the default `loopTask` task + * ### This example created two dedicated functions + * ### This example creates a software timer + * + * The "Main control task" is created in the regular setup() and then that + * arduino standard `loopTask` is deleted in the loop() + * + * In the main control task the TmLtchMPBttn object is instantiated and configured + * as usual, including a task to be unblocked when the isOn state changes by using + * `dmpbBttn.setTaskToNotify(dmpsOutputTskHdl)`. The second task is also created + * in the main control task, as is created the software timer that controls the + * isEnabled state. + * + * When a change in the object's outputs attribute flags values is detected, the + * task that manages the loads and resources that the switch turns On and Off is + * unblocked, with the provision of the MPB state passed as a 32-bits argument. + * The task then takes care of updating the GPIO outputs. + * + * - The third task is created, started and blocked, like the second, it's + * purpose is to execute while the MPB is in "isOn state". + * Please read the library documentation regarding the consequences of executing + * a task that is resumed and paused externally and without previous notification + * to let the task to be paused in an orderly manner!! + * + * The software timer created periodically toggles the isEnabled attribute flag + * value, showing the behavior of the instantiated object when enabled and when + * disabled. + * + * - The first functions is to be executed when the MPB enters the "isOn state", please refer to the + * **setFnWhnTrnOnPtr()** method for details. + * + * - The second functions is to be executed when the MPB enters the "isOff state", please refer to the + * **setFnWhnTrnOffPtr()** method for details. + * + * @author : Gabriel D. Goldman + * + * @date : 01/08/2023 First release + * 19/09/2024 Last update + * + ****************************************************************************** + * @attention This file is part of the examples folder for the ButtonToSwitch_ESP32 + * library. All files needed are provided as part of the source code for the library. + * + * Released into the public domain in accordance with "GPL-3.0-or-later" license terms. + * + ****************************************************************************** + */ +#include +#include + +const uint8_t dmpbFnWhnTrnOnOffPin{GPIO_NUM_4}; + +//===============================>> User Functions Prototypes BEGIN +void swpEnableCb(TimerHandle_t pvParam); +void Error_Handler(); + +void mainCtrlTsk(void *pvParameters); +void dmpsOutputTsk(void *pvParameters); +void dmpsActWhlOnTsk(void *pvParameters); +void fnExecTrnOn(); +void fnExecTrnOff(); + +//===============================>> User Functions Prototypes END + +//===============================>> User Tasks & Timers related declarations BEGIN +TaskHandle_t mainCtrlTskHndl {NULL}; +TaskHandle_t dmpsOutputTskHdl; +TaskHandle_t dmpsActWhlOnTskHndl; +BaseType_t xReturned; + +TimerHandle_t enableSwpTmrHndl{NULL}; +//===============================>> User Tasks & Timers related declarations END + +void setup() { + pinMode(dmpbFnWhnTrnOnOffPin, OUTPUT); + + //Create the Main control task to keep, the MPBs outputs updated and set the Callback task function + xReturned = xTaskCreatePinnedToCore( + mainCtrlTsk, //Callback function/task to be called + "MainControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &mainCtrlTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); +} + +void loop() { + vTaskDelete(NULL); +} + +//===============================>> User Tasks Implementations BEGIN +void mainCtrlTsk(void *pvParameters){ + const uint8_t dmpbSwitchPin{GPIO_NUM_25}; + + TmLtchMPBttn dmpbBttn (dmpbSwitchPin, 3000, true, true, 50, 100); + LtchMPBttn* dmpbBttnPtr {&dmpbBttn}; + + //Create the task to keep the GPIO outputs updated to reflect the MPBs states + xReturned = xTaskCreatePinnedToCore( + dmpsOutputTsk, //Callback function/task to be called + "SwitchOutputsControlTask", //Name of the task + 1716, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsOutputTskHdl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + + //Create the task to resume every time the the MPB enters the On state and blocks when enters the Off state + xReturned = xTaskCreatePinnedToCore( + dmpsActWhlOnTsk, //Callback function/task to be called + "ExecWhileOnTask", //Name of the task + 1024, //Stack size (in bytes in ESP32, words in FreeRTOS), the minimum value is in the config file, for this is 768 bytes + NULL, //Pointer to the parameters for the function to work with + configTIMER_TASK_PRIORITY, //Priority level given to the task: use the same as the Software Timers priority level + &dmpsActWhlOnTskHndl, //Task handle + xPortGetCoreID() //Run in the App Core if it's a dual core mcu (ESP-FreeRTOS specific) + ); + if(xReturned != pdPASS) + Error_Handler(); + vTaskSuspend(dmpsActWhlOnTskHndl); + + //Create the timer to keep the isEnabled state of the MPB changing to see the effects over the MPBs behavior + enableSwpTmrHndl = xTimerCreate( + "isEnabledSwapTimer", + 15000, + pdTRUE, + dmpbBttnPtr, + swpEnableCb + ); + if (enableSwpTmrHndl != NULL) + xReturned = xTimerStart(enableSwpTmrHndl, portMAX_DELAY); + if(xReturned == pdFAIL) + Error_Handler(); + + dmpbBttn.setIsOnDisabled(false); + dmpbBttn.setTaskToNotify(dmpsOutputTskHdl); + dmpbBttn.setTaskWhileOn(dmpsActWhlOnTskHndl); + dmpbBttn.setFnWhnTrnOnPtr(&fnExecTrnOn); + dmpbBttn.setFnWhnTrnOffPtr(&fnExecTrnOff); + dmpbBttn.begin(); + + for(;;){ + /* + Any code can be placed here to execute while the MPBs are monitored + by the timer, and any output change will be responded by the dmpsOutputTsk + */ + } +} + +void dmpsOutputTsk(void *pvParameters){ + const uint8_t dmpbLoadPin{GPIO_NUM_21}; + const uint8_t dmpbIsDisabledPin{GPIO_NUM_18}; + + pinMode(dmpbLoadPin, OUTPUT); + pinMode(dmpbIsDisabledPin, OUTPUT); + + uint32_t mpbSttsRcvd{0}; + MpbOtpts_t mpbCurStateDcdd; + + for(;;){ + xReturned = xTaskNotifyWait( + 0x00, //uint32_t ulBitsToClearOnEntry + 0xFFFFFFFF, //uint32_t ulBitsToClearOnExit, + &mpbSttsRcvd, // uint32_t *pulNotificationValue, + portMAX_DELAY//TickType_t xTicksToWait + ); + if (xReturned != pdPASS) + Error_Handler(); + + mpbCurStateDcdd = otptsSttsUnpkg(mpbSttsRcvd); + digitalWrite(dmpbLoadPin, (mpbCurStateDcdd.isOn)?HIGH:LOW); + digitalWrite(dmpbIsDisabledPin, (mpbCurStateDcdd.isEnabled)?LOW:HIGH); + } +} + +void dmpsActWhlOnTsk(void *pvParameters){ + const uint8_t dmpbTskWhlOnPin{GPIO_NUM_16}; + + pinMode(dmpbTskWhlOnPin, OUTPUT); + + const unsigned long int swapTimeMs{500}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + unsigned long int elapTime{0}; + bool blinkOn {false}; + + strtTime = xTaskGetTickCount() / portTICK_RATE_MS; + for(;;){ + curTime = (xTaskGetTickCount() / portTICK_RATE_MS); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbTskWhlOnPin, blinkOn?HIGH:LOW); + strtTime = curTime; + } + } +} +//===============================>> User Tasks Implementations END + +//===============================>> User Timers Implementations BEGIN +/** + * @brief Timer callback function + * + * @param pvParam The callback function argument. + * In this case is a pointer to the MPB object to be enabled and disabled periodically. + * It's a DbncdMPBttn* as enable() and disable() are dynamic polymorphic so they can be invoked through a base class pointer call. + */ +void swpEnableCb(TimerHandle_t pvParam){ + DbncdMPBttn* dbncdMPBLocPtr = (DbncdMPBttn*) pvTimerGetTimerID(pvParam); + + if (dbncdMPBLocPtr->getIsEnabled()) + dbncdMPBLocPtr->disable(); + else + dbncdMPBLocPtr->enable(); + + return; +} +//===============================>> User Timers Implementations END + +//===============================>> User Functions Implementations BEGIN +void fnExecTrnOn(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOff() + */ + const unsigned long int swapTimeMs{100000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 2){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, HIGH); + + return; +} + +void fnExecTrnOff(){ + /*If the execution of the function resets the MCU the reason might be the + long execution time the function is taking, in that case delete the following + code inside the function and uncomment the last now commented line, the same for the + fnExecTrnOn() + */ + const unsigned long int swapTimeMs{50000}; + unsigned long int strtTime{0}; + unsigned long int curTime{0}; + bool blinkOn {false}; + int blinks{0}; + + strtTime = micros(); + while (blinks < 4){ + curTime = micros(); + if ((curTime - strtTime) > swapTimeMs){ + blinkOn = !blinkOn; + digitalWrite(dmpbFnWhnTrnOnOffPin, blinkOn?HIGH:LOW); + strtTime = curTime; + ++blinks; + } + } + + // digitalWrite(dmpbFnWhnTrnOnOffPin, LOW); + + return; +} + +/** + * @brief Error Handling function + * + * Placeholder for a Error Handling function, in case of an error the execution + * will be trapped in this endless loop + */ +void Error_Handler(){ + for(;;) + { + } + + return; +} +//===============================>> User Functions Implementations END diff --git a/library.json b/library.json index 69c0b46..dcd718b 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ButtonToSwitch_ESP32", - "version": "4.0.3", + "version": "4.0.4", "description": "This Arduino-Esp32 library implements all kind of switches out of simple buttons (Momentary Push Buttons or MPBs). Add any kind of switch to a project by using simple MPBs and this library to simulate the internal mechanism of each of them, starting from a Debounced Push Button and extending to Delayed Start Push Button, Toggle (Latched) Push Button, Time Latched Push Button, External Release Latched Push Button, Staircase Timed Button, On/Off/Dimmer, and more..." , "keywords": "momentary, push, button, debounce, switch, latch, toggle, release, warning, security, staircase, timer, slider, dimmer", diff --git a/library.properties b/library.properties index 59370f4..685c42d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ButtonToSwitch_ESP32 -version=4.0.3 +version=4.0.4 author=Gabriel D. Goldman maintainer=Gabriel D. Goldman sentence=Implement simple to complex switches out of simple buttons, this library with an easy consistent API will take care of debouncing, deglitching, toggle on-off, keep activation times in a completely unnatended manner. diff --git a/src/ButtonToSwitch_ESP32.cpp b/src/ButtonToSwitch_ESP32.cpp index 5e55cde..9db05e4 100644 --- a/src/ButtonToSwitch_ESP32.cpp +++ b/src/ButtonToSwitch_ESP32.cpp @@ -12,7 +12,7 @@ * behavior of standard electromechanical switches**. * * @author : Gabriel D. Goldman - * @version v4.0.2 + * @version v4.0.4 * @date : Created on: 06/11/2023 * : Last modification: 15/09/2024 * @copyright GPL-3.0 license @@ -103,11 +103,9 @@ void DbncdMPBttn::clrStatus(bool clrIsOn){ _validReleasePend = false; _dbncTimerStrt = 0; _dbncRlsTimerStrt = 0; - if(clrIsOn){ - if(_isOn){ + if(clrIsOn) + if(_isOn) _turnOff(); - } - } taskEXIT_CRITICAL(&mux); return; @@ -137,12 +135,10 @@ bool DbncdMPBttn::end(){ result = pause(); if (result){ tmrModResult = xTimerDelete(_mpbPollTmrHndl, portMAX_DELAY); - if (tmrModResult == pdPASS){ + if (tmrModResult == pdPASS) _mpbPollTmrHndl = NULL; - } - else{ + else result = false; - } } } @@ -348,12 +344,10 @@ bool DbncdMPBttn::setDbncTime(const unsigned long int &newDbncTime){ taskENTER_CRITICAL(&mux); if(_dbncTimeTempSett != newDbncTime){ - if (newDbncTime >= _stdMinDbncTime){ + if (newDbncTime >= _stdMinDbncTime) _dbncTimeTempSett = newDbncTime; - } - else{ + else result = false; - } } taskEXIT_CRITICAL(&mux); @@ -364,9 +358,8 @@ void DbncdMPBttn::setFnWhnTrnOffPtr(void (*newFnWhnTrnOff)()){ portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; taskENTER_CRITICAL(&mux); - if (_fnWhnTrnOff != newFnWhnTrnOff){ + if (_fnWhnTrnOff != newFnWhnTrnOff) _fnWhnTrnOff = newFnWhnTrnOff; - } taskEXIT_CRITICAL(&mux); return; @@ -376,9 +369,8 @@ void DbncdMPBttn::setFnWhnTrnOnPtr(void (*newFnWhnTrnOn)()){ portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; taskENTER_CRITICAL(&mux); - if (_fnWhnTrnOn != newFnWhnTrnOn){ + if (_fnWhnTrnOn != newFnWhnTrnOn) _fnWhnTrnOn = newFnWhnTrnOn; - } taskEXIT_CRITICAL(&mux); return; @@ -413,12 +405,10 @@ void DbncdMPBttn::setIsOnDisabled(const bool &newIsOnDisabled){ _isOnDisabled = newIsOnDisabled; if(!_isEnabled){ if(_isOn != _isOnDisabled){ - if(_isOnDisabled){ + if(_isOnDisabled) _turnOn(); - } - else{ + else _turnOff(); - } } } } @@ -870,9 +860,8 @@ void LtchMPBttn::setTrnOffASAP(const bool &newVal){ portMUX_TYPE mux portMUX_INITIALIZER_UNLOCKED; taskENTER_CRITICAL(&mux); - if(_trnOffASAP != newVal){ + if(_trnOffASAP != newVal) _trnOffASAP = newVal; - } taskEXIT_CRITICAL(&mux); return; @@ -1183,12 +1172,10 @@ bool TmLtchMPBttn::setSrvcTime(const unsigned long int &newSrvcTime){ taskENTER_CRITICAL(&mux); if (_srvcTime != newSrvcTime){ - if (newSrvcTime >= _MinSrvcTime){ //The minimum activation time is _minActTime milliseconds + if (newSrvcTime >= _MinSrvcTime) //The minimum activation time is _minActTime milliseconds _srvcTime = newSrvcTime; - } - else{ + else result = false; - } } taskEXIT_CRITICAL(&mux); diff --git a/src/ButtonToSwitch_ESP32.h b/src/ButtonToSwitch_ESP32.h index 3e2f003..18ad86d 100644 --- a/src/ButtonToSwitch_ESP32.h +++ b/src/ButtonToSwitch_ESP32.h @@ -12,7 +12,7 @@ * behavior of standard electromechanical switches**. * * @author : Gabriel D. Goldman - * @version v4.0.1 + * @version v4.0.4 * @date : Created on: 06/11/2023 * : Last modification: 28/08/2024 * @copyright GPL-3.0 license @@ -1659,7 +1659,7 @@ class TmVdblMPBttn: public VdblMPBttn{ * * @note Due to the short time the **isOn** flag will be raised, as described above, the resuming of the **taskWhileOn** activation mechanism is disabled in this class. For that purpose the setTaskWhileOn(const TaskHandle_t) is made not accessible by setting it's accessibility to **protected**. * - *@note Due to the short time the **isOn** flag will be raised, as described above, the short time between the **fnWhnTrnOn** function and the **fnWhnTrnOff** function callings must also need to be evaluated by the user. + * @note Due to the short time the **isOn** flag will be raised, as described above, the short time between the **fnWhnTrnOn** function and the **fnWhnTrnOff** function callings must also need to be evaluated by the user. * * @class SnglSrvcVdblMPBttn */