Arduino-Library-Button
Arduino-Library-Button copied to clipboard
Use dafault parameters
Instead of
//---------------------------------------------------- onPress
bool Button::onPress(void){
return _justPressed;
}
//------------------------------------------------ overload
bool Button::onPress(bool refreshPinData){
if (refreshPinData) {
listen();
return onPress();
} else {
return onPress();
}
}```
You can write just
Header: bool Button::onPress(bool refreshPinData=false); Source: bool Button::onPress(bool refreshPinData){ if (refreshPinData) { listen(); } return justPressed_; }``` Whic is much shorter and therefore much more readable. And calling to onPress(true) would be much faster.
Or pull https://github.com/carlynorama/Arduino-Library-Button/pull/3