Closed jfig closed 8 years ago
@jfig there isn't a public method available to find out how long the button was pressed, but we can find out like this:
#include <RBD_Timer.h> // https://github.com/alextaujenis/RBD_Timer
#include <RBD_Button.h> // https://github.com/alextaujenis/RBD_Button
// input pullup enabled by default
RBD::Button button(2);
RBD::Timer pressed_timer;
void setup() {
Serial.begin(115200);
}
void loop() {
if(button.onPressed()) {
pressed_timer.restart();
}
if(button.onReleased()) {
Serial.println(pressed_timer.getValue());
}
}
is it possible to know, after onReleased() and without tracking isPressed(), how long was the button pressed?
(thanks for the great library)