Rate-limit exp pedal: step ±1/update, stationary jitter ignored
This commit is contained in:
@@ -40,10 +40,15 @@ void ExpressionPedal::update(UsbMidiTransport& midi) {
|
|||||||
uint8_t new_value = adc_to_midi(smoothed_raw);
|
uint8_t new_value = adc_to_midi(smoothed_raw);
|
||||||
current_value = new_value;
|
current_value = new_value;
|
||||||
|
|
||||||
if (current_value != last_sent_value) {
|
// Rate-limited send: step ±1 per update when value deviates >1 from last sent.
|
||||||
last_sent_value = current_value;
|
// This prevents stationary jitter (adjacent-value dither) while keeping
|
||||||
midi.send_cc(midi_channel, midi_cc, current_value);
|
// movement smooth (values increment one at a time, faster than any foot).
|
||||||
Serial.printf("[EXP] CC%d: %d (raw ADC: %d)\n", midi_cc, current_value, current_raw);
|
if (current_value > last_sent_value + 1) {
|
||||||
|
last_sent_value++;
|
||||||
|
midi.send_cc(midi_channel, midi_cc, last_sent_value);
|
||||||
|
} else if (current_value < last_sent_value - 1) {
|
||||||
|
last_sent_value--;
|
||||||
|
midi.send_cc(midi_channel, midi_cc, last_sent_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user