ButtonToSwitch Library for ESP32 (Arduino) v4.4.0
A library that provides elaborated switch mechanism behavior simulation for digital signals inputs
Loading...
Searching...
No Matches
TmVdblMPBttn Class Reference

Models a Time Voidable DD-MPB, a.k.a. Anti-tampering switch (TVDD-MPB) More...

#include <ButtonToSwitch_ESP32.h>

Inheritance diagram for TmVdblMPBttn:
Collaboration diagram for TmVdblMPBttn:

Public Member Functions

 TmVdblMPBttn ()
 Default constructor.
 
 TmVdblMPBttn (const int8_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.
 
virtual ~TmVdblMPBttn ()
 Class virtual destructor.
 
virtual bool begin (const unsigned long int &pollDelayMs=_StdPollDelay)
 See DbncdMPBttn::begin(const unsigned long int)
 
void clrStatus ()
 See DbncdMPBttn::clrStatus(bool)
 
const unsigned long int getVoidTime () const
 Returns the voidTime attribute current value.
 
bool setVoidTime (const unsigned long int &newVoidTime)
 Sets a new value to the Void Time attribute.
 
- 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.
 
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.
 
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.
 
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.
 
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 the function that is set to execute every time the object enters the Off State.
 
fncPtrType getFnWhnTrnOn ()
 Returns the function that is 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 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 the outputs change task unblocking trigger (outputsChngTskTrggr) attribute flag.
 
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 ()
 Resets the outputs change task unblocking trigger (outputsChngTskTrggr) attribute flag.
 
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 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

Models a Time Voidable DD-MPB, a.k.a. Anti-tampering switch (TVDD-MPB)

The Time Voidable Momentary Push Button keeps the On state since the moment the signal is stable (debounce & delay process) and until the moment the push button is released, or until a preset time in the On state is reached. Then the switch will return to the Off position until the push button is released and pushed back. This kind of switches are used to activate limited resources related management or physical safety devices, and the possibility of a physical blocking of the switch to extend the ON signal forcibly beyond designer's plans is highly undesired. Water valves, door unlocking mechanisms, hands-off security mechanisms, high power heating devices are some of the usual uses for these type of switches.

class TmVdblMPBttn

Constructor & Destructor Documentation

◆ TmVdblMPBttn()

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

Parameters
voidTimeThe time -in milliseconds- the MPB must be pressed to enter the voided state.
Note
For the rest of the parameters see VdblMPBttn(const int8_t, const bool, const bool, const unsigned long int, const unsigned long int, const bool)

Member Function Documentation

◆ getVoidTime()

const unsigned long int TmVdblMPBttn::getVoidTime ( ) const

Returns the voidTime attribute current value.

The voidTime attribute holds the time -in milliseconds- the MPB must be pressed to enter the voided state.

Returns
The current value of the voidTime attribute.

◆ setVoidTime()

bool TmVdblMPBttn::setVoidTime ( const unsigned long int & newVoidTime)

Sets a new value to the Void Time attribute.

Parameters
newVoidTimeNew value for the Void Time attribute
Note
To ensure a safe and predictable behavior from the instantiated objects a minimum Void Time (equal to the minimum Service Time) setting guard is provided, ensuring data and signals processing are completed before voiding process is enforced by the timer. The guard is set by the defined _MinSrvcTime constant.
Return values
true if the newVoidTime parameter is equal to or greater than the minimum setting guard. The attribute value is changed.
false otherwise. The attribute value is not changed.