Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 052ac9eb17 |
Vendored
+9
-19
@@ -1,31 +1,21 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Cortex Debug",
|
||||
"name": "Cortex Debug (Pico 2W / RP2350)",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"executable": "${command:cmake.launchTargetPath}",
|
||||
"executable": "${workspaceRoot}/build/sint-gauntlet.elf",
|
||||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"gdbPath": "gdb-multiarch",
|
||||
"serverArgs": [
|
||||
|
||||
],
|
||||
"device": "RP2040",
|
||||
"configFiles": [
|
||||
"interface/raspberrypi-swd.cfg",
|
||||
"target/rp2040.cfg"
|
||||
],
|
||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
|
||||
"servertype": "external",
|
||||
"gdbPath": "arm-none-eabi-gdb",
|
||||
"gdbTarget": "localhost:3333",
|
||||
"device": "RP2350",
|
||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2350/hardware_regs/rp2350.svd",
|
||||
"runToEntryPoint": "main",
|
||||
// Give restart the same functionality as runToEntryPoint - main
|
||||
"postRestartCommands": [
|
||||
"break main",
|
||||
"continue"
|
||||
"break main",
|
||||
"continue"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,48 +1,72 @@
|
||||
#include <hardware/adc.h>
|
||||
#include <hardware/gpio.h>
|
||||
#include <math.h>
|
||||
#include <pico/stdlib.h>
|
||||
#include <pico/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "const.h"
|
||||
|
||||
#include "input.h"
|
||||
|
||||
bool is_toggle[BUTTON_COUNT] = { false };
|
||||
bool btn_prev[BUTTON_COUNT] = { false };
|
||||
bool is_toggle[BUTTON_COUNT] = {false};
|
||||
bool btn_prev[BUTTON_COUNT] = {false};
|
||||
|
||||
void set_mux_addr(uint8_t addr) {
|
||||
gpio_put(MUX_S0, addr & 1);
|
||||
gpio_put(MUX_S1, (addr >> 1) & 1);
|
||||
gpio_put(MUX_S2, (addr >> 2) & 1);
|
||||
gpio_put(MUX_S0, addr & 1);
|
||||
gpio_put(MUX_S1, (addr >> 1) & 1);
|
||||
gpio_put(MUX_S2, (addr >> 2) & 1);
|
||||
}
|
||||
|
||||
void update_inputs(input_t* input) {
|
||||
// Pots
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
set_mux_addr(i);
|
||||
sleep_us(50); // Let multiplexers multiplex
|
||||
for (uint8_t j = 0; j < 2; j++) {
|
||||
adc_select_input(j);
|
||||
float old_val = input->pots[i + j * 8];
|
||||
float new_val = (float)adc_read() / 4096.0f;
|
||||
if (fabs(new_val - old_val) >= 0.01f) input->pots[i + j * 8] = new_val;
|
||||
}
|
||||
}
|
||||
void update_pot(input_t *input) {
|
||||
static volatile uint function_call_counter = 0;
|
||||
function_call_counter++;
|
||||
static uint8_t i = 0;
|
||||
for (; i < 2; i++, adc_select_input(i)) {
|
||||
{
|
||||
static uint8_t j = 0;
|
||||
for (; j < 8;) {
|
||||
set_mux_addr(j);
|
||||
sleep_ms(5); // Let multiplexers multiplex (5ms smallest reliable delay)
|
||||
float old_val = input->pots[j + i * 8];
|
||||
float new_val = (float)adc_read() / 4096.0f;
|
||||
|
||||
// Buttons
|
||||
for (uint8_t i = 0; i < BUTTON_COUNT; i++) {
|
||||
bool btn_curr = gpio_get(BUTTON_BASE + i);
|
||||
if (!(new_val > 0.99f) && (fabs(new_val - old_val) >= 0.01f)) {
|
||||
|
||||
if (btn_curr == true && btn_prev[i] == false) {
|
||||
if (is_toggle[i]) input->buttons[i] = !input->buttons[i];
|
||||
}
|
||||
input->pots[j + i * 8] = new_val;
|
||||
}
|
||||
|
||||
if (!is_toggle[i]) input->buttons[i] = btn_curr;
|
||||
|
||||
btn_prev[i] = btn_curr;
|
||||
}
|
||||
j++;
|
||||
return;
|
||||
}
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
adc_select_input(i);
|
||||
sleep_ms(5);
|
||||
update_pot(input); // dont skip the tick
|
||||
}
|
||||
|
||||
void update_inputs(input_t *input) {
|
||||
|
||||
// Pots
|
||||
update_pot(input);
|
||||
__asm__("nop");
|
||||
|
||||
// Buttons
|
||||
for (uint8_t i = 0; i < BUTTON_COUNT; i++) {
|
||||
bool btn_curr = gpio_get(BUTTON_BASE + i);
|
||||
|
||||
if (btn_curr == true && btn_prev[i] == false) {
|
||||
if (is_toggle[i])
|
||||
input->buttons[i] = !input->buttons[i];
|
||||
}
|
||||
|
||||
if (!is_toggle[i])
|
||||
input->buttons[i] = btn_curr;
|
||||
|
||||
btn_prev[i] = btn_curr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ void update_state(state_t* state, input_t* input) {
|
||||
else state->vco_freq = quantize(state->vco_freq);
|
||||
}
|
||||
|
||||
// state->amen_enabled = input->buttons[2];
|
||||
state->amen_enabled = true;
|
||||
state->amen_enabled = input->buttons[2];
|
||||
//state->amen_enabled = true;
|
||||
|
||||
state->beat_samples = SAMPLE_RATE * 60.0f / state->clock_bpm;
|
||||
state->playback_rate = state->clock_bpm / AMEN_BPM;
|
||||
|
||||
@@ -87,7 +87,10 @@ float get_sample(void) {
|
||||
filter_env.SetTime(ADENV_SEG_DECAY, state->env2_decay);
|
||||
|
||||
float vco_env_out = vco_env.Process();
|
||||
float filter_env_out = filter_env.Process();
|
||||
float filter_env_out = filter_env.Process();
|
||||
// make it emit only continuous tone
|
||||
// float vco_env_out = 1.0f;
|
||||
// float filter_env_out = 0.0f;
|
||||
|
||||
osc.SetFreq(state->vco_freq);
|
||||
osc.SetWaveform(vco_mode_to_daisy(state->vco_mode));
|
||||
|
||||
Reference in New Issue
Block a user