| 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
TmLtchMPBttn Class Reference

Models a Timer Latch DD-MPB, a.k.a. Timer Switch (TiLDD-MPB). More...

`#include <ButtonToSwitch_ESP32.h>`

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

## Public Member Functions
| TmLtchMPBttn ()
| Default constructor.
| TmLtchMPBttn (const int8_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.
| TmLtchMPBttn (const TmLtchMPBttn &other)
| Copy constructor.
virtual | ~TmLtchMPBttn ()
| Class virtual destructor.
void | clrStatus (bool clrIsOn=true)
| see DbncdMPBttn::clrStatus(bool)
const unsigned long int | getSrvcTime () const
| Returns the configured Service Time.
bool | setSrvcTime (const unsigned long int &newSrvcTime)
| Sets a new value to the Service Time attribute.
void | setTmerRstbl (const bool &newIsRstbl)
| Configures the timer for the Service Time to be reseted before it reaches unlatching time.
Public Member Functions inherited from LtchMPBttn
| LtchMPBttn ()
| Default constructor.
| LtchMPBttn (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.
| LtchMPBttn (const LtchMPBttn &other)
| Copy constructor.
virtual | ~LtchMPBttn ()
| Class virtual destructor.
virtual bool | begin (const unsigned long int &pollDelayMs=_StdPollDelay)
| See DbncdMPBttn::begin(const unsigned long int)
void | clrStatus (bool clrIsOn=true)
| See DbncdMPBttn::clrStatus(bool)
const bool | getIsLatched () const
| Returns the value of the isLatched attribute flag, indicating the Latched or Unlatched condition of the object.
bool | getTrnOffASAP ()
| Returns the value of the trnOffASAP attribute flag.
const bool | getUnlatchPend () const
| Returns the value of the "Valid Unlatch Pending" attribute.
const bool | getUnlatchRlsPend () const
| Returns the value of the "Valid Unlatch Release Pending" attribute.
void | setTrnOffASAP (const bool &newVal)
| Sets the value of the trnOffASAP attribute.
void | setUnlatchPend (const bool &newVal)
| Sets the value of the "Valid Unlatch Pending" attribute.
void | setUnlatchRlsPend (const bool &newVal)
| Sets the value of the "Valid Unlatch Release Pending" attribute.
bool | unlatch ()
| Sets the values of the flags needed to unlatch a latched MPB.
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.
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 Timer Latch DD-MPB, a.k.a. Timer Switch (TiLDD-MPB).

The Timer switch keeps the On state since the moment the signal is stable (debouncing + delay process), and until the unlatch signal is provided by a preset timer started immediately after the MPB has passed the debounce & delay process. The time count down might be reset by pressing the MPB before the timer expires by optionally configuring the object to do so with the provided method. The total count-down time might be changed by using a provided method.

class TmLtchMPBttn

## Constructor & Destructor Documentation

## ◆ TmLtchMPBttn() [1/2]

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

Parameters

  srvcTime | The service time (time to keep the isOn attribute flag raised).

Note
  For the other 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:

## ◆ TmLtchMPBttn() [2/2]

TmLtchMPBttn::TmLtchMPBttn | ( | const TmLtchMPBttn & | other | ) |

Copy constructor.

Parameters

  other | Reference to an existing TmLtchMPBttn object to be copied.

Here is the call graph for this function:

## Member Function Documentation

## ◆ getSrvcTime()

const unsigned long int TmLtchMPBttn::getSrvcTime | ( |  | ) | const

Returns the configured Service Time.

Returns
  The current Service Time setting in milliseconds

## ◆ setSrvcTime()

bool TmLtchMPBttn::setSrvcTime | ( | const unsigned long int & | newSrvcTime | ) |

Sets a new value to the Service Time attribute.

Parameters

  newSrvcTime | New value for the Service Time attribute

Note
  To ensure a safe and predictable behavior from the instantiated objects a minimum Service Time setting guard is provided, ensuring data and signals processing are completed before unlatching process is enforced by the timer. The guard is set by the defined _MinSrvcTime constant.

Return values

  true | if the newSrvcTime parameter is equal to or greater than the minimum setting guard, the new value is set.
  false | The newSrvcTime parameter is less than the minimum setting guard, the srvcTime attribute was not changed.

Here is the caller graph for this function:

## ◆ setTmerRstbl()

void TmLtchMPBttn::setTmerRstbl | ( | const bool & | newIsRstbl | ) |

Configures the timer for the Service Time to be reseted before it reaches unlatching time.

If the isResetable attribute flag is cleared the MPB will return to Off state when the Service Time is reached no matter if the MPB was pressed again during the service time period. If the attribute flag is set, pressing the MPB (debounce and delay times enforced) while on the On state resets the timer, starting back from 0. The reseting might be repeated as many times as desired.

Parameters

  newIsRstbl | The new setting for the isResetable flag.