rusEFI
The most advanced open source ECU
ignition_controller.cpp
Go to the documentation of this file.
1 #include "pch.h"
2 
3 bool isIgnVoltage() {
5 }
6 
8  // default to 0 if failed sensor to prevent accidental ign-on if battery
9  // input misconfigured (or the ADC hasn't started yet)
10  auto hasIgnVoltage = isIgnVoltage();
11 
12  if (hasIgnVoltage) {
13  m_timeSinceIgnVoltage.reset();
14  }
15 
16  if (hasIgnVoltage == m_lastState) {
17  // nothing to do, states match
18  return;
19  }
20 
21  // Ignore low voltage transients - we may see this at the start of cranking
22  // and we don't want to
23  if (!hasIgnVoltage && !m_timeSinceIgnVoltage.hasElapsedSec(0.2f)) {
24  return;
25  }
26 
27  // Store state and notify other modules of the change
28  m_lastState = hasIgnVoltage;
29  engine->engineModules.apply_all([&](auto& m) { m.onIgnitionStateChanged(hasIgnVoltage); });
30 }
type_list< Mockable< InjectorModelPrimary >, Mockable< InjectorModelSecondary >,#if EFI_IDLE_CONTROL Mockable< IdleController >,#endif TriggerScheduler,#if EFI_HPFP &&EFI_ENGINE_CONTROL HpfpController,#endif #if EFI_ENGINE_CONTROL Mockable< ThrottleModel >,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif FuelPumpController, MainRelayController, IgnitionController, Mockable< AcController >, FanControl1, FanControl2, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable< WallFuelController >,#if EFI_VEHICLE_SPEED GearDetector, TripOdometer,#endif KnockController, SensorChecker,#if EFI_ENGINE_CONTROL LimpManager,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment, EngineModule > engineModules
Definition: engine.h:172
void onSlowCallback() override
static float getOrZero(SensorType type)
Definition: sensor.h:92
Engine * engine
bool isIgnVoltage()
void apply_all(func_t const &f)
Definition: type_list.h:43