Library for debouncing inputs, originally by Andres Mora Bedoya. Updated to include PinMode capability and class documentation.
Fork of DebouncedIn by
DebouncedIn Class Reference
DebouncedIn object, uses software tickers to debounce mechanical inputs. More...
#include <DebouncedIn.h>
Public Member Functions | |
DebouncedIn (PinName in) | |
Create a DebouncedIn connected to the specified pin. | |
DebouncedIn (PinName in, PinMode mode) | |
Same as before, with option to specify pin mode. | |
int | read (void) |
Read the input state, represented as 0 or 1 (int) | |
operator int () | |
An operator shorthand for read() | |
int | rising (void) |
Rising edge count (int) | |
int | falling (void) |
Falling edge count (int) | |
int | steady (void) |
Steady state tick count (int) |
Detailed Description
DebouncedIn object, uses software tickers to debounce mechanical inputs.
Definition at line 15 of file DebouncedIn.h.
Constructor & Destructor Documentation
DebouncedIn | ( | PinName | in ) |
Create a DebouncedIn connected to the specified pin.
- Parameters:
-
in DigitalIn pin to connect to
Definition at line 9 of file DebouncedIn.cpp.
DebouncedIn | ( | PinName | in, |
PinMode | mode | ||
) |
Same as before, with option to specify pin mode.
- Parameters:
-
in DigitalIn pin to connect to mode (optional) Set pull mode - PullUp, PullDown, PullNone, OpenDrain
Definition at line 24 of file DebouncedIn.cpp.
Member Function Documentation
int falling | ( | void | ) |
Falling edge count (int)
- Returns:
- An integer representing the number of times the switch has changed from high to low. Count resets to zero when this function is called.
Definition at line 57 of file DebouncedIn.cpp.
operator int | ( | ) |
An operator shorthand for read()
Definition at line 45 of file DebouncedIn.cpp.
int read | ( | void | ) |
Read the input state, represented as 0 or 1 (int)
- Returns:
- An integer representing the state of the input pin, 0 for logical 0, 1 for logical 1. State changes when input has been steady for at least 40ms (8 ticker cycles of 5ms).
Definition at line 41 of file DebouncedIn.cpp.
int rising | ( | void | ) |
Rising edge count (int)
- Returns:
- An integer representing the number of times the switch has changed from low to high. Count resets to zero when this function is called.
Definition at line 50 of file DebouncedIn.cpp.
int steady | ( | void | ) |
Steady state tick count (int)
- Returns:
- An integer representing how many ticker cycles the input has been steady for. Ticker cycles every 5ms.
Definition at line 64 of file DebouncedIn.cpp.
Generated on Sun Jul 24 2022 09:39:58 by 1.7.2