Compare commits
12
Commits
88fee54f96
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20e9d4a08d | ||
|
|
8aad6fdccd | ||
|
|
3558bb1050 | ||
|
|
cadb29f234 | ||
|
|
f055bad4ac | ||
|
|
1dec81e329 | ||
|
|
17def39f93 | ||
|
|
4f58d4b8e6 | ||
|
|
33c9dd10c0 | ||
|
|
dfa339a9b9 | ||
|
|
4aec064f3c | ||
|
|
39326e3247 |
@@ -24,11 +24,11 @@ private:
|
|||||||
uint8_t midi_channel;
|
uint8_t midi_channel;
|
||||||
uint8_t midi_cc;
|
uint8_t midi_cc;
|
||||||
|
|
||||||
static const uint8_t HYSTERESIS = 3;
|
|
||||||
static const uint16_t READ_INTERVAL_MS = 5;
|
static const uint16_t READ_INTERVAL_MS = 5;
|
||||||
uint32_t last_read_time;
|
uint32_t last_read_time;
|
||||||
|
|
||||||
uint16_t current_raw;
|
uint16_t current_raw;
|
||||||
|
uint16_t smoothed_raw;
|
||||||
uint16_t cal_min;
|
uint16_t cal_min;
|
||||||
uint16_t cal_max;
|
uint16_t cal_max;
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -144,10 +144,7 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) {
|
|||||||
uint8_t cc_num = cc_map[i];
|
uint8_t cc_num = cc_map[i];
|
||||||
// Use palette index 127 (magenta) for visible feedback
|
// Use palette index 127 (magenta) for visible feedback
|
||||||
uint8_t value = pressed ? 127 : 0;
|
uint8_t value = pressed ? 127 : 0;
|
||||||
|
midi_transport->send_cc(channel, cc_num, value);
|
||||||
if (pressed) {
|
|
||||||
midi_transport->send_cc(channel, cc_num, value);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-13
@@ -10,8 +10,9 @@ ExpressionPedal::ExpressionPedal(uint8_t adc_pin)
|
|||||||
, midi_cc(4)
|
, midi_cc(4)
|
||||||
, last_read_time(0)
|
, last_read_time(0)
|
||||||
, current_raw(0)
|
, current_raw(0)
|
||||||
|
, smoothed_raw(0)
|
||||||
, cal_min(36)
|
, cal_min(36)
|
||||||
, cal_max(1180)
|
, cal_max(950)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +22,8 @@ void ExpressionPedal::begin() {
|
|||||||
pinMode(adc_pin, INPUT);
|
pinMode(adc_pin, INPUT);
|
||||||
delay(10);
|
delay(10);
|
||||||
current_raw = analogRead(adc_pin);
|
current_raw = analogRead(adc_pin);
|
||||||
current_value = adc_to_midi(current_raw);
|
smoothed_raw = current_raw;
|
||||||
|
current_value = adc_to_midi(smoothed_raw);
|
||||||
last_sent_value = current_value;
|
last_sent_value = current_value;
|
||||||
Serial.printf("[EXP] Starting: raw ADC=%d -> MIDI=%d (cal: %d-%d)\n",
|
Serial.printf("[EXP] Starting: raw ADC=%d -> MIDI=%d (cal: %d-%d)\n",
|
||||||
current_raw, current_value, cal_min, cal_max);
|
current_raw, current_value, cal_min, cal_max);
|
||||||
@@ -34,18 +36,19 @@ void ExpressionPedal::update(UsbMidiTransport& midi) {
|
|||||||
last_read_time = now;
|
last_read_time = now;
|
||||||
|
|
||||||
current_raw = analogRead(adc_pin);
|
current_raw = analogRead(adc_pin);
|
||||||
uint8_t new_value = adc_to_midi(current_raw);
|
smoothed_raw = (smoothed_raw * 7 + current_raw + 4) / 8;
|
||||||
|
uint8_t new_value = adc_to_midi(smoothed_raw);
|
||||||
|
current_value = new_value;
|
||||||
|
|
||||||
if (new_value > current_value + HYSTERESIS ||
|
// Proportional catch-up: send midpoint rounded up each update.
|
||||||
new_value + HYSTERESIS < current_value ||
|
// Rejects ±1 stationary jitter but converges to exact value on movement
|
||||||
(new_value != current_value && (new_value == 0 || new_value == 127))) {
|
// (e.g., 0→127 converges in ~35ms).
|
||||||
current_value = new_value;
|
if (current_value > last_sent_value + 1) {
|
||||||
}
|
last_sent_value = (last_sent_value + current_value + 1) / 2;
|
||||||
|
midi.send_cc(midi_channel, midi_cc, last_sent_value);
|
||||||
if (current_value != last_sent_value) {
|
} else if (current_value < last_sent_value - 1) {
|
||||||
last_sent_value = current_value;
|
last_sent_value = (last_sent_value + current_value) / 2;
|
||||||
midi.send_cc(midi_channel, midi_cc, current_value);
|
midi.send_cc(midi_channel, midi_cc, last_sent_value);
|
||||||
Serial.printf("[EXP] CC%d: %d (raw ADC: %d)\n", midi_cc, current_value, current_raw);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-6
@@ -194,21 +194,25 @@ void DefaultLedStub::begin() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("[LED] Launchpad-style startup animation...");
|
Serial.println("[LED] Launchpad-style startup animation (paired)...");
|
||||||
|
|
||||||
// Launchpad X style: sweep each LED through palette, then all-off
|
// Sweep each pixel-pair through palette, then off
|
||||||
for (int i = 0; i < NUM_LEDS; i++) {
|
for (int pair = 0; pair < 5; pair++) {
|
||||||
|
int i1 = pair * 2;
|
||||||
|
int i2 = pair * 2 + 1;
|
||||||
for (int c = 1; c <= 127; c += 8) {
|
for (int c = 1; c <= 127; c += 8) {
|
||||||
uint32_t color = launchpad_palette[c];
|
uint32_t color = launchpad_palette[c];
|
||||||
uint8_t r = (color >> 16) & 0xFF;
|
uint8_t r = (color >> 16) & 0xFF;
|
||||||
uint8_t g = (color >> 8) & 0xFF;
|
uint8_t g = (color >> 8) & 0xFF;
|
||||||
uint8_t b = color & 0xFF;
|
uint8_t b = color & 0xFF;
|
||||||
mux_ptr->set_led_color(i, r, g, b);
|
mux_ptr->set_led_color(i1, r, g, b);
|
||||||
|
mux_ptr->set_led_color(i2, r, g, b);
|
||||||
mux_ptr->show();
|
mux_ptr->show();
|
||||||
delay(15);
|
delay(15);
|
||||||
}
|
}
|
||||||
// Turn off this LED before moving to next
|
// Turn off this pair before moving to next
|
||||||
mux_ptr->set_led_color(i, 0, 0, 0);
|
mux_ptr->set_led_color(i1, 0, 0, 0);
|
||||||
|
mux_ptr->set_led_color(i2, 0, 0, 0);
|
||||||
mux_ptr->show();
|
mux_ptr->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ UsbMidiTransport midi_transport;
|
|||||||
AppTask controller(&led_driver, &switch_driver, &midi_transport);
|
AppTask controller(&led_driver, &switch_driver, &midi_transport);
|
||||||
ExpressionPedal exp_pedal(4);
|
ExpressionPedal exp_pedal(4);
|
||||||
|
|
||||||
volatile uint32_t flash_latency = 55; // ms delay to compensate for Loopy Pro rendering
|
volatile uint32_t flash_latency = 0;
|
||||||
volatile uint8_t beats_per_bar = 4; // change to match your project's time signature
|
volatile uint8_t beats_per_bar = 4; // change to match your project's time signature
|
||||||
|
|
||||||
TaskHandle_t midi_task_handle = NULL;
|
TaskHandle_t midi_task_handle = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user