Some checks failed
check / check (push) Has been cancelled
First commit of the repo. Contents beyond the v0.1 simulator and layout: - Full Pico 2 W firmware (firmware/app, drivers, engine port, host test). - BANK page and 404 mode A/B removed; learned pads play exactly what was learned. - 404/MiniFreak renamed to KIT/SYNTH throughout (jacks, code, sim, docs, layout labels; wiring rebuilt). - ROLL returns to page select after a re-roll; a freshly learned track turns on. - LCD contrast 66. - ROOT and SCALE pages: 21 scales, AUTO = the seed picks; global and sticky. Intended music change: the scale table grew from 8 to 21 and AUTO picks from all of them, so every seed's scale changed. Vectors regenerated with npm run vectors, plus new key-override cases. Flash record is now version 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
817 B
C
32 lines
817 B
C
#include "pots.h"
|
|
#include "hardware/adc.h"
|
|
|
|
#define SAMPLES 16
|
|
#define HYSTERESIS 24 /* in 12-bit counts: 0.75 of a 7-bit step past the step's centre */
|
|
|
|
static int value[2], raw[2];
|
|
|
|
void pots_init(void){
|
|
adc_init();
|
|
adc_gpio_init(26); /* also turns off the digital input and pulls */
|
|
adc_gpio_init(27);
|
|
pots_update();
|
|
value[0] = raw[0] >> 5; value[1] = raw[1] >> 5;
|
|
}
|
|
|
|
void pots_update(void){
|
|
int i, k;
|
|
for(i = 0; i < 2; i++){
|
|
int sum = 0, centre, d;
|
|
adc_select_input((uint)i);
|
|
for(k = 0; k < SAMPLES; k++) sum += adc_read();
|
|
raw[i] = sum / SAMPLES;
|
|
centre = value[i] * 32 + 16;
|
|
d = raw[i] - centre;
|
|
if(d > 16 + HYSTERESIS || d < -16 - HYSTERESIS) value[i] = raw[i] >> 5;
|
|
}
|
|
}
|
|
|
|
int pot_value(int pot){ return value[pot]; }
|
|
int pot_raw(int pot){ return raw[pot]; }
|