only: extracting isIgnVoltage() method
This commit is contained in:
parent
f881b178a5
commit
21e22cb7da
|
@ -1,12 +1,13 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "main_relay.h"
|
||||
#include "ignition_controller.h"
|
||||
|
||||
void MainRelayController::onSlowCallback() {
|
||||
#if EFI_MAIN_RELAY_CONTROL
|
||||
#if defined(IGN_KEY_DIVIDER)
|
||||
if (isAdcChannelValid(engineConfiguration->ignKeyAdcChannel)) {
|
||||
hasIgnitionVoltage = Sensor::getOrZero(SensorType::IgnKeyVoltage) > 5;
|
||||
hasIgnitionVoltage = isIgnVoltage();
|
||||
} else
|
||||
#endif // IGN_KEY_DIVIDER
|
||||
if (engineConfiguration->ignitionKeyDigitalPin != Gpio::Unassigned) {
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "pch.h"
|
||||
|
||||
bool isIgnVoltage() {
|
||||
return Sensor::getOrZero(SensorType::BatteryVoltage) > 5;
|
||||
}
|
||||
|
||||
void IgnitionController::onSlowCallback() {
|
||||
// default to 0 if failed sensor to prevent accidental ign-on if battery
|
||||
// input misconfigured (or the ADC hasn't started yet)
|
||||
auto hasIgnVoltage = Sensor::getOrZero(SensorType::BatteryVoltage) > 5;
|
||||
auto hasIgnVoltage = isIgnVoltage();
|
||||
|
||||
if (hasIgnVoltage) {
|
||||
m_timeSinceIgnVoltage.reset();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// file ignition_controller.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "engine_module.h"
|
||||
|
@ -12,3 +14,6 @@ private:
|
|||
Timer m_timeSinceIgnVoltage;
|
||||
bool m_lastState = false;
|
||||
};
|
||||
|
||||
// USB power or vehicle power?
|
||||
bool isIgnVoltage();
|
||||
|
|
Loading…
Reference in New Issue