Skip to content

Commit

Permalink
initialize knock controller / max retard table on reset
Browse files Browse the repository at this point in the history
  • Loading branch information
nmschulte committed May 4, 2024
1 parent ae01649 commit dbe240b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions firmware/controllers/engine_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ void commonInitEngineController() {

initTachometer();
initSpeedometer();

initKnockCtrl();
}

// Returns false if there's an obvious problem with the loaded configuration
Expand Down
10 changes: 9 additions & 1 deletion firmware/controllers/engine_cycle/knock_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
#include "pch.h"
#include "knock_logic.h"

void KnockController::init(engine_configuration_s const * const previousConfig) {
m_maxRetardTable.init(config->maxKnockRetardTable, config->maxKnockRetardLoadBins, config->maxKnockRetardRpmBins);
}

void KnockController::onConfigurationChange(engine_configuration_s const * previousConfig) {
KnockControllerBase::onConfigurationChange(previousConfig);

m_maxRetardTable.init(config->maxKnockRetardTable, config->maxKnockRetardLoadBins, config->maxKnockRetardRpmBins);
init(previousConfig);
}

int getCylinderKnockBank(uint8_t cylinderNumber) {
Expand Down Expand Up @@ -161,3 +165,7 @@ void Engine::onSparkFireKnockSense(uint8_t cylinderNumber, efitick_t nowNt) {
UNUSED(nowNt);
#endif
}

void initKnockCtrl() {
engine->module<KnockController>().unmock().init(engineConfiguration);
}
3 changes: 3 additions & 0 deletions firmware/controllers/engine_cycle/knock_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class KnockController : public KnockControllerBase {
KnockController()
{
}
void init(engine_configuration_s const * const previousConfig);

void onConfigurationChange(engine_configuration_s const * /*previousConfig*/) override;

Expand All @@ -50,3 +51,5 @@ class KnockController : public KnockControllerBase {
private:
Map3D<6, 6, uint8_t, uint8_t, uint8_t> m_maxRetardTable;
};

void initKnockCtrl();

0 comments on commit dbe240b

Please sign in to comment.