Add expression pedal calibration: cal min/cal max

- Remove fixed 0-4095 mapping, use cal_min/cal_max instead
- Auto-calibrate minimum at boot (assumes pedal at heel)
- 'cal min' sets current position as heel (0)
- 'cal max' sets current position as toe (127)
- Map cal_min->0, cal_max->127 with clamping
- Update 'exp' command to show raw ADC + cal values
This commit is contained in:
ash
2026-07-02 04:09:22 +00:00
parent 08d6fc8701
commit 8bde8efaff
3 changed files with 48 additions and 11 deletions
+10 -3
View File
@@ -87,8 +87,13 @@ void handle_serial_command(const String& cmd) {
mux.show();
Serial.println("[CMD] Pixel 1 WHITE (max brightness)");
} else if (cmd == "exp") {
uint16_t raw = analogRead(5);
Serial.printf("[CMD] EXP GPIO5 ADC=%d MIDI=%d\n", raw, exp_pedal.get_value());
Serial.printf("[CMD] EXP ADC=%d MIDI=%d cal_min=%d cal_max=%d\n",
exp_pedal.get_raw(), exp_pedal.get_value(),
exp_pedal.get_cal_min(), exp_pedal.get_cal_max());
} else if (cmd == "cal min") {
exp_pedal.set_cal_min();
} else if (cmd == "cal max") {
exp_pedal.set_cal_max();
} else if (cmd == "usb") {
Serial.printf("[CMD] USB mounted: %s\n", TinyUSBDevice.mounted() ? "YES" : "NO");
Serial.printf("[CMD] USB ready: %s\n", TinyUSBDevice.ready() ? "YES" : "NO");
@@ -132,7 +137,9 @@ void handle_serial_command(const String& cmd) {
Serial.println(" read - raw button read");
Serial.println(" red/green/blue - solid colour");
Serial.println(" pixel0/pixel1 - single pixel test");
Serial.println(" exp - expression pedal ADC/MIDI value");
Serial.println(" exp - expression pedal ADC/MIDI/cal values");
Serial.println(" cal min - set current pedal position as minimum (heel)");
Serial.println(" cal max - set current pedal position as maximum (toe)");
Serial.println(" usb - USB connection status and descriptor info");
Serial.println(" gpiotest - raw GPIO pin diagnostic");
Serial.println(" rawled - bit-bang WS2812 (no library)");