sint-gauntlet/buttons.c
2026-04-25 09:07:02 +02:00

25 lines
638 B
C

#include "const.h"
#include "state.h"
#include "vco.h"
#include <pico/types.h>
#include "hardware/gpio.h"
void check_button_change(uint pin, bool* btn_state) {
static bool btn_prev[32] = { false };
bool btn_now = gpio_get(pin);
if (btn_now && !btn_prev[pin]) *btn_state = !*btn_state;
btn_prev[pin] = btn_now;
}
void update_buttons() {
check_button_change(QUANT_BUTTON, &state.quant_enabled);
check_button_change(AMEN_BUTTON, &state.amen_enabled);
bool vco_change;
check_button_change(VCO_BUTTON, &vco_change);
if (vco_change) {
if (state.vco_mode == VCO_SAW) state.vco_mode = VCO_SINE;
otherwise state.vco_mode++;
}
}