Tach output: hardware-timer ISR, slew glide, adaptive dither

The Patrol cluster counts pulses in ~150 rpm quanta, so the needle
stepped no matter how clean the data was. Three-stage rework of the
tach path in gauge_outputs:

- Drop LEDC for the tach: Arduino 2.x ledcChangeFrequency() re-inits
  the timer and truncates the waveform mid-period, corrupting the
  cluster's counting window on every update. IO7 is now toggled from a
  1 MHz hardware-timer ISR with auto-reload - phase-continuous through
  every frequency change and immune to task scheduling (an esp_timer
  version wobbled under WiFi bursts).
- Slew limiter: update() (5 Hz packets) only sets a target; tick(),
  called every 20 ms from loop(), glides the output 25%/tick toward it.
- Adaptive dither: random +/-1.2 Hz (~45 rpm, half the cluster's count
  quantum) per tick while the target moves, fading to zero within 1.2 s
  at steady rpm - emulates the natural pulse jitter that makes factory
  senders look smooth, without flickering the needle at rest.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 11:12:48 +02:00
parent 5fe313b7fa
commit bde1f57f62
3 changed files with 138 additions and 27 deletions
+8
View File
@@ -254,6 +254,14 @@ void loop() {
was_connected = is_connected;
}
// Tach slew: glide the output frequency between the 5 Hz data points so the
// pulse-counting cluster tach sweeps instead of stair-stepping.
static uint32_t last_tach_tick = 0;
if (millis() - last_tach_tick >= 20) {
last_tach_tick = millis();
GaugeOutputs::tick();
}
// UI + gauge outputs at the packet rate (5 Hz)
if (millis() - last_ui_update > 200) {
last_ui_update = millis();