From 98f4a1d0ad60371cf0682dbd7ae884db352ce30a Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Fri, 17 Mar 2023 14:30:56 +0100 Subject: [PATCH] Use rising edges for encoder checks This seems to be more robust --- Core/Src/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Src/ui.c b/Core/Src/ui.c index 21f3aec..8205f48 100644 --- a/Core/Src/ui.c +++ b/Core/Src/ui.c @@ -75,8 +75,8 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { last_state[idx_a] = state_a; last_state[idx_b] = state_b; - if (state_a == GPIO_PIN_RESET && state_b == GPIO_PIN_RESET) { - // Second falling edge, direction depends on which pin changed last + if (state_a == GPIO_PIN_SET && state_b == GPIO_PIN_SET) { + // Second rising edge, direction depends on which pin changed last if (a_changed && b_changed) { // This shouldn't happen. Ignore this event. last_change[idx_a] = now;