File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ volatile uint32_t vssWindowStartUs = 0;
9090static constexpr uint8_t VSS_MIN_PULSES_TO_MOVE = 6 ;
9191static constexpr float VSS_MIN_UNLOCK_KPH = 8 .0f ; // ~5 mph
9292static uint8_t vssValidPulseStreak = 0 ;
93+ static constexpr float VSS_IDLE_RPM_CUTOFF = 1800 .0f ;
94+
9395
9496
9597
@@ -180,6 +182,7 @@ volatile uint32_t tachPeriodUs = 0;
180182volatile uint32_t lastTachUs = 0 ;
181183volatile uint32_t vssPeriodUs = 0 ;
182184volatile uint32_t vssLastUs = 0 ;
185+ volatile float engineRpm = 0 .0f ;
183186
184187
185188float rpmNow = 0 .0f ;
@@ -495,6 +498,7 @@ void updateRPM() {
495498 rpmFiltered = rpmRaw;
496499
497500 rpmNow = rpmFiltered;
501+ engineRpm = rpmFiltered;
498502}
499503
500504// =======================================================
@@ -578,6 +582,14 @@ void updateVSS() {
578582 // NOT MOVING: require sustained evidence to unlock
579583 // --------------------------------
580584 if (!vssMoving) {
585+
586+ // Block idle-correlated VSS chatter (only while trying to unlock)
587+ if (engineRpm < VSS_IDLE_RPM_CUTOFF ) {
588+ startGood = 0 ;
589+ kphNow = 0 .0f ;
590+ kphEma = 0 .0f ;
591+ return ;
592+ }
581593 // If pulses are not continuous, treat as noise and stay at 0
582594 if ((now - lastPulse) > CONTINUOUS_US ) {
583595 startGood = 0 ;
You can’t perform that action at this time.
0 commit comments