| ButtonToSwitch Library for Arduino v4.0.1 A library that provides elaborated switch mechanism behavior simulation for digital signals inputs

Loading...
Searching...
No Matches
Public Member Functions | List of all members
LtchMPBttn Class Referenceabstract

Abstract class, base to model Latched Debounced Delayed MPBs (LDD-MPB). More...

`#include <ButtonToSwitch.h>`

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

## Public Member Functions
| 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.
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 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.
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)
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 uint8_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.
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.
const unsigned long int | getLstPollTime ()
| Returns the time stamp of the last state update for the object.
const uint32_t | getOtptsSttsPkgd ()
| Returns the relevant attribute flags values for the object state encoded as a 32 bits value.
const bool | getOutputsChange () const
| Returns the value of the outputsChange attribute flag.
const unsigned long int | getPollPeriodMs ()
| Returns the poll period time setting attribute's value.
unsigned long int | getStrtDelay ()
| Returns the current value of strtDelay attribute.
bool | getUpdTmrAttchd ()
| Returns the value of the Attached to the update timer attribute.
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.
bool | pause ()
| Pauses the software timer updating the computation of the object's internal flags value (object's state).
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.
bool | setDbncTime (const unsigned long int &newDbncTime)
| Sets the debounce process time.
void | setFnWhnTrnOffPtr (void(*newFnWhnTrnOff)())
| Sets the function that will be called to execute every time the object enters the Off State.
void | setFnWhnTrnOnPtr (void(*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.
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).

## Detailed Description

Abstract class, base to model Latched Debounced Delayed MPBs (LDD-MPB).

Latched DD-MPBs are MPBs whose distinctive characteristic is that implement switches that keep the ON state since the moment the input signal is stable (debouncing + Delay process), and keeps the ON state after the MPB is released and until an event un-latches them, setting them free to move to the Off State. The un-latching mechanisms include but are not limited to: same MPB presses, timers, other MPB presses, other GPIO external un-latch signals or the use of the public method unlatch(). The different un-latching events defines the sub-classes of the LDD-MPB class.

Attention
  The range of signals accepted by the instantiated objects to execute the unlatch process is diverse, and their nature and characteristics might affect the expected switch behavior. While some of the signals might be instantaneous, meaning that the start of the unlatch signal is coincidental with the end of the unlatch signal, some others might extend the time between both ends. To accommodate the logic required by each subclass, and the requirements of each design, the **_unlatch_** process is then split into two stages:
  1. Validated Unlatch signal (or Validated Unlatch signal start).
  2. Validated Unlatch Release signal (or Validated Unlatch signal end). The class provides methods to generate those validated signals independently of the designated signal source to modify the instantiated object behavior if needed by the design requirements, Validated Unlatch signal (see LtchMPBttn::setUnlatchPend(const bool), Validated Unlatch Release signal (see LtchMPBttn::setUnlatchRlsPend(const bool), or to set both flags to generate an unlatch (see LtchMPBttn::unlatch().

Warning
  Generating the unlatch related flags independently of the unlatch signals provided by the LDD-MPB subclasses might result in unexpected behavior, which might generate the locking of the object with it's unexpected consequences.

## Constructor & Destructor Documentation

## ◆ LtchMPBttn()

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

Note
  For the parameters see DbncdDlydMPBttn(const uint8_t, const bool, const bool, const unsigned long int, const unsigned long int)

## Member Function Documentation

## ◆ getIsLatched()

const bool LtchMPBttn::getIsLatched | ( |  | ) | const

Returns the value of the isLatched attribute flag, indicating the Latched or Unlatched condition of the object.

The isLatched flag is automatically updated periodically by the timer that calculates the object state.

Return values

  true | the object is in Latched condition.
  false | The object is in Unlatched condition.

## ◆ getTrnOffASAP()

bool LtchMPBttn::getTrnOffASAP | ( |  | ) |

Returns the value of the trnOffASAP attribute flag.

As described in the class characteristics the unlatching process comprises two stages, Validated Unlatch Signal and Validated unlatch Release Signal, that might be generated simultaneously or separated in time. The trnOffASAP attribute flag sets the behavior of the MPB in the second case.

- If the trnOffASAP attribute flag is set (true) the isOn flag will be reset as soon as the Validated Unlatch signal start is detected
- If the trnOffASAP flag is reset (false) the isOn flag will be reset only when the Validated Unlatch signal end is detected.

Returns
  The current value of the trnOffASAP attribute flag.

## ◆ getUnlatchPend()

const bool LtchMPBttn::getUnlatchPend | ( |  | ) | const

Returns the value of the "Valid Unlatch Pending" attribute.

The "Valid Unlatch Pending" holds the existence of a still to be processed confirmed unlatch signal. Getting it's current value makes possible taking actions before the unlatch process is started or even discard it completely by using the setUnlatchPend(const bool) method.

Returns
  The current value of the "Valid Unlatch Pending" attribute.

## ◆ getUnlatchRlsPend()

const bool LtchMPBttn::getUnlatchRlsPend | ( |  | ) | const

Returns the value of the "Valid Unlatch Release Pending" attribute.

The "Valid Unlatch Release Pending" holds the existence of a still to be processed confirmed unlatch released signal. Getting it's current value makes possible taking actions before the unlatch process ends or even discard it completely by using the setUnlatchRlsPend(const bool) method.

Returns
  The current value of the "Valid Unlatch Release Pending" attribute.

## ◆ setTrnOffASAP()

void LtchMPBttn::setTrnOffASAP | ( | const bool & | newVal | ) |

Sets the value of the trnOffASAP attribute.

As explained in the class description, to accommodate to different sources of the unlatch signal, the unlatching process has been splitted in two steps:

1. Validated Unlatch signal (or Validated Unlatch signal start).
2. Validated Unlatch Release signal (or Validated Unlatch signal end). If trnOffASAP=true, the isOn attribute flag will be reset at the "Validated Unlatch Signal Start" stage. If trnOffASAP=false, the isOn attribute flag will be reset at the "Validated Unlatch Signal End" stage.

Parameters

  newVal | New value for the trnOffASAP attribute

## ◆ setUnlatchPend()

void LtchMPBttn::setUnlatchPend | ( | const bool & | newVal | ) |

Sets the value of the "Valid Unlatch Pending" attribute.

By setting the value of the "Valid Unlatch Pending" it's possible to modify the current MPB status by generating an unlatch signal or by canceling an existent unlatch signal.

Parameters

  newVal | New value for the "Valid Unlatch Pending" attribute

Here is the caller graph for this function:

## ◆ setUnlatchRlsPend()

void LtchMPBttn::setUnlatchRlsPend | ( | const bool & | newVal | ) |

Sets the value of the "Valid Unlatch Release Pending" attribute.

By setting the value of the "Valid Unlatch Pending" and "Valid Unlatch Release Pending" flags it's possible to modify the current MPB status by generating an unlatch signal or by canceling an existent unlatch signal.

Parameters

  newVal | New value for the "Valid Unlatch Release Pending" attribute

Here is the caller graph for this function:

## ◆ unlatch()

bool LtchMPBttn::unlatch | ( |  | ) |

Sets the values of the flags needed to unlatch a latched MPB.

By setting the values of the validUnlatchPending and validUnlatchReleasePending flags it's possible to modify the current MPB status by generating an unlatch signal.

Return values

  true | the object was latched and the unlatch flags were set.
  false | the object was not latched, no unlatch flags were set.

Note
  Setting the values of the validUnlatchPending and validUnlatchReleasePending flags does not implicate immediate unlatching the MPB but providing the unlatching signals. The unlatching signals will be processed by the MPB according to it's embedded behavioral pattern. For example, the signals will be processed if the MPB is in Enabled state and latched, but will be ignored if the MPB is disabled.

Here is the call graph for this function: