fix missing debouncing time updates. not yet tested

This commit is contained in:
interfisch 2019-12-12 22:12:25 +01:00
parent 767ffc188b
commit 107352737b
1 changed files with 8 additions and 0 deletions

View File

@ -382,11 +382,13 @@ void handleInputs()
if (timebuttonpressed_trigger == 0 && !digitalRead(PIN_TRIGGER)){ //first time pressed down. (low when pressed)
timebuttonpressed_trigger=loopmillis; //set time of button press
timebuttonpressed_trigger_long=loopmillis; //set time of button press, for long hold timing
millis_lastinput=millis(); //for debouncing
}else if(timebuttonpressed_trigger != 0 && digitalRead(PIN_TRIGGER)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD){ //short press
button_trigger=true;
}
timebuttonpressed_trigger=0; //re-enable after short press and release from hold
millis_lastinput=millis(); //for debouncing
}else if(loopmillis-timebuttonpressed_trigger >= BUTTONTIMEHOLD && timebuttonpressed_trigger>0){ //held down long enough and not already hold triggered
button_hold_trigger=true;
timebuttonpressed_trigger=-1; //-1 as flag for hold triggered
@ -401,11 +403,13 @@ void handleInputs()
//Left
if (timebuttonpressed_left == 0 && !digitalRead(PIN_BTNLEFT)){ //first time pressed down. (low when pressed)
timebuttonpressed_left=loopmillis; //set time of button press
millis_lastinput=millis(); //for debouncing
}else if(timebuttonpressed_left != 0 && digitalRead(PIN_BTNLEFT)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD){ //short press
button_left=true;
}
timebuttonpressed_left=0; //re-enable after short press and release from hold
millis_lastinput=millis(); //for debouncing
}else if(loopmillis-timebuttonpressed_left >= BUTTONTIMEHOLD && timebuttonpressed_left>0){ //held down long enough and not already hold triggered
button_hold_left=true;
timebuttonpressed_left=-1; //-1 as flag for hold triggered
@ -414,11 +418,13 @@ void handleInputs()
//Center
if (timebuttonpressed_center == 0 && !digitalRead(PIN_BTNCENTER)){ //first time pressed down. (low when pressed)
timebuttonpressed_center=loopmillis; //set time of button press
millis_lastinput=millis(); //for debouncing
}else if(timebuttonpressed_center != 0 && digitalRead(PIN_BTNCENTER)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD){ //short press
button_center=true;
}
timebuttonpressed_center=0; //re-enable after short press and release from hold
millis_lastinput=millis(); //for debouncing
}else if(loopmillis-timebuttonpressed_center >= BUTTONTIMEHOLD && timebuttonpressed_center>0){ //held down long enough and not already hold triggered
button_hold_center=true;
timebuttonpressed_center=-1; //-1 as flag for hold triggered
@ -427,11 +433,13 @@ void handleInputs()
//Right
if (timebuttonpressed_right == 0 && !digitalRead(PIN_BTNRIGHT)){ //first time pressed down. (low when pressed)
timebuttonpressed_right=loopmillis; //set time of button press
millis_lastinput=millis(); //for debouncing
}else if(timebuttonpressed_right != 0 && digitalRead(PIN_BTNRIGHT)){ //button released (was pressed)
if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD){ //short press
button_right=true;
}
timebuttonpressed_right=0; //re-enable after short press and release from hold
millis_lastinput=millis(); //for debouncing
}else if(loopmillis-timebuttonpressed_right >= BUTTONTIMEHOLD && timebuttonpressed_right>0){ //held down long enough and not already hold triggered
button_hold_right=true;
timebuttonpressed_right=-1; //-1 as flag for hold triggered