fix after button hold, when button released triggers short press. Not yet tested

This commit is contained in:
interfisch 2019-12-12 21:46:31 +01:00
parent 3cc8457f07
commit a3a7122610
1 changed files with 4 additions and 4 deletions

View File

@ -383,7 +383,7 @@ void handleInputs()
timebuttonpressed_trigger=loopmillis; //set time of button press
timebuttonpressed_trigger_long=loopmillis; //set time of button press, for long hold timing
}else if(timebuttonpressed_trigger != 0 && digitalRead(PIN_TRIGGER)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD){ //short press
if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD && timebuttonpressed_trigger>0){ //short press
button_trigger=true;
}
timebuttonpressed_trigger=0; //re-enable after short press and release from hold
@ -402,7 +402,7 @@ void handleInputs()
if (timebuttonpressed_left == 0 && !digitalRead(PIN_BTNLEFT)){ //first time pressed down. (low when pressed)
timebuttonpressed_left=loopmillis; //set time of button press
}else if(timebuttonpressed_left != 0 && digitalRead(PIN_BTNLEFT)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD){ //short press
if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD && timebuttonpressed_left>0){ //short press
button_left=true;
}
timebuttonpressed_left=0; //re-enable after short press and release from hold
@ -415,7 +415,7 @@ void handleInputs()
if (timebuttonpressed_center == 0 && !digitalRead(PIN_BTNCENTER)){ //first time pressed down. (low when pressed)
timebuttonpressed_center=loopmillis; //set time of button press
}else if(timebuttonpressed_center != 0 && digitalRead(PIN_BTNCENTER)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD){ //short press
if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD && timebuttonpressed_center>0){ //short press
button_center=true;
}
timebuttonpressed_center=0; //re-enable after short press and release from hold
@ -428,7 +428,7 @@ void handleInputs()
if (timebuttonpressed_right == 0 && !digitalRead(PIN_BTNRIGHT)){ //first time pressed down. (low when pressed)
timebuttonpressed_right=loopmillis; //set time of button press
}else if(timebuttonpressed_right != 0 && digitalRead(PIN_BTNRIGHT)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD){ //short press
if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD && timebuttonpressed_right>0){ //short press
button_right=true;
}
timebuttonpressed_right=0; //re-enable after short press and release from hold