Debounce is intended for cleaning up incoming signals from e.g. Arduinos that represent switching buttons. Such buttons often produce occasional wrong values, reporting e.g. off when the switch is on. Debouncing filters such signals, requiring at least e.g. 5 positiv values before actually switching to on.
onFunc |
a function that runs when on condition is reached |
offFunc |
a function that runs when off condition is reached |
size |
the list of how many lastN values to keep |
get and set whether debounce is now on or not
enter next value, and if change of status happened, run onFunc or offFunc
val |
0 or 1 |
the current sum of lastN values
get and set size of the list of how many lastN values to keep
get and set function that triggers when debounce switches to on
get and set function that triggers when debounce switches to off
check whether to switch status
the last n values recorded