Skip to content

Commit

Permalink
Update DebounceSwitch.h
Browse files Browse the repository at this point in the history
Simplify class variable initialization; re-order.
  • Loading branch information
bdubs-astro authored Jul 24, 2021
1 parent bc68ab8 commit 29158af
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions DebounceSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 49,24 @@ bdubs, 7-Jul-2021
class DebounceSwitch {

public:
DebounceSwitch(const int _pin, bool _intPullup, void (*_loCallback)(void), void (*_hiCallback)(void)) {
DebounceSwitch(const int _pin, bool _intPullup, void (*_loCallback)(void), void (*_hiCallback)(void)):
intPullup(_intPullup), pin(_pin), loCallback(_loCallback), hiCallback(_hiCallback) {

pin = _pin;
intPullup = _intPullup;
loCallback = _loCallback;
hiCallback = _hiCallback;

// configure input pin
if (intPullup)
pinMode(pin,INPUT_PULLUP); // use internal pullup resistor
else
pinMode(pin,INPUT);
// configure input pin
if (intPullup)
pinMode(pin, INPUT_PULLUP); // use internal pullup resistor
else
pinMode(pin, INPUT);
}

bool initPin();
bool readPin(int debounceDelay);

private:
bool intPullup;
int pin;
void (*loCallback)(void);
void (*hiCallback)(void);
int pin;
bool intPullup;
bool reading;
bool currState;
bool prevState;
Expand Down

0 comments on commit 29158af

Please sign in to comment.