ButtonToSwitch Library for ESP32 (Arduino) v5.0.0
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
Loading...
Searching...
No Matches
VdblMPBttn Class Referenceabstract

Abstract class, base to model Voidable DD-MPBs (VDD-MPB). More...

#include <ButtonToSwitch_ESP32.h>

Inheritance diagram for VdblMPBttn:
Collaboration diagram for VdblMPBttn:

Public Member Functions

 VdblMPBttn ()
 Default constructor.
 VdblMPBttn (const int8_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.
 VdblMPBttn (PressSignalSource *newSignalSource, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0, const bool &isOnDisabled=false)
 Class constructor.
 VdblMPBttn (const VdblMPBttn &other)
 Copy constructor.
virtual ~VdblMPBttn ()
 Default virtual destructor.
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 status.
void clrStatus (bool clrIsOn=true)
 See DbncdMPBttn::clrStatus(bool).
fncPtrType getFnWhnTrnOffVdd ()
 Returns the function that is set to execute every time the object exits the Voided State.
fncPtrType getFnWhnTrnOnVdd ()
 Returns the function that is set to execute every time the object enters the Voided or "Voided On" State.
bool getFrcdOtptLvlWhnVdd ()
 Returns the value of the frcOtptLvlWhnVdd attribute.
fncVdPtrPrmPtrType getFVPPWhnTrnOffVdd ()
 Returns a pointer to a function that is set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.
void * getFVPPWhnTrnOffVddArgPtr ()
 Returns a pointer to the argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.
fncVdPtrPrmPtrType getFVPPWhnTrnOnVdd ()
 Returns a pointer to a function that is set to execute every time the object enters the Voided On State a.k.a. Voided State.
void * getFVPPWhnTrnOnVddArgPtr ()
 Returns a pointer to the argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.
const bool getIsVoided () const
 Returns the current value of the isVoided attribute flag.
bool getStOnWhnVddOtpLvlFrcd ()
 Returns the value of the frcOtptLvlWhnVdd attribute.
void setFnWhnTrnOffVddPtr (void(*newFnWhnTrnOff)())
 Sets the function that will be called to execute every time the object's isVoided attribute flag is reset.
void setFnWhnTrnOnVddPtr (void(*newFnWhnTrnOn)())
 Sets the function that will be called to execute every time the object's isVoided attribute flag is set.
void setFVPPWhnTrnOffVdd (fncVdPtrPrmPtrType newFVPPWhnTrnOff, void *argPtr=nullptr)
 Sets a function to be executed every time the object enters the Voided Off State a.k.a. Not Voided State.
void setFVPPWhnTrnOffVddArgPtr (void *newFVPPWhnTrnOffArgPtr)
 Sets a pointer to an argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.
void setFVPPWhnTrnOnVdd (fncVdPtrPrmPtrType newFVPPWhnTrnOn, void *argPtr=nullptr)
 Sets a function to be executed every time the object enters the Voided On State a.k.a. Voided State.
void setFVPPWhnTrnOnVddArgPtr (void *newFVPPWhnTrnOnArgPtr)
 Sets a pointer to an argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.
bool setIsNotVoided ()
 Sets the value of the isVoided attribute flag to false.
bool setIsVoided ()
 Sets the value of the isVoided attribute flag to true.
Public Member Functions inherited from DbncdDlydMPBttn
 DbncdDlydMPBttn ()
 Default constructor.
 DbncdDlydMPBttn (const int8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
 Class constructor.
 DbncdDlydMPBttn (PressSignalSource *newSignalSource, const unsigned long int &dbncTimeOrigSett=0, const unsigned long int &strtDelay=0)
 Class constructor.
 DbncdDlydMPBttn (const DbncdDlydMPBttn &other)
 Copy constructor.
virtual ~DbncdDlydMPBttn ()
 Class destructor.
void setStrtDelay (const unsigned long int &newStrtDelay)
 Sets a new value to the "Start Delay" strtDelay attribute.
Public Member Functions inherited from DbncdMPBttn
 DbncdMPBttn ()
 Default class constructor.
 DbncdMPBttn (const int8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0)
 Class constructor.
 DbncdMPBttn (PressSignalSource *newSignalSource, const unsigned long int &dbncTimeOrigSett=0)
 Class constructor.
 DbncdMPBttn (const DbncdMPBttn &other)
 Copy constructor.
virtual ~DbncdMPBttn ()
 Class destructor.
void clrStatus (bool clrIsOn=true)
 Clears and resets flags, timers and counters modified through the object's signals processing.
void disable ()
 Disables the input signal processing, ignoring the changes of its values.
void enable ()
 Enables the input signal processing.
bool end ()
 Detaches the object from the timer that monitors the input pins, compute and updates the object's status. The timer daemon entry is deleted for the object.
bool getBeginDisabled ()
 Returns the value of the beginDisabled attribute.
uint8_t getBtsSerialNum () const
 Get the object's Instantiation Serial Number.
const unsigned long int getCurDbncTime () const
 Returns the current debounce period time set for the object.
fncPtrType getFnWhnTrnOff ()
 Returns a pointer to a function that is set to execute every time the object enters the Off State.
fncPtrType getFnWhnTrnOn ()
 Returns a pointer to a function that is set to execute every time the object enters the On State.
fncVdPtrPrmPtrType getFVPPWhnTrnOff ()
 Returns a pointer to a function that is set to execute every time the object enters the Off State.
void * getFVPPWhnTrnOffArgPtr ()
 Returns a pointer to the argument to be passed to the function set to execute every time the object enters the Off State.
fncVdPtrPrmPtrType getFVPPWhnTrnOn ()
 Returns a pointer to a function that is set to execute every time the object enters the On State.
void * getFVPPWhnTrnOnArgPtr ()
 Returns a pointer to the argument to be passed to the function set to execute every time the object enters the On State.
const bool getIsEnabled () const
 Returns the value of the isEnabled attribute flag, indicating the Enabled or Disabled status of the object.
const bool getIsOn () const
 Returns the value of the isOn attribute flag.
const bool getIsOnDisabled () const
 Returns the value of the isOnDisabled attribute flag.
const DbncdMPBttngetMpbInstnc () const
 Returns a pointer to the present instanced object.
const uint32_t getOtptsSttsPkgd ()
 Returns the relevant attribute flags values for the object state encoded as a 32 bits value, required to pass current state of the object to another thread/task managing the outputs.
const bool getOutputsChange () const
 Returns the value of the outputsChange attribute flag.
unsigned long int getStrtDelay ()
 Returns the current value of strtDelay attribute.
const TaskHandle_t getTaskToNotify () const
 Returns the task to be notified by the object when its output flags changes.
const TaskHandle_t getTaskWhileOn ()
 Returns the task to be run (resumed) while the object is in the On state.
bool pause ()
 Pauses the software timer updating the computation of the object's internal flags value.
void resetDbncTime ()
 Resets the debounce process time of the object to the value used at instantiation.
void resetFda ()
 Resets the MPB behavior automaton to it's Initial or Start State.
bool resume ()
 Restarts the software timer updating the calculation of the object internal flags.
void setBeginDisabled (const bool &newBeginDisabled=false)
 Sets the starting isDisabled state.
bool setDbncTime (const unsigned long int &newDbncTime)
 Sets the debounce process time.
void setFnWhnTrnOffPtr (fncPtrType newFnWhnTrnOff)
 Sets the function that will be called to execute every time the object enters the Off State.
void setFnWhnTrnOnPtr (fncPtrType newFnWhnTrnOn)
 Sets the function that will be called to execute every time the object enters the On State.
void setFVPPWhnTrnOff (fncVdPtrPrmPtrType newFVPPWhnTrnOff, void *argPtr=nullptr)
 Sets a function to be executed every time the object enters the Off State.
void setFVPPWhnTrnOffArgPtr (void *newFVPPWhnTrnOffArgPtr)
 Sets a pointer to an argument to be passed to the function set to execute every time the object enters the Off State.
void setFVPPWhnTrnOn (fncVdPtrPrmPtrType newFVPPWhnTrnOn, void *argPtr=nullptr)
 Sets a function to be executed every time the object enters the On State.
void setFVPPWhnTrnOnArgPtr (void *newFVPPWhnTrnOnArgPtr)
 Sets a pointer to an argument to be passed to the function set to execute every time the object enters the On State.
void setIsOnDisabled (const bool &newIsOnDisabled)
 Sets the value of the isOnDisabled attribute flag.
void setOutputsChange (bool newOutputsChange)
 Sets the value of the attribute flag indicating if a change took place in any of the output attribute flags (IsOn included).
void setTaskToNotify (const TaskHandle_t &newTaskHandle)
 Sets the handle to the task to be notified by the object when its output attribute flags changes.
virtual void setTaskWhileOn (const TaskHandle_t &newTaskHandle)
 Sets the task to be run while the object is in the On state.

Detailed Description

Abstract class, base to model Voidable DD-MPBs (VDD-MPB).

Voidable DD-MPBs are MPBs whose distinctive characteristic is that implement non-latching switches that while being pressed their state might change from On State to a Voided state due to different voiding conditions. Depending on the classes the voided state might be Voided & Off state, Voided & On state or Voided & Not enforced states. Those conditions to change to a voided state include -but are not limited to- the following conditions:

  • pressing time
  • external signals
  • entering the On state

The mechanisms to "un-void" the MPB and return it to an operational state include -but are not limited to- the following actions:

  • releasing the MPBs
  • receiving an external signal
  • the reading of the isOn attribute flag status

The voiding conditions and the un-voiding mechanisms define the VDD-MPB subclasses.

Constructor & Destructor Documentation

◆ VdblMPBttn() [1/3]

VdblMPBttn::VdblMPBttn ( const int8_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.

Parameters
isOnDisabled(Optional) Sets the instantiation value for the isOnDisabled flag attribute.
Note
For the parameters see DbncdDlydMPBttn(const int8_t, const bool, const bool, const unsigned long int, const unsigned long int)
Here is the call graph for this function:

◆ VdblMPBttn() [2/3]

VdblMPBttn::VdblMPBttn ( PressSignalSource * newSignalSource,
const unsigned long int & dbncTimeOrigSett = 0,
const unsigned long int & strtDelay = 0,
const bool & isOnDisabled = false )

Class constructor.

Parameters
isOnDisabled(Optional) Sets the instantiation value for the isOnDisabled flag attribute.
Note
For the other parameters see DbncdDlydMPBttn(PressSignalSource*, const unsigned long int)
Attention
The PressSignalSource class and its subclasses are expected to be created and configured by the developer using this library, so no default values or configurations are provided for them. The only requirement for a PressSignalSource subclass object to be used as a parameter in this constructor is that it must be properly instantiated and configured to provide the expected behavior for the MPB signal processing by the DbncdMPBttn objects. The library provides a McuInputPin subclass of PressSignalSource that can be used to create a bridge between pre v5.0.0 library legacy objects and new objects created with this constructor, but any other PressSignalSource subclass can be used as long as it provides the expected behavior for the MPB signal processing.
Here is the call graph for this function:

◆ VdblMPBttn() [3/3]

VdblMPBttn::VdblMPBttn ( const VdblMPBttn & other)

Copy constructor.

Parameters
otherReference to an existing VdblMPBttn object to be copied.
Here is the call graph for this function:

Member Function Documentation

◆ begin()

bool VdblMPBttn::begin ( const unsigned long int & pollDelayMs = _StdPollDelay)
virtual

Attaches the instantiated object to a timer that monitors the input pins and updates the object status.

The frequency of the periodic monitoring is passed as a parameter in milliseconds, and is a value that must be small (frequent) enough to keep the object updated, but not so frequent that wastes resources from other tasks. A default value is provided based on empirical results obtained in various published tests.

Parameters
pollDelayMs(Optional) unsigned long integer (ulong), the time between polls in milliseconds.
Returns
Boolean indicating if the object could be attached to a timer.
Return values
truethe object could be attached to a timer -or it was already attached to a timer when the method was invoked-.
falsethe object could not create the needed timer, or the object could not be attached to it.

Reimplemented from DbncdMPBttn.

◆ getFnWhnTrnOffVdd()

fncPtrType VdblMPBttn::getFnWhnTrnOffVdd ( )

Returns the function that is set to execute every time the object exits the Voided State.

The function to be executed is an attribute that might be modified by the setFnWhnTrnOffVddPtr() method.

Returns
A function pointer to the function set to execute every time the object enters the Unvoided or "Voieded Off" State.
Return values
nullptrif there is no function set to execute when the object enters the Unvoided (or "Voided Off") State.

◆ getFnWhnTrnOnVdd()

fncPtrType VdblMPBttn::getFnWhnTrnOnVdd ( )

Returns the function that is set to execute every time the object enters the Voided or "Voided On" State.

The function to be executed is an attribute that might be modified by the setFnWhnTrnOnVddPtr() method.

Returns
A function pointer to the function set to execute every time the object enters the Voided (or "Voided On") State.
Return values
nullptrif there is no function set to execute when the object enters the Voided State.

◆ getFrcdOtptLvlWhnVdd()

bool VdblMPBttn::getFrcdOtptLvlWhnVdd ( )

Returns the value of the frcOtptLvlWhnVdd attribute.

The frcOtptLvlWhnVdd (Force Output Level When Voided) attribute configures the object to either keep it's isOn attribute flag current value when entering the voided state (false) or to force it to a specific isOn value (true).

Returns
the current value of the frcOtptLvlWhnVdd attribute.
Note
As of this version of the library no VdblMPBttn class or subclasses make use of the frcOtptLvlWhnVdd attribute, their inclusion is "New Features Under Development" related to the refactoring of binary states to Non-binary states.

◆ getFVPPWhnTrnOffVdd()

fncVdPtrPrmPtrType VdblMPBttn::getFVPPWhnTrnOffVdd ( )

Returns a pointer to a function that is set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.

The pointer is one to a function with the signature void (fncPtr*) (void*) to allow for passing a void* argument to the function.

Returns
fncVdPtrPrmPtrType The pointer to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.
Return values
nullptrif there is no function with the described signature set to execute when the object enters the Voided Off State a.k.a. Not Voided State.

◆ getFVPPWhnTrnOffVddArgPtr()

void * VdblMPBttn::getFVPPWhnTrnOffVddArgPtr ( )

Returns a pointer to the argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.

Returns
void* Pointer to the argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.

◆ getFVPPWhnTrnOnVdd()

fncVdPtrPrmPtrType VdblMPBttn::getFVPPWhnTrnOnVdd ( )

Returns a pointer to a function that is set to execute every time the object enters the Voided On State a.k.a. Voided State.

The pointer is one to a function with the signature void (fncPtr*) (void*) to allow for passing a void* argument to the function.

Returns
fncVdPtrPrmPtrType The pointer to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.
Return values
nullptrif there is no function with the described signature set to execute when the object enters the Voided On State a.k.a. Voided State.

◆ getFVPPWhnTrnOnVddArgPtr()

void * VdblMPBttn::getFVPPWhnTrnOnVddArgPtr ( )

Returns a pointer to the argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.

Returns
void* Pointer to the argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.

◆ getIsVoided()

const bool VdblMPBttn::getIsVoided ( ) const

Returns the current value of the isVoided attribute flag.

Returns
The value of the flag.
Return values
trueThe object is in voided state
falseThe object is in not voided state

◆ getStOnWhnVddOtpLvlFrcd()

bool VdblMPBttn::getStOnWhnVddOtpLvlFrcd ( )

Returns the value of the frcOtptLvlWhnVdd attribute.

The frcOtptLvlWhnVdd (Force Output Level When Voided) attribute configures the object to either keep it's isOn attribute flag current value when entering the voided state (false) or to force it to a specific isOn value (true).

If the object is set to force to a specific isOn value (true), the forced value to be set will be determined by the stOnWhnOtptFrcd attribute.

Returns
the current value of the frcOtptLvlWhnVdd attribute.
Note
As of this version of the library no VdblMPBttn class or subclasses make use of the frcOtptLvlWhnVdd attribute, their inclusion is "New Features Under Development" related to the refactoring of binary states to Non-binary states.

◆ setFnWhnTrnOffVddPtr()

void VdblMPBttn::setFnWhnTrnOffVddPtr ( void(* newFnWhnTrnOff )())

Sets the function that will be called to execute every time the object's isVoided attribute flag is reset.

The function to be executed must be of the form void (*newFnWhnTrnOff)(), meaning it must take no arguments and must return no value, it will be executed only once by the object (recursion must be handled with the usual precautions). When instantiated the attribute value is set to nullptr.

Parameters
newFnWhnTrnOffFunction pointer to the function intended to be called when the object's isVoided attribute flag is reset. Passing nullptr as parameter deactivates the function execution mechanism.

◆ setFnWhnTrnOnVddPtr()

void VdblMPBttn::setFnWhnTrnOnVddPtr ( void(* newFnWhnTrnOn )())

Sets the function that will be called to execute every time the object's isVoided attribute flag is set.

The function to be executed must be of the form void (*newFnWhnTrnOn)(), meaning it must take no arguments and must return no value, it will be executed only once by the object (recursion must be handled with the usual precautions). When instantiated the attribute value is set to nullptr.

Parameters
newFnWhnTrnOnfunction pointer to the function intended to be called when the object's isVoided is set. Passing nullptr as parameter deactivates the function execution mechanism.

◆ setFVPPWhnTrnOffVdd()

void VdblMPBttn::setFVPPWhnTrnOffVdd ( fncVdPtrPrmPtrType newFVPPWhnTrnOff,
void * argPtr = nullptr )

Sets a function to be executed every time the object enters the Voided Off State a.k.a. Not Voided State.

The function to be executed must be of the form void (newFVPPWhnTrnOff)(void), meaning it must take a void pointer as argument and must return no value, it will be executed only once by the object (recursion must be handled with the usual precautions). When the object is instantiated the attribute value is set to nullptr.

Parameters
newFVPPWhnTrnOffFunction pointer to the function intended to be called when the object enters the Voided Off State a.k.a. Not Voided State. Passing nullptr as parameter deactivates the function execution mechanism.
argPtrvoid pointer to an argument to be passed to the function when it is called.

◆ setFVPPWhnTrnOffVddArgPtr()

void VdblMPBttn::setFVPPWhnTrnOffVddArgPtr ( void * newFVPPWhnTrnOffArgPtr)

Sets a pointer to an argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.

The argument pointer is passed to the function set to execute when the object enters the Voided Off State a.k.a. Not Voided State. The pointer is set to nullptr when the object is instantiated.

Parameters
newFVPPWhnTrnOffArgPtrPointer to an argument to be passed to the function set to execute every time the object enters the Voided Off State a.k.a. Not Voided State.

◆ setFVPPWhnTrnOnVdd()

void VdblMPBttn::setFVPPWhnTrnOnVdd ( fncVdPtrPrmPtrType newFVPPWhnTrnOn,
void * argPtr = nullptr )

Sets a function to be executed every time the object enters the Voided On State a.k.a. Voided State.

The function to be executed must be of the form void (newFVPPWhnTrnOn)(void), meaning it must take a void pointer as argument and must return no value, it will be executed only once by the object (recursion must be handled with the usual precautions). When the object is instantiated the attribute value is set to nullptr.

Parameters
newFVPPWhnTrnOnFunction pointer to the function intended to be called when the object enters the Voided On State a.k.a. Voided State. Passing nullptr as parameter deactivates the function execution mechanism.
argPtrvoid pointer to an argument to be passed to the function when it is called.

◆ setFVPPWhnTrnOnVddArgPtr()

void VdblMPBttn::setFVPPWhnTrnOnVddArgPtr ( void * newFVPPWhnTrnOnArgPtr)

Sets a pointer to an argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.

The argument pointer is passed to the function set to execute when the object enters the Voided On State a.k.a. Voided State. The pointer is set to nullptr when the object is instantiated.

Parameters
newFVPPWhnTrnOnArgPtrPointer to an argument to be passed to the function set to execute every time the object enters the Voided On State a.k.a. Voided State.

◆ setIsNotVoided()

bool VdblMPBttn::setIsNotVoided ( )

Sets the value of the isVoided attribute flag to false.

Warning
The value of the isVoided attribute flag is computed as a result of the current state of the instantiated object, considering the inputs and embedded simulated behavior.
  • Arbitrarily setting a value to the isVoided attribute flag might affect the normal behavior path for the object.
  • The attribute flag value might return to it's natural value when the behavior imposes the change.
  • The use of this method must be limited to certain states and conditions of the object, being the most suitable situation while the object is in Disabled state: If the application development requires the isVoided attribute flag to be in a specific value, this method and the setIsVoided() method are the required tools.
Return values
true
Here is the caller graph for this function:

◆ setIsVoided()

bool VdblMPBttn::setIsVoided ( )

Sets the value of the isVoided attribute flag to true.

Warning
See the Warnings for setIsNotVoided()
Return values
true