diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 83636ca4d0..893143a109 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -24,7 +24,7 @@ #include "trigger_simulator.h" #include "rpm_calculator.h" - +#include "tooth_logger.h" #include "perf_trace.h" #if EFI_PROD_CODE @@ -103,13 +103,33 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt DECLARE_ENGINE_ tc->vvtEventFallCounter++; } + if (!CONFIG(displayLogicLevelsInEngineSniffer)) { + addEngineSnifferEvent(PROTOCOL_VVT_NAME, front == TV_RISE ? PROTOCOL_ES_UP : PROTOCOL_ES_DOWN); + } - addEngineSnifferEvent(PROTOCOL_VVT_NAME, front == TV_RISE ? PROTOCOL_ES_UP : PROTOCOL_ES_DOWN); if (CONFIG(vvtCamSensorUseRise) ^ (front != TV_FALL)) { return; } + if (CONFIG(displayLogicLevelsInEngineSniffer)) { + if (CONFIG(vvtCamSensorUseRise)) { + // todo: unify TS composite logger code with console Engine Sniffer + // todo: better API to reduce copy/paste? + LogTriggerTooth(SHAFT_SECONDARY_RISING, nowNt); + LogTriggerTooth(SHAFT_SECONDARY_FALLING, nowNt); + + addEngineSnifferEvent(PROTOCOL_VVT_NAME, PROTOCOL_ES_UP); + addEngineSnifferEvent(PROTOCOL_VVT_NAME, PROTOCOL_ES_DOWN); + } else { + LogTriggerTooth(SHAFT_SECONDARY_FALLING, nowNt); + LogTriggerTooth(SHAFT_SECONDARY_RISING, nowNt); + + addEngineSnifferEvent(PROTOCOL_VVT_NAME, PROTOCOL_ES_DOWN); + addEngineSnifferEvent(PROTOCOL_VVT_NAME, PROTOCOL_ES_UP); + } + } + floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs; if (cisnan(oneDegreeUs)) { // we are here if we are getting VVT position signals while engine is not running diff --git a/firmware/hw_layer/trigger_input_icu.cpp b/firmware/hw_layer/trigger_input_icu.cpp index ab193386d7..d3abca5554 100644 --- a/firmware/hw_layer/trigger_input_icu.cpp +++ b/firmware/hw_layer/trigger_input_icu.cpp @@ -30,7 +30,10 @@ static Logging *logger; static void vvtRisingCallback(void *) { efitick_t now = getTimeNowNt(); #if EFI_TOOTH_LOGGER - LogTriggerTooth(SHAFT_SECONDARY_RISING, now); + if (!CONFIG(displayLogicLevelsInEngineSniffer)) { + // real physical fronts go into engine sniffer + LogTriggerTooth(SHAFT_SECONDARY_RISING, now); + } #endif /* EFI_TOOTH_LOGGER */ hwHandleVvtCamSignal(TV_RISE, now); } @@ -38,7 +41,9 @@ static void vvtRisingCallback(void *) { static void vvtFallingCallback(void *) { efitick_t now = getTimeNowNt(); #if EFI_TOOTH_LOGGER - LogTriggerTooth(SHAFT_SECONDARY_FALLING, now); + if (!CONFIG(displayLogicLevelsInEngineSniffer)) { + LogTriggerTooth(SHAFT_SECONDARY_FALLING, now); + } #endif /* EFI_TOOTH_LOGGER */ hwHandleVvtCamSignal(TV_FALL, now); }