diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index c12f79293f..db7f869517 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -573,9 +573,8 @@ engine_configuration2_s::engine_configuration2_s() { } void engine_configuration2_s::precalc() { - //sparkTable.init() - //engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell, DWELL_CURVE_SIZE); - + sparkTable.init(DWELL_CURVE_SIZE, sparkAtable, sparkBtable); + sparkTable.preCalc(engineConfiguration->sparkDwellBins, engineConfiguration->sparkDwell); } void applyNonPersistentConfiguration(Logging * logger, Engine *engine) { diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index f43ad01d32..a931fe5b63 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -127,7 +127,7 @@ void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs) { scheduling_s * sDown = &signal->signalTimerDown[index]; scheduleTask("out up", sUp, (int) MS2US(delayMs), (schfunc_t) &turnPinHigh, (void *) signal->io_pin); - scheduleTask("out down", sDown, (int) MS2US(delayMs + durationMs), (schfunc_t) &turnPinLow, (void*) signal->io_pin); + scheduleTask("out down", sDown, (int) MS2US(delayMs) + MS2US(durationMs), (schfunc_t) &turnPinLow, (void*) signal->io_pin); } io_pin_e getPinByName(const char *name) { diff --git a/firmware/controllers/core/table_helper.cpp b/firmware/controllers/core/table_helper.cpp index a2d98210a9..3a5504297e 100644 --- a/firmware/controllers/core/table_helper.cpp +++ b/firmware/controllers/core/table_helper.cpp @@ -27,6 +27,7 @@ void Table2D::init(int size, float *aTable, float *bTable) { } void Table2D::preCalc(float *bin, float *values) { + this->bin = bin; for (int i = 0; i < size - 1; i++) { float x1 = bin[i]; float x2 = bin[i + 1]; diff --git a/firmware/controllers/core/table_helper.h b/firmware/controllers/core/table_helper.h index e2291adfd6..f6ad8ac760 100644 --- a/firmware/controllers/core/table_helper.h +++ b/firmware/controllers/core/table_helper.h @@ -32,6 +32,7 @@ public: int size; float *aTable; float *bTable; + float *bin; }; template diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 05ad483072..6269572cfc 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -34,15 +34,10 @@ extern "C" float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S); /** - * So that's how 'inline' syntax for both GCC and IAR - * It is interesting to mention that GCC compiler chooses not to inline this function. - * * @return time needed to rotate crankshaft by one degree, in milliseconds. - * @deprecated use at least Us, maybe event Nt + * @deprecated use at least Us, maybe even Nt */ -inline float getOneDegreeTimeMs(int rpm) { - return 1000.0f * 60 / 360 / rpm; -} +#define getOneDegreeTimeMs(rpm) (1000.0f * 60 / 360 / (rpm)) /** * @return time needed to rotate crankshaft by one degree, in microseconds. diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 958eba188a..d5f8a9cf4b 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -117,9 +117,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rp float delayMs = getOneDegreeTimeMs(rpm) * event->position.angleOffset; -// if (isCranking()) -// scheduleMsg(&logger, "crankingFuel=%f for CLT=%fC", fuelMs, getCoolantTemperature()); - if (event->isSimultanious) { if (fuelMs < 0) { firmwareError("duration cannot be negative: %d", fuelMs); @@ -141,7 +138,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rp scheduling_s * sDown = &signal->signalTimerDown[index]; scheduleTask("out up", sUp, (int) MS2US(delayMs), (schfunc_t) &startSimultaniousInjection, engine); - scheduleTask("out down", sDown, (int) MS2US(delayMs + fuelMs), (schfunc_t) &endSimultaniousInjection, engine); + scheduleTask("out down", sDown, (int) MS2US(delayMs) + MS2US(fuelMs), (schfunc_t) &endSimultaniousInjection, engine); } else { scheduleOutput(event->actuator, delayMs, fuelMs);