Debouncer.cpp

Debouncer.cpp#

Description#

Functions#

Name

Description

Debouncer

Constructs a Debouncer with a specified delay in milliseconds. It is recommended to use a pointer. Default active high.

debounce

Must be called regularly (i.e., in a loop). Wrap your call to check your button/sensor in this. Takes only an input of 0 or 1, and outputs a 0 or 1.

isActive

Returns the “current” debounced state of the button.

wasToggled

Should be used to enable execution of an action once when the button is toggled after debouncing. In other words, it checks whether the button has changed debounced state.I t is assumed that debounce() is being called regularly

debounceAndToggled

Should be used to enable execution of an action once when the button is toggled after debouncing. Calls both debounce() and wasToggled() consecutively to avoid potential misses.

wasSwitchedToState

Should be used to enable execution of an action when switched to a specific state after debouncing. Calls wasToggled() and checks it against the passed state parameter.

debounceAndSwitchedTo

Should be used to enable execution of an action when switched to a specific state after debouncing. Calls both debounce() and wasSwitchedToState() consecutively to avoid potential misses. Not as useful as debounceAndPressed() because usually you have no reason to switch based on the inactive state.

debounceAndPressed

Usually you will use this function. Should be used to enable execution of an action when a button has been pressed (after debouncing). It is assumed that the “active” state of the button corresponds to the “pressed” state. Shorthand for debounceAndSwitchesTo(inputState, active). Calls both debounce() and wasSwitchedToState() automatically.

Included Headers#