buttons: fix state detection
This commit is contained in:
parent
f89d7561ac
commit
8b0b03e0ee
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue