rusefillc 2023-12-10 11:52:39 -05:00
parent 28a273cae7
commit 3b88f847e0
1 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,13 @@
void MainRelayController::onSlowCallback() {
#if EFI_MAIN_RELAY_CONTROL
hasIgnitionVoltage = Sensor::getOrZero(SensorType::BatteryVoltage) > 5;
if (engineConfiguration->ignitionKeyDigitalPin != Gpio::Unassigned) {
// separate digital input pin just for main relay logic since it's preferred to read voltage from main relay
// key-on is usually a bit smaller voltage than main relay but sometimes even 1v off!
hasIgnitionVoltage = efiReadPin(engineConfiguration->ignitionKeyDigitalPin);
} else {
hasIgnitionVoltage = Sensor::getOrZero(SensorType::BatteryVoltage) > 5;
}
if (hasIgnitionVoltage) {
m_lastIgnitionTime.reset();
@ -24,7 +30,7 @@ void MainRelayController::onSlowCallback() {
}
bool MainRelayController::needsDelayedShutoff() {
// Prevent main relay from turning off if we had igniton voltage in the past 1 second
// Prevent main relay from turning off if we had ignition voltage in the past 1 second
// This avoids accidentally killing the car during a transient, for example
// right when the starter is engaged.
return !m_lastIgnitionTime.hasElapsedSec(1);