fix missing debouncing time updates. not yet tested
This commit is contained in:
parent
767ffc188b
commit
107352737b
|
@ -382,11 +382,13 @@ void handleInputs()
|
||||||
if (timebuttonpressed_trigger == 0 && !digitalRead(PIN_TRIGGER)){ //first time pressed down. (low when pressed)
|
if (timebuttonpressed_trigger == 0 && !digitalRead(PIN_TRIGGER)){ //first time pressed down. (low when pressed)
|
||||||
timebuttonpressed_trigger=loopmillis; //set time of button press
|
timebuttonpressed_trigger=loopmillis; //set time of button press
|
||||||
timebuttonpressed_trigger_long=loopmillis; //set time of button press, for long hold timing
|
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)
|
}else if(timebuttonpressed_trigger != 0 && digitalRead(PIN_TRIGGER)){ //button released (was pressed)
|
||||||
if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD){ //short press
|
if (loopmillis-timebuttonpressed_trigger < BUTTONTIMEHOLD){ //short press
|
||||||
button_trigger=true;
|
button_trigger=true;
|
||||||
}
|
}
|
||||||
timebuttonpressed_trigger=0; //re-enable after short press and release from hold
|
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
|
}else if(loopmillis-timebuttonpressed_trigger >= BUTTONTIMEHOLD && timebuttonpressed_trigger>0){ //held down long enough and not already hold triggered
|
||||||
button_hold_trigger=true;
|
button_hold_trigger=true;
|
||||||
timebuttonpressed_trigger=-1; //-1 as flag for hold triggered
|
timebuttonpressed_trigger=-1; //-1 as flag for hold triggered
|
||||||
|
@ -401,11 +403,13 @@ void handleInputs()
|
||||||
//Left
|
//Left
|
||||||
if (timebuttonpressed_left == 0 && !digitalRead(PIN_BTNLEFT)){ //first time pressed down. (low when pressed)
|
if (timebuttonpressed_left == 0 && !digitalRead(PIN_BTNLEFT)){ //first time pressed down. (low when pressed)
|
||||||
timebuttonpressed_left=loopmillis; //set time of button press
|
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)
|
}else if(timebuttonpressed_left != 0 && digitalRead(PIN_BTNLEFT)){ //button released (was pressed)
|
||||||
if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD){ //short press
|
if (loopmillis-timebuttonpressed_left < BUTTONTIMEHOLD){ //short press
|
||||||
button_left=true;
|
button_left=true;
|
||||||
}
|
}
|
||||||
timebuttonpressed_left=0; //re-enable after short press and release from hold
|
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
|
}else if(loopmillis-timebuttonpressed_left >= BUTTONTIMEHOLD && timebuttonpressed_left>0){ //held down long enough and not already hold triggered
|
||||||
button_hold_left=true;
|
button_hold_left=true;
|
||||||
timebuttonpressed_left=-1; //-1 as flag for hold triggered
|
timebuttonpressed_left=-1; //-1 as flag for hold triggered
|
||||||
|
@ -414,11 +418,13 @@ void handleInputs()
|
||||||
//Center
|
//Center
|
||||||
if (timebuttonpressed_center == 0 && !digitalRead(PIN_BTNCENTER)){ //first time pressed down. (low when pressed)
|
if (timebuttonpressed_center == 0 && !digitalRead(PIN_BTNCENTER)){ //first time pressed down. (low when pressed)
|
||||||
timebuttonpressed_center=loopmillis; //set time of button press
|
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)
|
}else if(timebuttonpressed_center != 0 && digitalRead(PIN_BTNCENTER)){ //button released (was pressed)
|
||||||
if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD){ //short press
|
if (loopmillis-timebuttonpressed_center < BUTTONTIMEHOLD){ //short press
|
||||||
button_center=true;
|
button_center=true;
|
||||||
}
|
}
|
||||||
timebuttonpressed_center=0; //re-enable after short press and release from hold
|
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
|
}else if(loopmillis-timebuttonpressed_center >= BUTTONTIMEHOLD && timebuttonpressed_center>0){ //held down long enough and not already hold triggered
|
||||||
button_hold_center=true;
|
button_hold_center=true;
|
||||||
timebuttonpressed_center=-1; //-1 as flag for hold triggered
|
timebuttonpressed_center=-1; //-1 as flag for hold triggered
|
||||||
|
@ -427,11 +433,13 @@ void handleInputs()
|
||||||
//Right
|
//Right
|
||||||
if (timebuttonpressed_right == 0 && !digitalRead(PIN_BTNRIGHT)){ //first time pressed down. (low when pressed)
|
if (timebuttonpressed_right == 0 && !digitalRead(PIN_BTNRIGHT)){ //first time pressed down. (low when pressed)
|
||||||
timebuttonpressed_right=loopmillis; //set time of button press
|
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)
|
}else if(timebuttonpressed_right != 0 && digitalRead(PIN_BTNRIGHT)){ //button released (was pressed)
|
||||||
if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD){ //short press
|
if (loopmillis-timebuttonpressed_right < BUTTONTIMEHOLD){ //short press
|
||||||
button_right=true;
|
button_right=true;
|
||||||
}
|
}
|
||||||
timebuttonpressed_right=0; //re-enable after short press and release from hold
|
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
|
}else if(loopmillis-timebuttonpressed_right >= BUTTONTIMEHOLD && timebuttonpressed_right>0){ //held down long enough and not already hold triggered
|
||||||
button_hold_right=true;
|
button_hold_right=true;
|
||||||
timebuttonpressed_right=-1; //-1 as flag for hold triggered
|
timebuttonpressed_right=-1; //-1 as flag for hold triggered
|
||||||
|
|
Loading…
Reference in New Issue