Updated PushButton() so that longPresses always repeat
No need for any new methods - default is now that longPress repeats every longTime milliseconds provided button continues to be held down. Once a longPress is triggered, a shortPress will not be triggered until button is released.
This commit is contained in:
parent
77c48dcf46
commit
7ecff55f9c
|
|
@ -94,7 +94,7 @@ void setup() {
|
|||
new SpanAccessory();
|
||||
new DEV_Identify("PushButton LED","HomeSpan","123-ABC","20mA LED","0.9",0);
|
||||
|
||||
new DEV_DimmableLED(0,17,23,5,18); // NEW! added three extra arguments to specific the pin numbers for three SpanButtons() - see DEV_LED.h
|
||||
new DEV_DimmableLED(0,17,23,5,18); // NEW! added three extra arguments to specify the pin numbers for three SpanButtons() - see DEV_LED.h
|
||||
|
||||
} // end of setup()
|
||||
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ boolean PushButton::triggered(uint16_t shortTime, uint16_t longTime){
|
|||
} else
|
||||
|
||||
if(millis()>longAlarm){ // button is long-pressed
|
||||
longAlarm=millis()+longTime;
|
||||
status=3;
|
||||
isLongPress=true;
|
||||
return(true);
|
||||
|
|
@ -108,6 +109,11 @@ boolean PushButton::triggered(uint16_t shortTime, uint16_t longTime){
|
|||
case 3:
|
||||
if(digitalRead(pin)) // button has been released after a long press
|
||||
status=0;
|
||||
else if(millis()>longAlarm){
|
||||
longAlarm=millis()+longTime;
|
||||
isLongPress=true;
|
||||
return(true);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue