Made buttons work V2

This commit is contained in:
Tom-on64 2026-04-24 16:57:38 +02:00
parent d5933cd060
commit e375586804
2 changed files with 11 additions and 3 deletions

View File

@ -4,8 +4,11 @@
#include <pico/types.h> #include <pico/types.h>
#include "hardware/gpio.h" #include "hardware/gpio.h"
void handle_vco_change(uint gpio, uint32_t events) { void handle_vco_change(void) {
if (gpio == VCO_BUTTON && (events & GPIO_IRQ_EDGE_RISE)) { 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; if (state.vco_mode == VCO_SAW) state.vco_mode = VCO_SINE;
otherwise state.vco_mode++; otherwise state.vco_mode++;
} }
@ -18,4 +21,5 @@ void update_button(uint pin, bool *button_state) {
void update_buttons() { void update_buttons() {
update_button(QUANT_BUTTON, &state.quant_enabled); update_button(QUANT_BUTTON, &state.quant_enabled);
update_button(AMEN_BUTTON, &state.amen_enabled); update_button(AMEN_BUTTON, &state.amen_enabled);
handle_vco_change();
} }

View File

@ -1,3 +1,7 @@
#pragma once #pragma once
#include <pico/types.h> #include <pico/types.h>
void handle_vco_change(uint gpio, uint32_t events);
void handle_vco_change(uint gpio, uint32_t events);
void update_button(uint pin, bool *button_state);
void update_buttons();