Skip to content

Commit

Permalink
move output channel fuel/spark cut update to limp
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 19, 2025
1 parent d2edb9e commit 2d96259
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions firmware/controllers/engine_cycle/main_trigger_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ static void handleFuel(efitick_t nowNt, float currentPhase, float nextPhase) {

efiAssertVoid(ObdCode::CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");

LimpState limitedFuelState = getLimpManager()->allowInjection();

// todo: eliminate state copy logic by giving limpManager it's owm limp_manager.txt and leveraging LiveData
engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason;
bool limitedFuel = !limitedFuelState.value;
if (limitedFuel) {
if (!getLimpManager()->allowInjection().value) {
return;
}

Expand Down
6 changes: 1 addition & 5 deletions firmware/controllers/engine_cycle/spark_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,7 @@ void onTriggerEventSparkLogic(efitick_t edgeTimestamp, float currentPhase, float
return;
}

LimpState limitedSparkState = getLimpManager()->allowIgnition();

// todo: eliminate state copy logic by giving limpManager it's owm limp_manager.txt and leveraging LiveData
engine->outputChannels.sparkCutReason = (int8_t)limitedSparkState.reason;
bool limitedSpark = !limitedSparkState.value;
bool limitedSpark = !getLimpManager()->allowIgnition().value;

const floatms_t dwellMs = engine->ignitionState.getDwell();
if (std::isnan(dwellMs) || dwellMs <= 0) {
Expand Down
4 changes: 4 additions & 0 deletions firmware/controllers/limp_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ todo AndreiKA this change breaks 22 unit tests?
// Tracks the last time any cut happened
m_lastCutTime.reset(nowNt);
}

// Update output channels
engine->outputChannels.fuelCutReason = static_cast<uint8_t>(allowInjection().reason);
engine->outputChannels.sparkCutReason = static_cast<uint8_t>(allowIgnition().reason);
}

void LimpManager::onIgnitionStateChanged(bool ignitionOn) {
Expand Down

0 comments on commit 2d96259

Please sign in to comment.