don't write settings if cal didn't work (#2154)

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2020-12-28 05:03:10 -08:00 committed by GitHub
parent 4555a98836
commit ec508d8f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -605,6 +605,13 @@ struct EtbImpl final : public EtbController {
// Finally disable and reset state // Finally disable and reset state
motor->disable(); motor->disable();
// Check that the calibrate actually moved the throttle
if (absF(primaryMax - primaryMin) < 0.5f) {
firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax);
m_isAutocal = false;
return;
}
// Write out the learned values to TS, waiting briefly after setting each to let TS grab it // Write out the learned values to TS, waiting briefly after setting each to let TS grab it
tsOutputChannels.calibrationMode = functionToCalModePriMax(myFunction); tsOutputChannels.calibrationMode = functionToCalModePriMax(myFunction);
tsOutputChannels.calibrationValue = primaryMax; tsOutputChannels.calibrationValue = primaryMax;