| ButtonToSwitch Library for ESP32 (Arduino) v4.6.1 A library that provides elaborated switch mechanism behavior simulation for digital signals inputs

Loading...
Searching...
No Matches
SnglSrvcVdblMPBttn Class Reference

Models a Single Service Voidable DD-MPB a.k.a. Trigger switch (SSVDD-MPB) More...

`#include <ButtonToSwitch_ESP32.h>`

Inheritance diagram for SnglSrvcVdblMPBttn:
[legend]
Collaboration diagram for SnglSrvcVdblMPBttn:
[legend]

## Public Member Functions
| SnglSrvcVdblMPBttn ()
| Default constructor.
| SnglSrvcVdblMPBttn (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.
virtual | ~SnglSrvcVdblMPBttn ()
| Class virtual destructor.
virtual bool | begin (const unsigned long int &pollDelayMs=_StdPollDelay)
| See DbncdMPBttn::begin(const unsigned long int)
Public Member Functions inherited from VdblMPBttn
| 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.
virtual | ~VdblMPBttn ()
| Default virtual destructor.
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 | getFrcOtptLvlWhnVdd ()
| 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 | getStOnWhnOtpFrcd ()
| 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 (const DbncdDlydMPBttn &other)
| Copy constructor.
virtual | ~DbncdDlydMPBttn ()
| Class destructor.
bool | init (const int8_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 int8_t, const bool, const bool, const unsigned long int)
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 (const DbncdMPBttn &other)
| Copy constructor.
virtual | ~DbncdMPBttn ()
| Default virtual 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.
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 DbncdMPBttn * | getMpbInstnc () 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 | init (const int8_t &mpbttnPin, const bool &pulledUp=true, const bool &typeNO=true, const unsigned long int &dbncTimeOrigSett=0)
| Initializes an object instantiated by the default constructor.
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.

## Protected Member Functions
virtual void | setTaskWhileOn (const TaskHandle_t &newTaskHandle)
| Sets the task to be run while the object is in the On state.

## Detailed Description

Models a Single Service Voidable DD-MPB a.k.a. Trigger switch (SSVDD-MPB)

The Single Service Voidable Momentary Push Button keeps the On state since the moment the signal is stable (debounce & delay process) and until the moment the provided mechanisms implemented to be executed when the switch enters the On State are started, that means calling the fnWhnTrnOn function, notifying the taskToNotify task and setting the isOn attribute flag. After the configured mechanisms are triggered and the attribute flag is set to true (the only mandatory action is the attribute flag setting, all the others are configurable to execute or not) the MPB will enter the Voided State, forcing the MPB into the Off State. The SnglSrvcVdblMPBttn class objects requires the MPB to be released to exit the Voided State, restarting the cycle. This kind of switches are used to handle "Single Shot Trigger" style signals, ensuring one single signal per push.

Attention
  Depending on checking the isOn flag reading trough the getIsOn() method might surely fail due to the high risk of missing the short time the flag will be raised before it is again taken down by the voidance of the MPB. The use of the non-polling facilities ensures no loss of signals and enough time to execute the code depending on the "trigger activation", including the fnWhnTrnOn function, and the taskToNotify task.

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.
  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.

## Constructor & Destructor Documentation

## ◆ SnglSrvcVdblMPBttn()

SnglSrvcVdblMPBttn::SnglSrvcVdblMPBttn | ( | 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.

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:

## Member Function Documentation

## ◆ setTaskWhileOn()

void SnglSrvcVdblMPBttn::setTaskWhileOn | ( | const TaskHandle_t & | newTaskHandle | ) |
| protected virtual

Sets the task to be run while the object is in the On state.

Sets the task handle of the task to be resumed when the object enters the On state, and will be paused when the object enters the Off state. This task execution mechanism dependent of the On state extends the concept of the Switch object far away of the simple turning On/Off a single hardware signal, attaching to it all the task execution capabilities of the MCU.

If the existing value for the task handle was not NULL before the invocation, the method will verify the Task Handle was pointing to a deleted or suspended task, in which case will proceed to suspend that task before changing the Task Handle to the new provided value.

Setting the value to NULL will disable the task execution mechanism.

Note
  The method does not implement any task handle validation for the new task handle, a valid handle to a valid task is assumed as parameter.
  Consider the implications of the task that's going to get suspended every time the MPB goes to the Off state, so that the the task to be run might be interrupted at any point of its execution. This implies that the task must be designed with that consideration in mind to avoid dangerous situations generated by a task not completely done when suspended.

Warning
  Take special consideration about the implications of the execution priority of the task to be executed while the MPB is in On state and its relation to the priority of the calling task, as it might affect the normal execution of the application.

Reimplemented from DbncdMPBttn.