more ignition encapsulation

only:uaefi
This commit is contained in:
rusefillc 2024-12-27 12:02:15 -05:00
parent 5bf6964538
commit d61e1b5147
4 changed files with 16 additions and 10 deletions

View File

@ -144,7 +144,7 @@ void EngineState::periodicFastCallback() {
}
engine->fuelComputer.running.postCrankingFuelCorrection = m_postCrankingFactor;
engine->ignitionState.cltTimingCorrection = getCltTimingCorrection();
engine->ignitionState.updateAdvanceCorrections();
baroCorrection = getBaroCorrection();

View File

@ -366,15 +366,6 @@ float getCltFuelCorrection() {
return interpolate2d(clt.Value, config->cltFuelCorrBins, config->cltFuelCorr);
}
angle_t getCltTimingCorrection() {
const auto clt = Sensor::get(SensorType::Clt);
if (!clt)
return 0; // this error should be already reported somewhere else, let's just handle it
return interpolate2d(clt.Value, config->cltTimingBins, config->cltTimingExtra);
}
float getIatFuelCorrection() {
const auto iat = Sensor::get(SensorType::Iat);

View File

@ -130,6 +130,19 @@ angle_t getRunningAdvance(float rpm, float engineLoad) {
return advanceAngle;
}
angle_t getCltTimingCorrection() {
const auto clt = Sensor::get(SensorType::Clt);
if (!clt)
return 0; // this error should be already reported somewhere else, let's just handle it
return interpolate2d(clt.Value, config->cltTimingBins, config->cltTimingExtra);
}
void IgnitionState::updateAdvanceCorrections() {
cltTimingCorrection = getCltTimingCorrection();
}
angle_t getAdvanceCorrections(float engineLoad) {
auto iat = Sensor::get(SensorType::Iat);

View File

@ -5,6 +5,8 @@
class IgnitionState : public ignition_state_s {
public:
void updateDwell(float rpm, bool isCranking);
void updateAdvanceCorrections();
floatms_t getDwell() const;
angle_t getWrappedAdvance(const float rpm, const float engineLoad);
private: