Only allow manual +/- if in manual range

This commit is contained in:
David Holdeman 2024-04-20 12:59:36 -05:00 committed by rusefillc
parent 48a658fff9
commit 649e7cf149
2 changed files with 5 additions and 2 deletions

View File

@ -96,7 +96,7 @@ void GenericGearController::update() {
setDesiredGear(NEUTRAL); setDesiredGear(NEUTRAL);
break; break;
case SelectedGear::ManualPlus : case SelectedGear::ManualPlus :
if (!shiftTimer.hasElapsedMs(500)) { if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
break; break;
} }
shiftTimer.reset(); shiftTimer.reset();
@ -115,7 +115,7 @@ void GenericGearController::update() {
} }
break; break;
case SelectedGear::ManualMinus : case SelectedGear::ManualMinus :
if (!shiftTimer.hasElapsedMs(500)) { if (!shiftTimer.hasElapsedMs(500) || lastRange != SelectedGear::Manual) {
break; break;
} }
shiftTimer.reset(); shiftTimer.reset();
@ -139,6 +139,8 @@ void GenericGearController::update() {
default: default:
break; break;
} }
lastRange = gear;
} }
GearControllerBase::update(); GearControllerBase::update();

View File

@ -15,6 +15,7 @@ public:
} }
private: private:
Timer shiftTimer; Timer shiftTimer;
SelectedGear lastRange;
bool isNearest(float value, int pinIndex, float* rangeStates); bool isNearest(float value, int pinIndex, float* rangeStates);
SensorType getAnalogSensorType(int zeroBasedSensorIndex); SensorType getAnalogSensorType(int zeroBasedSensorIndex);
}; };