Skip to content

Commit

Permalink
Merge pull request #42 from nemoo2580/master
Browse files Browse the repository at this point in the history
Made "setPinMode" method extendable
  • Loading branch information
thomasfredericks committed Feb 5, 2018
2 parents 3f9594d + 80d2912 commit 9901bf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Bounce2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ void Bounce::attach(int pin) {
}

void Bounce::attach(int pin, int mode){
#if defined(ARDUINO_STM_NUCLEO_F103RB) || defined(ARDUINO_GENERIC_STM32F103C)
pinMode(pin, (WiringPinMode)mode);
#else
pinMode(pin, mode);
#endif
this->attach(pin);
setPinMode(pin, mode);
this->attach(pin);
}

void Bounce::interval(uint16_t interval_millis)
Expand Down
7 changes: 7 additions & 0 deletions Bounce2.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ class Bounce
uint8_t state;
uint8_t pin;
virtual bool readCurrentState() { return digitalRead(pin); }
virtual void setPinMode(int pin, int mode) {
#if defined(ARDUINO_STM_NUCLEO_F103RB) || defined(ARDUINO_GENERIC_STM32F103C)
pinMode(pin, (WiringPinMode)mode);
#else
pinMode(pin, mode);
#endif
}

private:
inline void setStateFlag(const uint8_t flag) {state |= flag;}
Expand Down

0 comments on commit 9901bf1

Please sign in to comment.