guards
This commit is contained in:
parent
d951f36794
commit
41a8a90b3d
|
@ -13,8 +13,10 @@ void FuelPumpController::onSlowCallback() {
|
|||
// If the ignition just turned on, turn on the fuel pump to prime
|
||||
isPrime = timeSinceIgn >= 0 && timeSinceIgn < engineConfiguration->startUpFuelPumpDuration;
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
// If there was a trigger event recently, turn on the pump, the engine is running!
|
||||
engineTurnedRecently = engine->triggerCentral.engineMovedRecently();
|
||||
#endif //EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
isFuelPumpOn = isPrime || engineTurnedRecently;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ expected<float> readGppwmChannel(gppwm_channel_e channel) {
|
|||
return Sensor::get(SensorType::AcceleratorPedal);
|
||||
case GPPWM_Vbatt:
|
||||
return Sensor::get(SensorType::BatteryVoltage);
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
case GPPWM_VVT_1I:
|
||||
return engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0);
|
||||
case GPPWM_VVT_1E:
|
||||
|
@ -42,6 +43,13 @@ expected<float> readGppwmChannel(gppwm_channel_e channel) {
|
|||
return engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/0);
|
||||
case GPPWM_VVT_2E:
|
||||
return engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/1);
|
||||
#else
|
||||
case GPPWM_VVT_1I:
|
||||
case GPPWM_VVT_1E:
|
||||
case GPPWM_VVT_2I:
|
||||
case GPPWM_VVT_2E:
|
||||
return 0;
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
case GPPWM_EthanolPercent:
|
||||
return Sensor::get(SensorType::FuelEthanolPercent);
|
||||
case GPPWM_AuxLinear1:
|
||||
|
|
|
@ -44,11 +44,13 @@ void applyIACposition(percent_t position) {
|
|||
#endif /* EFI_UNIT_TEST */
|
||||
} else {
|
||||
// if not spinning or running a bench test, turn off the idle valve(s) to be quieter and save power
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
if (!engine->triggerCentral.engineMovedRecently() && engine->timeToStopIdleTest == 0) {
|
||||
idleSolenoidOpen.setSimplePwmDutyCycle(0);
|
||||
idleSolenoidClose.setSimplePwmDutyCycle(0);
|
||||
return;
|
||||
}
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
if (!engineConfiguration->isDoubleSolenoidIdle) {
|
||||
idleSolenoidOpen.setSimplePwmDutyCycle(duty);
|
||||
|
|
|
@ -358,8 +358,10 @@ float IdleController::getIdlePosition(float rpm) {
|
|||
}
|
||||
|
||||
void IdleController::onSlowCallback() {
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
float position = getIdlePosition(engine->triggerCentral.instantRpm.getInstantRpm());
|
||||
applyIACposition(position);
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
}
|
||||
|
||||
void IdleController::onConfigurationChange(engine_configuration_s const * previousConfiguration) {
|
||||
|
|
|
@ -129,11 +129,13 @@ static void assertCloseTo(const char* msg, float actual, float expected) {
|
|||
void Engine::periodicSlowCallback() {
|
||||
ScopePerf perf(PE::EnginePeriodicSlowCallback);
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
// Re-read config in case it's changed
|
||||
triggerCentral.primaryTriggerConfiguration.update();
|
||||
for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) {
|
||||
triggerCentral.vvtTriggerConfiguration[camIndex].update();
|
||||
}
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
efiWatchdog();
|
||||
updateSlowSensors();
|
||||
|
@ -205,13 +207,13 @@ void Engine::periodicSlowCallback() {
|
|||
void Engine::updateSlowSensors() {
|
||||
updateSwitchInputs();
|
||||
|
||||
#if EFI_ENGINE_CONTROL
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
int rpm = Sensor::getOrZero(SensorType::Rpm);
|
||||
triggerCentral.isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold;
|
||||
getEngineState()->sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;
|
||||
|
||||
engineState.updateSlowSensors();
|
||||
#endif
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
}
|
||||
|
||||
#if EFI_GPIO_HARDWARE
|
||||
|
@ -354,10 +356,12 @@ void Engine::OnTriggerSyncronization(bool wasSynchronized, bool isDecodingError)
|
|||
#endif
|
||||
|
||||
void Engine::injectEngineReferences() {
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
triggerCentral.primaryTriggerConfiguration.update();
|
||||
for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) {
|
||||
triggerCentral.vvtTriggerConfiguration[camIndex].update();
|
||||
}
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
}
|
||||
|
||||
void Engine::setConfig() {
|
||||
|
@ -367,7 +371,7 @@ void Engine::setConfig() {
|
|||
}
|
||||
|
||||
void Engine::efiWatchdog() {
|
||||
#if EFI_ENGINE_CONTROL
|
||||
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
||||
if (isRunningPwmTest)
|
||||
return;
|
||||
|
||||
|
@ -413,7 +417,7 @@ void Engine::efiWatchdog() {
|
|||
#endif
|
||||
|
||||
enginePins.stopPins();
|
||||
#endif
|
||||
#endif // EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
||||
}
|
||||
|
||||
void Engine::checkShutdown() {
|
||||
|
@ -541,14 +545,17 @@ ExecutorInterface *getExecutorInterface() {
|
|||
return &engine->executor;
|
||||
}
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
TriggerCentral * getTriggerCentral() {
|
||||
return &engine->triggerCentral;
|
||||
}
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
LimpManager * getLimpManager() {
|
||||
return &engine->module<LimpManager>().unmock();
|
||||
}
|
||||
|
||||
#if EFI_ENGINE_CONTROL
|
||||
FuelSchedule *getFuelSchedule() {
|
||||
return &engine->injectionEvents;
|
||||
}
|
||||
|
@ -556,3 +563,4 @@ FuelSchedule *getFuelSchedule() {
|
|||
IgnitionEventList *getIgnitionEvents() {
|
||||
return &engine->ignitionEvents;
|
||||
}
|
||||
#endif // EFI_ENGINE_CONTROL
|
||||
|
|
|
@ -181,11 +181,13 @@ struct Cams {
|
|||
};
|
||||
|
||||
static void populateFrame(Cams& msg) {
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
msg.Bank1IntakeActual = engine->triggerCentral.getVVTPosition(0, 0);
|
||||
msg.Bank1ExhaustActual = engine->triggerCentral.getVVTPosition(0, 1);
|
||||
msg.Bank2IntakeActual = engine->triggerCentral.getVVTPosition(1, 0);
|
||||
msg.Bank2ExhaustActual = engine->triggerCentral.getVVTPosition(1, 1);
|
||||
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
// TODO: maybe don't rely on outputChannels here
|
||||
msg.Bank1IntakeTarget = engine->outputChannels.vvtTargets[0];
|
||||
msg.Bank1ExhaustTarget = engine->outputChannels.vvtTargets[1];
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
*/
|
||||
#include "engine_state.h"
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
|
||||
InstantRpmCalculator::InstantRpmCalculator() :
|
||||
//https://en.cppreference.com/w/cpp/language/zero_initialization
|
||||
timeOfLastEvent()
|
||||
|
@ -135,3 +137,5 @@ void InstantRpmCalculator::updateInstantRpm(
|
|||
}
|
||||
#endif /* EFI_SENSOR_CHART */
|
||||
}
|
||||
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
Loading…
Reference in New Issue