From e375586804fadbeb4dc1b7ced763247f2bb14867 Mon Sep 17 00:00:00 2001 From: Tom-on64 Date: Fri, 24 Apr 2026 16:57:38 +0200 Subject: [PATCH] Made buttons work V2 --- buttons.c | 8 ++++++-- buttons.h | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/buttons.c b/buttons.c index 0992f7e..8710d2c 100644 --- a/buttons.c +++ b/buttons.c @@ -4,8 +4,11 @@ #include #include "hardware/gpio.h" -void handle_vco_change(uint gpio, uint32_t events) { - if (gpio == VCO_BUTTON && (events & GPIO_IRQ_EDGE_RISE)) { +void handle_vco_change(void) { + static bool btn_prev = false; + + bool btn_now = gpio_get(VCO_BUTTON); + if (btn_now && !btn_prev) { if (state.vco_mode == VCO_SAW) state.vco_mode = VCO_SINE; otherwise state.vco_mode++; } @@ -18,4 +21,5 @@ void update_button(uint pin, bool *button_state) { void update_buttons() { update_button(QUANT_BUTTON, &state.quant_enabled); update_button(AMEN_BUTTON, &state.amen_enabled); + handle_vco_change(); } diff --git a/buttons.h b/buttons.h index 47a4a21..4de50ea 100644 --- a/buttons.h +++ b/buttons.h @@ -1,3 +1,7 @@ #pragma once #include -void handle_vco_change(uint gpio, uint32_t events); \ No newline at end of file + +void handle_vco_change(uint gpio, uint32_t events); +void update_button(uint pin, bool *button_state); +void update_buttons(); +