ETB overheats due to constant isTpsError true/false/true/false jitter #4832

refactoring: extract method
This commit is contained in:
rusefillc 2022-11-27 18:44:44 -05:00
parent d487d9db7a
commit c01ffa3716
3 changed files with 13 additions and 6 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -23,3 +23,6 @@ void grabTPSIsClosed();
void grabTPSIsWideOpen();
void grabPedalIsUp();
void grabPedalIsWideOpen();
bool isTps2Error();
bool isPedalError();