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);
|
||||
current_value = new_value;
|
||||
|
||||
if (current_value != last_sent_value) {
|
||||
last_sent_value = current_value;
|
||||
midi.send_cc(midi_channel, midi_cc, current_value);
|
||||
Serial.printf("[EXP] CC%d: %d (raw ADC: %d)\n", midi_cc, current_value, current_raw);
|
||||
// Rate-limited send: step ±1 per update when value deviates >1 from last sent.
|
||||
// This prevents stationary jitter (adjacent-value dither) while keeping
|
||||
// movement smooth (values increment one at a time, faster than any foot).
|
||||
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