Made "pinMode" method extendable #42

Merged
nemoo2580 merged 1 commits from master into master 2018-02-05 19:20:40 +03:00
2 changed files with 9 additions and 6 deletions
+2 -6
View File
@@ -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)
+7
View File
@@ -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;}