refactoring: extracting method

This commit is contained in:
Andrey 2022-11-29 20:11:29 -05:00
parent e754595b97
commit ddc9971a2a
3 changed files with 6 additions and 1 deletions

View File

@ -525,7 +525,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
prevOutput = output;
// seems good enough to simply check for both TPS sensors
bool isInputError = !Sensor::get(SensorType::Tps1).Valid || isTps2Error() || isPedalError();
bool isInputError = isTps1Error() || isTps2Error() || isPedalError();
// current basic implementation is to check for input error counter only while engine is not running
// we can make this logic smarter one day later
if (Sensor::getOrZero(SensorType::Rpm) == 0 && wasInputError != isInputError) {

View File

@ -34,6 +34,10 @@ void grabPedalIsWideOpen() {
engine->outputChannels.calibrationValue2 = Sensor::getRaw(SensorType::AcceleratorPedalSecondary);
}
bool isTps1Error() {
return !Sensor::get(SensorType::Tps1).Valid;
}
bool isTps2Error() {
return !Sensor::get(SensorType::Tps2).Valid && Sensor::hasSensor(SensorType::Tps2Primary);
}

View File

@ -24,5 +24,6 @@ void grabTPSIsWideOpen();
void grabPedalIsUp();
void grabPedalIsWideOpen();
bool isTps1Error();
bool isTps2Error();
bool isPedalError();