diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index 32a8a5d0ce..6b1c18a24a 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -70,6 +70,12 @@ int copyCompositeEvents(CompositeEvent *events) { #endif // EFI_UNIT_TEST +static void setToothLogReady(bool value) { +#if EFI_TUNER_STUDIO + tsOutputChannels.toothLogReady = value; +#endif // EFI_TUNER_STUDIO +} + static void SetNextCompositeEntry(efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX) { uint32_t nowUs = NT2US(timestamp); @@ -89,21 +95,15 @@ static void SetNextCompositeEntry(efitick_t timestamp DECLARE_ENGINE_PARAMETER_S //If we hit the end, loop if ((firstBuffer) && (NextIdx >= (COMPOSITE_PACKET_COUNT/2))) { /* first half is full */ -#if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = true; -#endif + setToothLogReady(true); firstBuffer = false; } if ((!firstBuffer) && (NextIdx >= sizeof(buffer) / sizeof(buffer[0]))) { -#if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = true; -#endif + setToothLogReady(true); NextIdx = 0; firstBuffer = true; } - /////tsOutputChannels.toothLogReady = true; - } void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX) { @@ -206,13 +206,13 @@ void EnableToothLogger() { // Enable logging of edges as they come ToothLoggerEnabled = true; -#if EFI_TUNER_STUDIO + // Tell TS that we're ready for it to read out the log // nb: this is a lie, as we may not have written anything // yet. However, we can let it continuously read out the buffer // as we update it, which looks pretty nice. - tsOutputChannels.toothLogReady = false; -#endif // EFI_TUNER_STUDIO + setToothLogReady(false); + } void EnableToothLoggerIfNotEnabled() { @@ -223,20 +223,18 @@ void EnableToothLoggerIfNotEnabled() { void DisableToothLogger() { ToothLoggerEnabled = false; -#if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = false; -#endif // EFI_TUNER_STUDIO + setToothLogReady(false); } ToothLoggerBuffer GetToothLoggerBuffer() { if (firstBuffer) { #if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = false; + setToothLogReady(false); #endif return { reinterpret_cast(ptr_buffer_second), (sizeof(buffer)/2) }; } else { #if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = false; + setToothLogReady(false); #endif return { reinterpret_cast(ptr_buffer_first), (sizeof(buffer)/2) }; }