Made buttons work
This commit is contained in:
parent
061ca37ad7
commit
d5933cd060
15
buttons.c
15
buttons.c
@ -4,25 +4,18 @@
|
||||
#include <pico/types.h>
|
||||
#include "hardware/gpio.h"
|
||||
|
||||
|
||||
void handle_vco_change(uint gpio, uint32_t events) {
|
||||
if (gpio == VCO_BUTTON && (events & GPIO_IRQ_EDGE_RISE)) {
|
||||
if (state.vco_mode == VCO_SAW) {
|
||||
state.vco_mode = VCO_SINE;
|
||||
} otherwise {
|
||||
state.vco_mode++;
|
||||
}
|
||||
if (state.vco_mode == VCO_SAW) state.vco_mode = VCO_SINE;
|
||||
otherwise state.vco_mode++;
|
||||
}
|
||||
}
|
||||
|
||||
void update_button(uint pin, bool *button_state) {
|
||||
if(gpio_get(pin) != *button_state) {
|
||||
*button_state=!*button_state;
|
||||
}
|
||||
if(gpio_get(pin) != *button_state) *button_state = !*button_state;
|
||||
}
|
||||
|
||||
void update_buttons() {
|
||||
update_button(QUANT_BUTTON, &state.quant_enabled);
|
||||
|
||||
|
||||
update_button(AMEN_BUTTON, &state.amen_enabled);
|
||||
}
|
||||
10
main.cc
10
main.cc
@ -10,7 +10,6 @@
|
||||
#include "hardware/pwm.h"
|
||||
#include "hardware/adc.h"
|
||||
#include "state.h"
|
||||
#include "daisysp.h"
|
||||
|
||||
state_t state;
|
||||
|
||||
@ -42,15 +41,10 @@ void init_all() {
|
||||
gpio_set_irq_enabled_with_callback(VCO_BUTTON, GPIO_IRQ_EDGE_RISE, true, &handle_vco_change);
|
||||
}
|
||||
|
||||
daisysp::Oscillator osc;
|
||||
|
||||
__attribute__((noreturn))
|
||||
int main() {
|
||||
init_all();
|
||||
|
||||
osc.Init(SAMPLE_RATE);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
osc.SetFreq(state.vco_freq * 1760);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user