diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 54d1601902..01f8818dbb 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -438,12 +438,12 @@ static void updateThrottles() { SensorResult tps2 = Sensor::get(SensorType::Tps2); engine->outputChannels.TPS2Value = tps2.value_or(0); // If we don't have a TPS2 at all, don't turn on the failure light - engine->outputChannels.isTps2Error = !tps2.Valid && Sensor::hasSensor(SensorType::Tps2Primary); + engine->outputChannels.isTps2Error = isTps2Error(); SensorResult pedal = Sensor::get(SensorType::AcceleratorPedal); engine->outputChannels.throttlePedalPosition = pedal.value_or(0); // Only report fail if you have one (many people don't) - engine->outputChannels.isPedalError = !pedal.Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); + engine->outputChannels.isPedalError = isPedalError(); // TPS 1 pri/sec split engine->outputChannels.tps1Split = Sensor::getOrZero(SensorType::Tps1Primary) - Sensor::getOrZero(SensorType::Tps1Secondary); diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index 7ddedd6022..50116f8820 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -20,20 +20,24 @@ void grabTPSIsWideOpen() { } void grabPedalIsUp() { -#if EFI_PROD_CODE /** * search for 'maintainConstantValue' to find how this TS magic works */ engine->outputChannels.calibrationMode = (uint8_t)TsCalMode::PedalMin; engine->outputChannels.calibrationValue = Sensor::getRaw(SensorType::AcceleratorPedalPrimary); engine->outputChannels.calibrationValue2 = Sensor::getRaw(SensorType::AcceleratorPedalSecondary); -#endif /* EFI_PROD_CODE */ } void grabPedalIsWideOpen() { -#if EFI_PROD_CODE engine->outputChannels.calibrationMode = (uint8_t)TsCalMode::PedalMax; engine->outputChannels.calibrationValue = Sensor::getRaw(SensorType::AcceleratorPedalPrimary); engine->outputChannels.calibrationValue2 = Sensor::getRaw(SensorType::AcceleratorPedalSecondary); -#endif /* EFI_PROD_CODE */ +} + +bool isTps2Error() { + return !Sensor::get(SensorType::Tps2).Valid && Sensor::hasSensor(SensorType::Tps2Primary); +} + +bool isPedalError() { + return !Sensor::get(SensorType::AcceleratorPedal).Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); } diff --git a/firmware/controllers/sensors/tps.h b/firmware/controllers/sensors/tps.h index 2b00b32088..f3cdc9781a 100644 --- a/firmware/controllers/sensors/tps.h +++ b/firmware/controllers/sensors/tps.h @@ -23,3 +23,6 @@ void grabTPSIsClosed(); void grabTPSIsWideOpen(); void grabPedalIsUp(); void grabPedalIsWideOpen(); + +bool isTps2Error(); +bool isPedalError();