Debounce the rest of the buttons

This commit is contained in:
Jasper Blanckenburg 2022-03-13 18:15:41 +01:00
parent 7c2e245796
commit 0eeafa9393
2 changed files with 16 additions and 3 deletions

View File

@ -51,13 +51,22 @@ void read_buttons(){
Stw_data.Stw_shift_down = debouncer[4].rose();
Stw_data.Stw_shift_up = debouncer[5].rose();
// These are also used for GUI, so if we set them only at rising edge, they
// might never be high when checked in the GUI.
// TODO: Rewrite so we can use debounced values here as well
Stw_data.buttonState1 = digitalRead(button1);
Stw_data.buttonState4 = digitalRead(button4);
Stw_data.buttonStateEnc1 = digitalRead(enc1PinS);
Stw_data.buttonStateEnc2 = digitalRead(enc2PinS);
if (debouncer[0].rose()) {
Stw_data.button1_rises++;
}
if (debouncer[3].rose()) {
Stw_data.button4_rises++;
}
if (debouncer[6].rose()) {
Stw_data.enc1_rises++;
}
if (debouncer[7].rose()) {
Stw_data.enc2_rises++;
}
}
void read_rotary(){

View File

@ -69,6 +69,10 @@ typedef struct
uint8_t trc;
uint8_t mode;
uint8_t button1_rises;
uint8_t button4_rises;
uint8_t enc1_rises;
uint8_t enc2_rises;
} stw_data_type;
typedef struct