File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ void setup() {
1919 // Typical usage: with a normal digital input
2020 button = new DebounceFilter (filter_functions::ForDigitalRead<kButtonPin >());
2121
22+ // For an inverted input, e.g. when using a button with a pullup resistor
23+ button = new DebounceFilter (filter_functions::ForInvertedDigitalRead<kButtonPin >());
24+
2225 // Advanced usage: custom input function
2326 button = new DebounceFilter (readButtonPin);
2427
Original file line number Diff line number Diff line change @@ -181,6 +181,11 @@ static bool (*ForDigitalRead())() {
181181 return []() { return (bool )digitalRead (pin); };
182182}
183183
184+ template <uint32_t pin>
185+ static bool (*ForInvertedDigitalRead ())() {
186+ return []() { return (bool )!digitalRead (pin); };
187+ }
188+
184189template <uint32_t pin>
185190static uint32_t (*ForAnalogRead ())() {
186191 return []() { return (uint32_t )analogRead (pin); };
You can’t perform that action at this time.
0 commit comments