buttons: fix state detection

This commit is contained in:
Thomas Kolb 2024-05-18 00:08:37 +02:00
parent f89d7561ac
commit 8b0b03e0ee

View file

@ -32,8 +32,8 @@ void buttons_init(void)
void buttons_update_state(uint32_t time_ms)
{
for(int i = 0; i < NUM_BUTTONS; i++) {
bool is_pressed = gpio_get(m_pins[i]);
bool was_pressed = (m_states >> i) != 0;
bool is_pressed = !gpio_get(m_pins[i]); // buttons are active low
bool was_pressed = ((m_states >> i) & 0x1) != 0;
m_events[i] = 0;
if(is_pressed && !was_pressed) {