diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp
index ccc9e25f01..04dfb536f1 100644
--- a/firmware/controllers/algo/engine.cpp
+++ b/firmware/controllers/algo/engine.cpp
@@ -205,7 +205,7 @@ void Engine::updateSlowSensors() {
#if EFI_ENGINE_CONTROL
int rpm = Sensor::getOrZero(SensorType::Rpm);
triggerCentral.isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold;
- sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;
+ getEngineState()->sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;
engineState.updateSlowSensors();
#endif
diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h
index dfb80ce8e1..f5d55f7bcf 100644
--- a/firmware/controllers/algo/engine.h
+++ b/firmware/controllers/algo/engine.h
@@ -223,10 +223,6 @@ public:
bool tdcMarkEnabled = true;
#endif // EFI_UNIT_TEST
- /**
- * this is based on sensorChartMode and sensorSnifferRpmThreshold settings
- */
- sensor_chart_e sensorChartMode = SC_OFF;
bool slowCallBackWasInvoked = false;
diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h
index 93bb9ecce0..1ebdc6e336 100644
--- a/firmware/controllers/algo/engine_state.h
+++ b/firmware/controllers/algo/engine_state.h
@@ -24,6 +24,11 @@ public:
*/
angle_t engineCycle;
+ /**
+ * this is based on sensorChartMode and sensorSnifferRpmThreshold settings
+ */
+ sensor_chart_e sensorChartMode = SC_OFF;
+
// Per-injection fuel mass, including TPS accel enrich
float injectionMass[MAX_CYLINDER_COUNT] = {0};
diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp
index f5e0d9cd77..8c803bc2e4 100644
--- a/firmware/controllers/engine_cycle/rpm_calculator.cpp
+++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp
@@ -313,7 +313,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
#if EFI_SENSOR_CHART
// this 'index==0' case is here so that it happens after cycle callback so
// it goes into sniffer report into the first position
- if (engine->sensorChartMode == SC_TRIGGER) {
+ if (getEngineState()->sensorChartMode == SC_TRIGGER) {
angle_t crankAngle = engine->triggerCentral.getCurrentEnginePhase(nowNt).value_or(0);
int signal = 1000 * ckpSignalType + trgEventIndex;
scAddData(crankAngle, signal);
diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp
index 0f5bb17407..b4c69694de 100644
--- a/firmware/controllers/trigger/trigger_decoder.cpp
+++ b/firmware/controllers/trigger/trigger_decoder.cpp
@@ -24,10 +24,38 @@
* If not, see .
*/
-#include "pch.h"
-
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "global.h"
+#include "efifeatures.h"
+#include "rusefi_generated.h"
+#include "loggingcentral.h"
+#include "error_handling.h"
+#include "efi_gpio.h"
+#include "tunerstudio_outputs.h"
+#include "engine.h"
+#include "engine_configuration.h"
+#include "engine_controller.h"
+#include "engine_math.h"
+#include "pwm_generator_logic.h"
+#include "perf_trace.h"
+#include
+#include "trigger_central.h"
+#include "trigger_decoder.h"
+#include "global.h"
+#include "sensor.h"
+#include "error_handling.h"
+#include "engine_state.h"
+#include "engine_math.h"
+#include "loggingcentral.h"
#include "obd_error_codes.h"
#include "trigger_decoder.h"
#include "cyclic_buffer.h"
@@ -324,7 +352,7 @@ void PrimaryTriggerDecoder::updateInstantRpm(
#if EFI_SENSOR_CHART
- if (engine->sensorChartMode == SC_RPM_ACCEL || engine->sensorChartMode == SC_DETAILED_RPM) {
+ if (getEngineState()->sensorChartMode == SC_RPM_ACCEL || getEngineState()->sensorChartMode == SC_DETAILED_RPM) {
angle_t currentAngle = triggerFormDetails->eventAngles[currentCycle.current_index];
if (engineConfiguration->sensorChartMode == SC_DETAILED_RPM) {
scAddData(currentAngle, m_instantRpm);
@@ -415,16 +443,16 @@ void PrimaryTriggerDecoder::onTriggerError() {
void PrimaryTriggerDecoder::onNotEnoughTeeth(int /*actual*/, int /*expected*/) {
warning(CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, "primary trigger error: not enough teeth between sync points: expected %d/%d got %d/%d",
- TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_PRIMARY)),
- TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_SECONDARY)),
+ getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
+ getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
currentCycle.eventCount[0],
currentCycle.eventCount[1]);
}
void PrimaryTriggerDecoder::onTooManyTeeth(int /*actual*/, int /*expected*/) {
warning(CUSTOM_PRIMARY_TOO_MANY_TEETH, "primary trigger error: too many teeth between sync points: expected %d/%d got %d/%d",
- TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_PRIMARY)),
- TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_SECONDARY)),
+ getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
+ getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
currentCycle.eventCount[0],
currentCycle.eventCount[1]);
}
diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp
index ee22741efd..9e7d8f6dce 100644
--- a/firmware/hw_layer/hardware.cpp
+++ b/firmware/hw_layer/hardware.cpp
@@ -180,7 +180,7 @@ void onFastAdcComplete(adcsample_t*) {
efiAssertVoid(CUSTOM_STACK_ADC, getCurrentRemainingStack() > 128, "lowstck#9b");
#if EFI_SENSOR_CHART && EFI_SHAFT_POSITION_INPUT
- if (engine->sensorChartMode == SC_AUX_FAST1) {
+ if (getEngineState()->sensorChartMode == SC_AUX_FAST1) {
float voltage = getAdcValue("fAux1", engineConfiguration->auxFastSensor1_adcChannel);
scAddData(engine->triggerCentral.getCurrentEnginePhase(getTimeNowNt()).value_or(0), voltage);
}