Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix knock retard table init #419

Merged
merged 3 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
m_maxRetardTable.init(config->maxKnockRetardTable, config->maxKnockRetardLoadBins, config->maxKnockRetardRpmBins);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note this flips the load/rpm bins to match the current implementation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the minimal diff to fix the bug, sigh

}

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

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

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();
}
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();

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();
Loading