add button basics
This commit is contained in:
parent
65516b2bff
commit
061ca37ad7
28
buttons.c
Normal file
28
buttons.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "const.h"
|
||||||
|
#include "state.h"
|
||||||
|
#include "vco.h"
|
||||||
|
#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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_button(uint pin, bool *button_state) {
|
||||||
|
if(gpio_get(pin) != *button_state) {
|
||||||
|
*button_state=!*button_state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_buttons() {
|
||||||
|
update_button(QUANT_BUTTON,&state.quant_enabled);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
3
buttons.h
Normal file
3
buttons.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <pico/types.h>
|
||||||
|
void handle_vco_change(uint gpio, uint32_t events);
|
||||||
1
const.h
1
const.h
@ -16,3 +16,4 @@
|
|||||||
|
|
||||||
#define SAMPLE_RATE 44100.0f
|
#define SAMPLE_RATE 44100.0f
|
||||||
|
|
||||||
|
#define otherwise else
|
||||||
|
|||||||
4
main.cc
4
main.cc
@ -1,3 +1,4 @@
|
|||||||
|
#include "buttons.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include <hardware/gpio.h>
|
#include <hardware/gpio.h>
|
||||||
@ -36,6 +37,9 @@ void init_all() {
|
|||||||
adc_gpio_init(adc_gpio[i]);
|
adc_gpio_init(adc_gpio[i]);
|
||||||
adc_select_input(i);
|
adc_select_input(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpio_pull_down(VCO_BUTTON);
|
||||||
|
gpio_set_irq_enabled_with_callback(VCO_BUTTON, GPIO_IRQ_EDGE_RISE, true, &handle_vco_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
daisysp::Oscillator osc;
|
daisysp::Oscillator osc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user