diff --git a/firmware/src/main.c b/firmware/src/main.c index 29e7447..27add27 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -691,6 +691,9 @@ static void update_state(const enum input event) { ISR(PCINT0_vect) { cli(); + // Dechatter + _delay_ms(3); + switch (enc) { case 0: if (ENC_A && !ENC_B) @@ -724,9 +727,6 @@ ISR(PCINT0_vect) { break; } - // TODO: proper dechattering - _delay_ms(3); - sei(); } @@ -734,6 +734,9 @@ ISR(PCINT0_vect) { ISR(PCINT1_vect) { cli(); + // Debounce + _delay_ms(2); + if (PINC & (1 << PC0)) { // Release if (TCCR1B & (1 << CS10)) // If release before hold update_state(click); // Switch to selected state @@ -745,9 +748,6 @@ ISR(PCINT1_vect) { TCCR1B |= (1 << CS11) | (1 << CS10); // Enable Timer/Counter1 } - // TODO: Proper debouncing - _delay_ms(3); - sei(); }