diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp index 0ddc80e3d0..12c5893ffc 100644 --- a/firmware/console/binary/tooth_logger.cpp +++ b/firmware/console/binary/tooth_logger.cpp @@ -72,7 +72,7 @@ int copyCompositeEvents(CompositeEvent *events) { static void setToothLogReady(bool value) { #if EFI_TUNER_STUDIO - tsOutputChannels.toothLogReady = value; + engine->outputChannels.toothLogReady = value; #endif // EFI_TUNER_STUDIO } diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 94e649da3c..38025367e1 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -91,7 +91,7 @@ static void printErrorCounters() { efiPrintf("TunerStudio size=%d / total=%d / errors=%d / H=%d / O=%d / P=%d / B=%d", - sizeof(tsOutputChannels), tsState.totalCounter, tsState.errorCounter, tsState.queryCommandCounter, + sizeof(engine->outputChannels), tsState.totalCounter, tsState.errorCounter, tsState.queryCommandCounter, tsState.outputChannelsCommandCounter, tsState.readPageCommandsCounter, tsState.burnCommandCounter); efiPrintf("TunerStudio W=%d / C=%d / P=%d", tsState.writeValueCommandCounter, tsState.writeChunkCommandCounter, tsState.pageCommandCounter); @@ -529,7 +529,6 @@ void TunerstudioThread::ThreadTask() { #endif // EFI_TUNER_STUDIO tunerstudio_counters_s tsState; -TunerStudioOutputChannels tsOutputChannels; void tunerStudioError(TsChannelBase* tsChannel, const char *msg) { tunerStudioDebug(tsChannel, msg); @@ -723,9 +722,9 @@ int TunerStudioBase::handleCrcCommand(TsChannelBase* tsChannel, char *data, int uint16_t index = SWAP_UINT16(data16[1]); if (engineConfiguration->debugMode == DBG_BENCH_TEST) { - tsOutputChannels.debugIntField1++; - tsOutputChannels.debugIntField2 = subsystem; - tsOutputChannels.debugIntField3 = index; + engine->outputChannels.debugIntField1++; + engine->outputChannels.debugIntField2 = subsystem; + engine->outputChannels.debugIntField3 = index; } #if EFI_PROD_CODE && EFI_ENGINE_CONTROL @@ -763,8 +762,8 @@ int TunerStudioBase::handleCrcCommand(TsChannelBase* tsChannel, char *data, int // set debug_mode 40 if (engineConfiguration->debugMode == DBG_COMPOSITE_LOG) { - tsOutputChannels.debugIntField1 = currentEnd; - tsOutputChannels.debugIntField2 = transmitted; + engine->outputChannels.debugIntField1 = currentEnd; + engine->outputChannels.debugIntField2 = transmitted; } diff --git a/firmware/console/binary/tunerstudio_commands.cpp b/firmware/console/binary/tunerstudio_commands.cpp index 2b55109b0b..8ce82b7135 100644 --- a/firmware/console/binary/tunerstudio_commands.cpp +++ b/firmware/console/binary/tunerstudio_commands.cpp @@ -23,7 +23,7 @@ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, u tsState.outputChannelsCommandCounter++; prepareTunerStudioOutputs(); // this method is invoked too often to print any debug information - tsChannel->sendResponse(TS_CRC, reinterpret_cast(&tsOutputChannels) + offset, count); + tsChannel->sendResponse(TS_CRC, reinterpret_cast(&engine->outputChannels) + offset, count); } #endif // EFI_TUNER_STUDIO diff --git a/firmware/console/binary/tunerstudio_outputs.h b/firmware/console/binary/tunerstudio_outputs.h index f865fe339c..970f33364b 100644 --- a/firmware/console/binary/tunerstudio_outputs.h +++ b/firmware/console/binary/tunerstudio_outputs.h @@ -48,5 +48,3 @@ struct TunerStudioOutputChannels : ts_outputs_s { } }; - -extern TunerStudioOutputChannels tsOutputChannels; diff --git a/firmware/console/binary_log/binary_logging.cpp b/firmware/console/binary_log/binary_logging.cpp index eae8b71a56..0d6fc7d445 100644 --- a/firmware/console/binary_log/binary_logging.cpp +++ b/firmware/console/binary_log/binary_logging.cpp @@ -18,104 +18,104 @@ static scaled_channel packedTime; // todo: we are at the edge of sdLogBuffer size and at the moment we have no code to make sure buffer does not overflow // todo: make this logic smarter static constexpr LogField fields[] = { - {tsOutputChannels.RPMValue, GAUGE_NAME_RPM, "rpm", 0}, + {engine->outputChannels.RPMValue, GAUGE_NAME_RPM, "rpm", 0}, {packedTime, GAUGE_NAME_TIME, "sec", 0}, - {tsOutputChannels.totalTriggerErrorCounter, GAUGE_NAME_TRG_ERR, "err", 0}, - {tsOutputChannels.vehicleSpeedKph, GAUGE_NAME_VVS, "kph", 0}, - {tsOutputChannels.internalMcuTemperature, GAUGE_NAME_CPU_TEMP, "C", 0}, - {tsOutputChannels.coolant, GAUGE_NAME_CLT, "C", 1}, - {tsOutputChannels.intake, GAUGE_NAME_IAT, "C", 1}, - {tsOutputChannels.auxTemp1, GAUGE_NAME_AUX_TEMP1, "C", 1}, - {tsOutputChannels.auxTemp2, GAUGE_NAME_AUX_TEMP2, "C", 1}, - {tsOutputChannels.throttlePedalPosition, GAUGE_NAME_TPS, "%", 2}, - {tsOutputChannels.TPS2Value, GAUGE_NAME_TPS2, "%", 2}, - {tsOutputChannels.throttlePedalPosition, GAUGE_NAME_THROTTLE_PEDAL, "%", 2}, - {tsOutputChannels.MAPValue, GAUGE_NAME_MAP, "kPa", 1}, - {tsOutputChannels.AFRValue, GAUGE_NAME_AFR, "afr", 2}, - {tsOutputChannels.AFRValue2, GAUGE_NAME_AFR2, "afr", 2}, - {tsOutputChannels.lambdaValue, GAUGE_NAME_LAMBDA, "", 3}, - {tsOutputChannels.lambdaValue2, GAUGE_NAME_LAMBDA2, "", 3}, - {tsOutputChannels.warningCounter, GAUGE_NAME_WARNING_COUNTER, "", 0}, - {tsOutputChannels.lastErrorCode, GAUGE_NAME_WARNING_LAST, "", 0}, - {tsOutputChannels.tuneCrc16, GAUGE_NAME_TUNE_CRC16, "", 0}, - {tsOutputChannels.engineMakeCodeNameCrc16, GAUGE_NAME_ENGINE_CRC16, "", 0}, + {engine->outputChannels.totalTriggerErrorCounter, GAUGE_NAME_TRG_ERR, "err", 0}, + {engine->outputChannels.vehicleSpeedKph, GAUGE_NAME_VVS, "kph", 0}, + {engine->outputChannels.internalMcuTemperature, GAUGE_NAME_CPU_TEMP, "C", 0}, + {engine->outputChannels.coolant, GAUGE_NAME_CLT, "C", 1}, + {engine->outputChannels.intake, GAUGE_NAME_IAT, "C", 1}, + {engine->outputChannels.auxTemp1, GAUGE_NAME_AUX_TEMP1, "C", 1}, + {engine->outputChannels.auxTemp2, GAUGE_NAME_AUX_TEMP2, "C", 1}, + {engine->outputChannels.throttlePedalPosition, GAUGE_NAME_TPS, "%", 2}, + {engine->outputChannels.TPS2Value, GAUGE_NAME_TPS2, "%", 2}, + {engine->outputChannels.throttlePedalPosition, GAUGE_NAME_THROTTLE_PEDAL, "%", 2}, + {engine->outputChannels.MAPValue, GAUGE_NAME_MAP, "kPa", 1}, + {engine->outputChannels.AFRValue, GAUGE_NAME_AFR, "afr", 2}, + {engine->outputChannels.AFRValue2, GAUGE_NAME_AFR2, "afr", 2}, + {engine->outputChannels.lambdaValue, GAUGE_NAME_LAMBDA, "", 3}, + {engine->outputChannels.lambdaValue2, GAUGE_NAME_LAMBDA2, "", 3}, + {engine->outputChannels.warningCounter, GAUGE_NAME_WARNING_COUNTER, "", 0}, + {engine->outputChannels.lastErrorCode, GAUGE_NAME_WARNING_LAST, "", 0}, + {engine->outputChannels.tuneCrc16, GAUGE_NAME_TUNE_CRC16, "", 0}, + {engine->outputChannels.engineMakeCodeNameCrc16, GAUGE_NAME_ENGINE_CRC16, "", 0}, - {tsOutputChannels.firmwareVersion, GAUGE_NAME_VERSION, "", 0}, - {tsOutputChannels.accelerationX, GAUGE_NAME_ACCEL_X, "", 2}, - {tsOutputChannels.accelerationY, GAUGE_NAME_ACCEL_Y, "", 2}, - {tsOutputChannels.accelerationZ, GAUGE_NAME_ACCEL_Z, "", 2}, - {tsOutputChannels.accelerationRoll, GAUGE_NAME_ACCEL_ROLL, "", 2}, - {tsOutputChannels.accelerationYaw, GAUGE_NAME_ACCEL_YAW, "", 2}, + {engine->outputChannels.firmwareVersion, GAUGE_NAME_VERSION, "", 0}, + {engine->outputChannels.accelerationX, GAUGE_NAME_ACCEL_X, "", 2}, + {engine->outputChannels.accelerationY, GAUGE_NAME_ACCEL_Y, "", 2}, + {engine->outputChannels.accelerationZ, GAUGE_NAME_ACCEL_Z, "", 2}, + {engine->outputChannels.accelerationRoll, GAUGE_NAME_ACCEL_ROLL, "", 2}, + {engine->outputChannels.accelerationYaw, GAUGE_NAME_ACCEL_YAW, "", 2}, - {tsOutputChannels.debugIntField1, GAUGE_NAME_DEBUG_I1, "", 0}, - {tsOutputChannels.debugIntField2, GAUGE_NAME_DEBUG_I2, "", 0}, - {tsOutputChannels.debugIntField3, GAUGE_NAME_DEBUG_I3, "", 0}, - {tsOutputChannels.debugIntField4, GAUGE_NAME_DEBUG_I4, "", 0}, - {tsOutputChannels.debugIntField5, GAUGE_NAME_DEBUG_I5, "", 0}, - {tsOutputChannels.debugFloatField1, GAUGE_NAME_DEBUG_F1, "", 3}, - {tsOutputChannels.debugFloatField2, GAUGE_NAME_DEBUG_F2, "", 3}, - {tsOutputChannels.debugFloatField3, GAUGE_NAME_DEBUG_F3, "", 3}, - {tsOutputChannels.debugFloatField4, GAUGE_NAME_DEBUG_F4, "", 3}, - {tsOutputChannels.debugFloatField5, GAUGE_NAME_DEBUG_F5, "", 3}, - {tsOutputChannels.debugFloatField6, GAUGE_NAME_DEBUG_F6, "", 3}, - {tsOutputChannels.debugFloatField7, GAUGE_NAME_DEBUG_F7, "", 3}, - {tsOutputChannels.VBatt, GAUGE_NAME_VBAT, "v", 2}, - {tsOutputChannels.oilPressure, GAUGE_NAME_OIL_PRESSURE, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0}, - {tsOutputChannels.lowFuelPressure, GAUGE_NAME_FUEL_PRESSURE_LOW, GAUGE_NAME_FUEL_PRESSURE_LOW_UNITS, 0}, - {tsOutputChannels.highFuelPressure, GAUGE_NAME_FUEL_PRESSURE_HIGH, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0}, - {tsOutputChannels.vvtPositionB1I, GAUGE_NAME_VVT_B1I, "deg", 1}, - {tsOutputChannels.vvtPositionB1E, GAUGE_NAME_VVT_B1E, "deg", 1}, - {tsOutputChannels.vvtPositionB2I, GAUGE_NAME_VVT_B2I, "deg", 1}, - {tsOutputChannels.vvtPositionB2E, GAUGE_NAME_VVT_B2E, "deg", 1}, - {tsOutputChannels.vvtTargets[0], GAUGE_NAME_VVT_TARGET_B1I, "deg", 0}, - {tsOutputChannels.vvtTargets[1], GAUGE_NAME_VVT_TARGET_B1E, "deg", 0}, - {tsOutputChannels.vvtTargets[2], GAUGE_NAME_VVT_TARGET_B2I, "deg", 0}, - {tsOutputChannels.vvtTargets[3], GAUGE_NAME_VVT_TARGET_B2E, "deg", 0}, - {tsOutputChannels.wastegatePositionSensor, GAUGE_NAME_WG_POSITION, "%", 2}, - {tsOutputChannels.idlePositionSensor, GAUGE_NAME_IDLE_POSITION, "%", 2}, - {tsOutputChannels.chargeAirMass, GAUGE_NAME_AIR_MASS, "g", 3}, - {tsOutputChannels.currentTargetAfr, GAUGE_NAME_TARGET_AFR, "afr", 2}, - {tsOutputChannels.targetLambda, GAUGE_NAME_TARGET_LAMBDA, "", 3}, - {tsOutputChannels.baseFuel, GAUGE_NAME_FUEL_BASE, "ms", 3}, - {tsOutputChannels.fuelRunning, GAUGE_NAME_FUEL_RUNNING, "ms", 3}, - {tsOutputChannels.actualLastInjection, GAUGE_NAME_FUEL_LAST_INJECTION, "ms", 3}, - {tsOutputChannels.injectorDutyCycle, GAUGE_NAME_FUEL_INJ_DUTY, "%", 0}, - {tsOutputChannels.veValue, GAUGE_NAME_FUEL_VE, "%", 1}, - {tsOutputChannels.tCharge, GAUGE_NAME_TCHARGE, "C", 1}, - {tsOutputChannels.injectorLagMs, GAUGE_NAME_INJECTOR_LAG, "ms", 3}, - {tsOutputChannels.fuelPidCorrection[0], GAUGE_NAME_FUEL_TRIM, "%", 2}, - {tsOutputChannels.fuelPidCorrection[1], GAUGE_NAME_FUEL_TRIM_2, "%", 2}, - {tsOutputChannels.wallFuelCorrection, GAUGE_NAME_FUEL_WALL_CORRECTION, "ms", 3}, - {tsOutputChannels.tpsAccelFuel, GAUGE_NAME_FUEL_TPS_EXTRA, "ms", 3}, - {tsOutputChannels.ignitionAdvance, GAUGE_NAME_TIMING_ADVANCE, "deg", 1}, - {tsOutputChannels.sparkDwellValue, GAUGE_COIL_DWELL_TIME, "ms", 1}, - {tsOutputChannels.coilDutyCycle, GAUGE_NAME_DWELL_DUTY, "%", 0}, - {tsOutputChannels.idleAirValvePosition, GAUGE_NAME_IAC, "%", 1}, - {tsOutputChannels.etbTarget, GAUGE_NAME_ETB_TARGET, "%", 2}, - {tsOutputChannels.etb1DutyCycle, GAUGE_NAME_ETB_DUTY, "%", 1}, - {tsOutputChannels.etb1Error, GAUGE_NAME_ETB_ERROR, "%", 3}, - {tsOutputChannels.fuelTankLevel, GAUGE_NAME_FUEL_LEVEL, "%", 0}, - {tsOutputChannels.fuelingLoad, GAUGE_NAME_FUEL_LOAD, "%", 1}, - {tsOutputChannels.ignitionLoad, GAUGE_NAME_IGNITION_LOAD, "%", 1}, - {tsOutputChannels.massAirFlowValue, GAUGE_NAME_AIR_FLOW, "kg/h", 1}, - {tsOutputChannels.tcuDesiredGear, GAUGE_NAME_DESIRED_GEAR, "gear", 0}, - {tsOutputChannels.tcuCurrentGear, GAUGE_NAME_CURRENT_GEAR, "gear", 0}, - {tsOutputChannels.flexPercent, GAUGE_NAME_FLEX, "%", 1}, - {tsOutputChannels.fuelFlowRate, GAUGE_NAME_FUEL_FLOW, "g/s", 3}, - {tsOutputChannels.totalFuelConsumption, GAUGE_NAME_FUEL_CONSUMPTION, "g", 1}, - {tsOutputChannels.knockLevel, GAUGE_NAME_KNOCK_LEVEL, "dBv", 0}, - {tsOutputChannels.knock[0], GAUGE_NAME_KNOCK_1, "dBv", 0}, - {tsOutputChannels.knock[1], GAUGE_NAME_KNOCK_2, "dBv", 0}, - {tsOutputChannels.knock[2], GAUGE_NAME_KNOCK_3, "dBv", 0}, - {tsOutputChannels.knock[3], GAUGE_NAME_KNOCK_4, "dBv", 0}, - {tsOutputChannels.knock[4], GAUGE_NAME_KNOCK_5, "dBv", 0}, - {tsOutputChannels.knock[5], GAUGE_NAME_KNOCK_6, "dBv", 0}, - {tsOutputChannels.knock[6], GAUGE_NAME_KNOCK_7, "dBv", 0}, - {tsOutputChannels.knock[7], GAUGE_NAME_KNOCK_8, "dBv", 0}, - {tsOutputChannels.knock[8], GAUGE_NAME_KNOCK_9, "dBv", 0}, - {tsOutputChannels.knock[9], GAUGE_NAME_KNOCK_10, "dBv", 0}, - {tsOutputChannels.knock[10], GAUGE_NAME_KNOCK_11, "dBv", 0}, - {tsOutputChannels.knock[11], GAUGE_NAME_KNOCK_12, "dBv", 0}, + {engine->outputChannels.debugIntField1, GAUGE_NAME_DEBUG_I1, "", 0}, + {engine->outputChannels.debugIntField2, GAUGE_NAME_DEBUG_I2, "", 0}, + {engine->outputChannels.debugIntField3, GAUGE_NAME_DEBUG_I3, "", 0}, + {engine->outputChannels.debugIntField4, GAUGE_NAME_DEBUG_I4, "", 0}, + {engine->outputChannels.debugIntField5, GAUGE_NAME_DEBUG_I5, "", 0}, + {engine->outputChannels.debugFloatField1, GAUGE_NAME_DEBUG_F1, "", 3}, + {engine->outputChannels.debugFloatField2, GAUGE_NAME_DEBUG_F2, "", 3}, + {engine->outputChannels.debugFloatField3, GAUGE_NAME_DEBUG_F3, "", 3}, + {engine->outputChannels.debugFloatField4, GAUGE_NAME_DEBUG_F4, "", 3}, + {engine->outputChannels.debugFloatField5, GAUGE_NAME_DEBUG_F5, "", 3}, + {engine->outputChannels.debugFloatField6, GAUGE_NAME_DEBUG_F6, "", 3}, + {engine->outputChannels.debugFloatField7, GAUGE_NAME_DEBUG_F7, "", 3}, + {engine->outputChannels.VBatt, GAUGE_NAME_VBAT, "v", 2}, + {engine->outputChannels.oilPressure, GAUGE_NAME_OIL_PRESSURE, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0}, + {engine->outputChannels.lowFuelPressure, GAUGE_NAME_FUEL_PRESSURE_LOW, GAUGE_NAME_FUEL_PRESSURE_LOW_UNITS, 0}, + {engine->outputChannels.highFuelPressure, GAUGE_NAME_FUEL_PRESSURE_HIGH, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0}, + {engine->outputChannels.vvtPositionB1I, GAUGE_NAME_VVT_B1I, "deg", 1}, + {engine->outputChannels.vvtPositionB1E, GAUGE_NAME_VVT_B1E, "deg", 1}, + {engine->outputChannels.vvtPositionB2I, GAUGE_NAME_VVT_B2I, "deg", 1}, + {engine->outputChannels.vvtPositionB2E, GAUGE_NAME_VVT_B2E, "deg", 1}, + {engine->outputChannels.vvtTargets[0], GAUGE_NAME_VVT_TARGET_B1I, "deg", 0}, + {engine->outputChannels.vvtTargets[1], GAUGE_NAME_VVT_TARGET_B1E, "deg", 0}, + {engine->outputChannels.vvtTargets[2], GAUGE_NAME_VVT_TARGET_B2I, "deg", 0}, + {engine->outputChannels.vvtTargets[3], GAUGE_NAME_VVT_TARGET_B2E, "deg", 0}, + {engine->outputChannels.wastegatePositionSensor, GAUGE_NAME_WG_POSITION, "%", 2}, + {engine->outputChannels.idlePositionSensor, GAUGE_NAME_IDLE_POSITION, "%", 2}, + {engine->outputChannels.chargeAirMass, GAUGE_NAME_AIR_MASS, "g", 3}, + {engine->outputChannels.currentTargetAfr, GAUGE_NAME_TARGET_AFR, "afr", 2}, + {engine->outputChannels.targetLambda, GAUGE_NAME_TARGET_LAMBDA, "", 3}, + {engine->outputChannels.baseFuel, GAUGE_NAME_FUEL_BASE, "ms", 3}, + {engine->outputChannels.fuelRunning, GAUGE_NAME_FUEL_RUNNING, "ms", 3}, + {engine->outputChannels.actualLastInjection, GAUGE_NAME_FUEL_LAST_INJECTION, "ms", 3}, + {engine->outputChannels.injectorDutyCycle, GAUGE_NAME_FUEL_INJ_DUTY, "%", 0}, + {engine->outputChannels.veValue, GAUGE_NAME_FUEL_VE, "%", 1}, + {engine->outputChannels.tCharge, GAUGE_NAME_TCHARGE, "C", 1}, + {engine->outputChannels.injectorLagMs, GAUGE_NAME_INJECTOR_LAG, "ms", 3}, + {engine->outputChannels.fuelPidCorrection[0], GAUGE_NAME_FUEL_TRIM, "%", 2}, + {engine->outputChannels.fuelPidCorrection[1], GAUGE_NAME_FUEL_TRIM_2, "%", 2}, + {engine->outputChannels.wallFuelCorrection, GAUGE_NAME_FUEL_WALL_CORRECTION, "ms", 3}, + {engine->outputChannels.tpsAccelFuel, GAUGE_NAME_FUEL_TPS_EXTRA, "ms", 3}, + {engine->outputChannels.ignitionAdvance, GAUGE_NAME_TIMING_ADVANCE, "deg", 1}, + {engine->outputChannels.sparkDwellValue, GAUGE_COIL_DWELL_TIME, "ms", 1}, + {engine->outputChannels.coilDutyCycle, GAUGE_NAME_DWELL_DUTY, "%", 0}, + {engine->outputChannels.idleAirValvePosition, GAUGE_NAME_IAC, "%", 1}, + {engine->outputChannels.etbTarget, GAUGE_NAME_ETB_TARGET, "%", 2}, + {engine->outputChannels.etb1DutyCycle, GAUGE_NAME_ETB_DUTY, "%", 1}, + {engine->outputChannels.etb1Error, GAUGE_NAME_ETB_ERROR, "%", 3}, + {engine->outputChannels.fuelTankLevel, GAUGE_NAME_FUEL_LEVEL, "%", 0}, + {engine->outputChannels.fuelingLoad, GAUGE_NAME_FUEL_LOAD, "%", 1}, + {engine->outputChannels.ignitionLoad, GAUGE_NAME_IGNITION_LOAD, "%", 1}, + {engine->outputChannels.massAirFlowValue, GAUGE_NAME_AIR_FLOW, "kg/h", 1}, + {engine->outputChannels.tcuDesiredGear, GAUGE_NAME_DESIRED_GEAR, "gear", 0}, + {engine->outputChannels.tcuCurrentGear, GAUGE_NAME_CURRENT_GEAR, "gear", 0}, + {engine->outputChannels.flexPercent, GAUGE_NAME_FLEX, "%", 1}, + {engine->outputChannels.fuelFlowRate, GAUGE_NAME_FUEL_FLOW, "g/s", 3}, + {engine->outputChannels.totalFuelConsumption, GAUGE_NAME_FUEL_CONSUMPTION, "g", 1}, + {engine->outputChannels.knockLevel, GAUGE_NAME_KNOCK_LEVEL, "dBv", 0}, + {engine->outputChannels.knock[0], GAUGE_NAME_KNOCK_1, "dBv", 0}, + {engine->outputChannels.knock[1], GAUGE_NAME_KNOCK_2, "dBv", 0}, + {engine->outputChannels.knock[2], GAUGE_NAME_KNOCK_3, "dBv", 0}, + {engine->outputChannels.knock[3], GAUGE_NAME_KNOCK_4, "dBv", 0}, + {engine->outputChannels.knock[4], GAUGE_NAME_KNOCK_5, "dBv", 0}, + {engine->outputChannels.knock[5], GAUGE_NAME_KNOCK_6, "dBv", 0}, + {engine->outputChannels.knock[6], GAUGE_NAME_KNOCK_7, "dBv", 0}, + {engine->outputChannels.knock[7], GAUGE_NAME_KNOCK_8, "dBv", 0}, + {engine->outputChannels.knock[8], GAUGE_NAME_KNOCK_9, "dBv", 0}, + {engine->outputChannels.knock[9], GAUGE_NAME_KNOCK_10, "dBv", 0}, + {engine->outputChannels.knock[10], GAUGE_NAME_KNOCK_11, "dBv", 0}, + {engine->outputChannels.knock[11], GAUGE_NAME_KNOCK_12, "dBv", 0}, }; static constexpr uint16_t computeFieldsRecordLength() { diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 5d8c058024..11cb92662e 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -136,7 +136,7 @@ void writeLogLine(Writer& buffer) { if (binaryLogCount == 0) { writeHeader(buffer); } else { - updateTunerStudioState(&tsOutputChannels); + updateTunerStudioState(&engine->outputChannels); size_t length = writeBlock(sdLogBuffer); efiAssertVoid(OBD_PCM_Processor_Fault, length <= efi::size(sdLogBuffer), "SD log buffer overflow"); buffer.write(sdLogBuffer, length); @@ -457,111 +457,111 @@ extern HIP9011 instance; static void updateTempSensors() { SensorResult clt = Sensor::get(SensorType::Clt); - tsOutputChannels.coolant = clt.Value; - tsOutputChannels.isCltError = !clt.Valid; + engine->outputChannels.coolant = clt.Value; + engine->outputChannels.isCltError = !clt.Valid; SensorResult iat = Sensor::get(SensorType::Iat); - tsOutputChannels.intake = iat.Value; - tsOutputChannels.isIatError = !iat.Valid; + engine->outputChannels.intake = iat.Value; + engine->outputChannels.isIatError = !iat.Valid; SensorResult auxTemp1 = Sensor::get(SensorType::AuxTemp1); - tsOutputChannels.auxTemp1 = auxTemp1.Value; + engine->outputChannels.auxTemp1 = auxTemp1.Value; SensorResult auxTemp2 = Sensor::get(SensorType::AuxTemp2); - tsOutputChannels.auxTemp2 = auxTemp2.Value; + engine->outputChannels.auxTemp2 = auxTemp2.Value; } static void updateThrottles() { SensorResult tps1 = Sensor::get(SensorType::Tps1); - tsOutputChannels.TPSValue = tps1.Value; - tsOutputChannels.isTpsError = !tps1.Valid; - tsOutputChannels.tpsADC = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1Primary)); + engine->outputChannels.TPSValue = tps1.Value; + engine->outputChannels.isTpsError = !tps1.Valid; + engine->outputChannels.tpsADC = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1Primary)); SensorResult tps2 = Sensor::get(SensorType::Tps2); - tsOutputChannels.TPS2Value = tps2.Value; + engine->outputChannels.TPS2Value = tps2.Value; // If we don't have a TPS2 at all, don't turn on the failure light - tsOutputChannels.isTps2Error = !tps2.Valid && Sensor::hasSensor(SensorType::Tps2Primary); + engine->outputChannels.isTps2Error = !tps2.Valid && Sensor::hasSensor(SensorType::Tps2Primary); SensorResult pedal = Sensor::get(SensorType::AcceleratorPedal); - tsOutputChannels.throttlePedalPosition = pedal.Value; + engine->outputChannels.throttlePedalPosition = pedal.Value; // Only report fail if you have one (many people don't) - tsOutputChannels.isPedalError = !pedal.Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); + engine->outputChannels.isPedalError = !pedal.Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); } static void updateLambda() { float lambdaValue = Sensor::getOrZero(SensorType::Lambda1); - tsOutputChannels.lambdaValue = lambdaValue; - tsOutputChannels.AFRValue = lambdaValue * engine->engineState.stoichiometricRatio; + engine->outputChannels.lambdaValue = lambdaValue; + engine->outputChannels.AFRValue = lambdaValue * engine->engineState.stoichiometricRatio; float lambda2Value = Sensor::getOrZero(SensorType::Lambda2); - tsOutputChannels.lambdaValue2 = lambda2Value; - tsOutputChannels.AFRValue2 = lambda2Value * engine->engineState.stoichiometricRatio; + engine->outputChannels.lambdaValue2 = lambda2Value; + engine->outputChannels.AFRValue2 = lambda2Value * engine->engineState.stoichiometricRatio; } static void updateFuelSensors() { // Low pressure is directly in kpa - tsOutputChannels.lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).Value; + engine->outputChannels.lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).Value; // High pressure is in bar, aka 100 kpa - tsOutputChannels.highFuelPressure = KPA2BAR(Sensor::get(SensorType::FuelPressureHigh).Value); + engine->outputChannels.highFuelPressure = KPA2BAR(Sensor::get(SensorType::FuelPressureHigh).Value); - tsOutputChannels.flexPercent = Sensor::get(SensorType::FuelEthanolPercent).Value; + engine->outputChannels.flexPercent = Sensor::get(SensorType::FuelEthanolPercent).Value; - tsOutputChannels.fuelTankLevel = Sensor::getOrZero(SensorType::FuelLevel); + engine->outputChannels.fuelTankLevel = Sensor::getOrZero(SensorType::FuelLevel); } static void updateVvtSensors() { #if EFI_SHAFT_POSITION_INPUT // 248 - tsOutputChannels.vvtPositionB1I = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); - tsOutputChannels.vvtPositionB1E = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/1); - tsOutputChannels.vvtPositionB2I = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/0); - tsOutputChannels.vvtPositionB2E = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/1); + engine->outputChannels.vvtPositionB1I = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); + engine->outputChannels.vvtPositionB1E = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/1); + engine->outputChannels.vvtPositionB2I = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/0); + engine->outputChannels.vvtPositionB2E = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/1); #endif } static void updateVehicleSpeed(int rpm) { #if EFI_VEHICLE_SPEED float vehicleSpeed = Sensor::getOrZero(SensorType::VehicleSpeed); - tsOutputChannels.vehicleSpeedKph = vehicleSpeed; - tsOutputChannels.speedToRpmRatio = vehicleSpeed / rpm; + engine->outputChannels.vehicleSpeedKph = vehicleSpeed; + engine->outputChannels.speedToRpmRatio = vehicleSpeed / rpm; #endif /* EFI_VEHICLE_SPEED */ } static void updateRawSensors() { - tsOutputChannels.rawTps1Primary = Sensor::getRaw(SensorType::Tps1Primary); - tsOutputChannels.rawTps1Secondary = Sensor::getRaw(SensorType::Tps1Secondary); - tsOutputChannels.rawTps2Primary = Sensor::getRaw(SensorType::Tps2Primary); - tsOutputChannels.rawTps2Secondary = Sensor::getRaw(SensorType::Tps2Secondary); - tsOutputChannels.rawPpsPrimary = Sensor::getRaw(SensorType::AcceleratorPedalPrimary); - tsOutputChannels.rawPpsSecondary = Sensor::getRaw(SensorType::AcceleratorPedalSecondary); - tsOutputChannels.rawClt = Sensor::getRaw(SensorType::Clt); - tsOutputChannels.rawIat = Sensor::getRaw(SensorType::Iat); - tsOutputChannels.rawOilPressure = Sensor::getRaw(SensorType::OilPressure); - tsOutputChannels.rawLowFuelPressure = Sensor::getRaw(SensorType::FuelPressureLow); - tsOutputChannels.rawHighFuelPressure = Sensor::getRaw(SensorType::FuelPressureHigh); - tsOutputChannels.MAFValue = Sensor::getRaw(SensorType::Maf); - tsOutputChannels.rawWastegatePosition = Sensor::getRaw(SensorType::WastegatePosition); - tsOutputChannels.rawIdlePositionSensor = Sensor::getRaw(SensorType::IdlePosition); + engine->outputChannels.rawTps1Primary = Sensor::getRaw(SensorType::Tps1Primary); + engine->outputChannels.rawTps1Secondary = Sensor::getRaw(SensorType::Tps1Secondary); + engine->outputChannels.rawTps2Primary = Sensor::getRaw(SensorType::Tps2Primary); + engine->outputChannels.rawTps2Secondary = Sensor::getRaw(SensorType::Tps2Secondary); + engine->outputChannels.rawPpsPrimary = Sensor::getRaw(SensorType::AcceleratorPedalPrimary); + engine->outputChannels.rawPpsSecondary = Sensor::getRaw(SensorType::AcceleratorPedalSecondary); + engine->outputChannels.rawClt = Sensor::getRaw(SensorType::Clt); + engine->outputChannels.rawIat = Sensor::getRaw(SensorType::Iat); + engine->outputChannels.rawOilPressure = Sensor::getRaw(SensorType::OilPressure); + engine->outputChannels.rawLowFuelPressure = Sensor::getRaw(SensorType::FuelPressureLow); + engine->outputChannels.rawHighFuelPressure = Sensor::getRaw(SensorType::FuelPressureHigh); + engine->outputChannels.MAFValue = Sensor::getRaw(SensorType::Maf); + engine->outputChannels.rawWastegatePosition = Sensor::getRaw(SensorType::WastegatePosition); + engine->outputChannels.rawIdlePositionSensor = Sensor::getRaw(SensorType::IdlePosition); } static void updatePressures() { - tsOutputChannels.baroPressure = Sensor::getOrZero(SensorType::BarometricPressure); - tsOutputChannels.MAPValue = Sensor::getOrZero(SensorType::Map); - tsOutputChannels.oilPressure = Sensor::get(SensorType::OilPressure).Value; + engine->outputChannels.baroPressure = Sensor::getOrZero(SensorType::BarometricPressure); + engine->outputChannels.MAPValue = Sensor::getOrZero(SensorType::Map); + engine->outputChannels.oilPressure = Sensor::get(SensorType::OilPressure).Value; } static void updateMiscSensors() { - tsOutputChannels.VBatt = Sensor::getOrZero(SensorType::BatteryVoltage); + engine->outputChannels.VBatt = Sensor::getOrZero(SensorType::BatteryVoltage); - tsOutputChannels.idlePositionSensor = Sensor::getOrZero(SensorType::IdlePosition); + engine->outputChannels.idlePositionSensor = Sensor::getOrZero(SensorType::IdlePosition); - tsOutputChannels.wastegatePositionSensor = Sensor::getOrZero(SensorType::WastegatePosition); + engine->outputChannels.wastegatePositionSensor = Sensor::getOrZero(SensorType::WastegatePosition); #if HAL_USE_ADC - tsOutputChannels.internalMcuTemperature = getMCUInternalTemperature(); + engine->outputChannels.internalMcuTemperature = getMCUInternalTemperature(); #endif /* HAL_USE_ADC */ // tCharge depends on the previous state, so we should use the stored value. - tsOutputChannels.tCharge = engine->engineState.sd.tCharge; + engine->outputChannels.tCharge = engine->engineState.sd.tCharge; } static void updateSensors(int rpm) { @@ -577,32 +577,32 @@ static void updateSensors(int rpm) { } static void updateFuelCorrections() { - tsOutputChannels.baroCorrection = engine->engineState.baroCorrection; - tsOutputChannels.iatCorrection = engine->engineState.running.intakeTemperatureCoefficient; - tsOutputChannels.cltCorrection = engine->engineState.running.coolantTemperatureCoefficient; + engine->outputChannels.baroCorrection = engine->engineState.baroCorrection; + engine->outputChannels.iatCorrection = engine->engineState.running.intakeTemperatureCoefficient; + engine->outputChannels.cltCorrection = engine->engineState.running.coolantTemperatureCoefficient; - tsOutputChannels.fuelPidCorrection[0] = 100.0f * (engine->stftCorrection[0] - 1.0f); - tsOutputChannels.fuelPidCorrection[1] = 100.0f * (engine->stftCorrection[1] - 1.0f); + engine->outputChannels.fuelPidCorrection[0] = 100.0f * (engine->stftCorrection[0] - 1.0f); + engine->outputChannels.fuelPidCorrection[1] = 100.0f * (engine->stftCorrection[1] - 1.0f); - tsOutputChannels.injectorLagMs = engine->engineState.running.injectorLag; + engine->outputChannels.injectorLagMs = engine->engineState.running.injectorLag; } static void updateFuelLoads() { - tsOutputChannels.fuelingLoad = getFuelingLoad(); - tsOutputChannels.ignitionLoad = getIgnitionLoad(); - tsOutputChannels.veTableYAxis = engine->engineState.currentVeLoad; - tsOutputChannels.afrTableYAxis = engine->engineState.currentAfrLoad; + engine->outputChannels.fuelingLoad = getFuelingLoad(); + engine->outputChannels.ignitionLoad = getIgnitionLoad(); + engine->outputChannels.veTableYAxis = engine->engineState.currentVeLoad; + engine->outputChannels.afrTableYAxis = engine->engineState.currentAfrLoad; } static void updateFuelResults() { - tsOutputChannels.chargeAirMass = engine->engineState.sd.airMassInOneCylinder; + engine->outputChannels.chargeAirMass = engine->engineState.sd.airMassInOneCylinder; - tsOutputChannels.baseFuel = engine->engineState.baseFuel * 1000; // Convert grams to mg - tsOutputChannels.fuelRunning = engine->engineState.running.fuel; - tsOutputChannels.actualLastInjection = engine->actualLastInjection[0]; + engine->outputChannels.baseFuel = engine->engineState.baseFuel * 1000; // Convert grams to mg + engine->outputChannels.fuelRunning = engine->engineState.running.fuel; + engine->outputChannels.actualLastInjection = engine->actualLastInjection[0]; - tsOutputChannels.fuelFlowRate = engine->engineState.fuelConsumption.getConsumptionGramPerSecond(); - tsOutputChannels.totalFuelConsumption = engine->engineState.fuelConsumption.getConsumedGrams(); + engine->outputChannels.fuelFlowRate = engine->engineState.fuelConsumption.getConsumptionGramPerSecond(); + engine->outputChannels.totalFuelConsumption = engine->engineState.fuelConsumption.getConsumedGrams(); } static void updateFuelInfo() { @@ -611,53 +611,53 @@ static void updateFuelInfo() { updateFuelResults(); const auto& wallFuel = engine->injectionEvents.elements[0].wallFuel; - tsOutputChannels.wallFuelAmount = wallFuel.getWallFuel() * 1000; // Convert grams to mg - tsOutputChannels.wallFuelCorrection = wallFuel.wallFuelCorrection * 1000; // Convert grams to mg + engine->outputChannels.wallFuelAmount = wallFuel.getWallFuel() * 1000; // Convert grams to mg + engine->outputChannels.wallFuelCorrection = wallFuel.wallFuelCorrection * 1000; // Convert grams to mg - tsOutputChannels.injectionOffset = engine->engineState.injectionOffset; + engine->outputChannels.injectionOffset = engine->engineState.injectionOffset; - tsOutputChannels.veValue = engine->engineState.currentVe; - tsOutputChannels.currentTargetAfr = engine->engineState.targetAFR; - tsOutputChannels.targetLambda = engine->engineState.targetLambda; + engine->outputChannels.veValue = engine->engineState.currentVe; + engine->outputChannels.currentTargetAfr = engine->engineState.targetAFR; + engine->outputChannels.targetLambda = engine->engineState.targetLambda; - tsOutputChannels.crankingFuelMs = engine->engineState.cranking.fuel; + engine->outputChannels.crankingFuelMs = engine->engineState.cranking.fuel; } static void updateIgnition(int rpm) { float timing = engine->engineState.timingAdvance[0]; // that's weird logic. also seems broken for two stroke? - tsOutputChannels.ignitionAdvance = timing > FOUR_STROKE_CYCLE_DURATION / 2 ? timing - FOUR_STROKE_CYCLE_DURATION : timing; + engine->outputChannels.ignitionAdvance = timing > FOUR_STROKE_CYCLE_DURATION / 2 ? timing - FOUR_STROKE_CYCLE_DURATION : timing; // 60 - tsOutputChannels.sparkDwellValue = engine->engineState.sparkDwell; + engine->outputChannels.sparkDwellValue = engine->engineState.sparkDwell; - tsOutputChannels.coilDutyCycle = getCoilDutyCycle(rpm); + engine->outputChannels.coilDutyCycle = getCoilDutyCycle(rpm); - tsOutputChannels.knockRetard = engine->knockController.getKnockRetard(); + engine->outputChannels.knockRetard = engine->knockController.getKnockRetard(); } static void updateFlags() { - tsOutputChannels.isFuelPumpOn = enginePins.fuelPumpRelay.getLogicValue(); - tsOutputChannels.isFanOn = enginePins.fanRelay.getLogicValue(); - tsOutputChannels.isFan2On = enginePins.fanRelay2.getLogicValue(); - tsOutputChannels.isO2HeaterOn = enginePins.o2heater.getLogicValue(); - tsOutputChannels.isIgnitionEnabledIndicator = engine->limpManager.allowIgnition(); - tsOutputChannels.isInjectionEnabledIndicator = engine->limpManager.allowInjection(); - tsOutputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode; + engine->outputChannels.isFuelPumpOn = enginePins.fuelPumpRelay.getLogicValue(); + engine->outputChannels.isFanOn = enginePins.fanRelay.getLogicValue(); + engine->outputChannels.isFan2On = enginePins.fanRelay2.getLogicValue(); + engine->outputChannels.isO2HeaterOn = enginePins.o2heater.getLogicValue(); + engine->outputChannels.isIgnitionEnabledIndicator = engine->limpManager.allowIgnition(); + engine->outputChannels.isInjectionEnabledIndicator = engine->limpManager.allowInjection(); + engine->outputChannels.isCylinderCleanupActivated = engine->isCylinderCleanupMode; #if EFI_LAUNCH_CONTROL - tsOutputChannels.launchTriggered = engine->launchController.isLaunchCondition; + engine->outputChannels.launchTriggered = engine->launchController.isLaunchCondition; #endif - tsOutputChannels.clutchUpState = engine->clutchUpState; - tsOutputChannels.clutchDownState = engine->clutchDownState; - tsOutputChannels.brakePedalState = engine->brakePedalState; + engine->outputChannels.clutchUpState = engine->clutchUpState; + engine->outputChannels.clutchDownState = engine->clutchDownState; + engine->outputChannels.brakePedalState = engine->brakePedalState; #if EFI_PROD_CODE - tsOutputChannels.isTriggerError = isTriggerErrorNow(); + engine->outputChannels.isTriggerError = isTriggerErrorNow(); #endif // EFI_PROD_CODE #if EFI_INTERNAL_FLASH - tsOutputChannels.needBurn = getNeedToWriteConfiguration(); + engine->outputChannels.needBurn = getNeedToWriteConfiguration(); #endif /* EFI_INTERNAL_FLASH */ } @@ -665,16 +665,16 @@ static void updateFlags() { // see https://github.com/rusefi/rusefi/issues/3302 and linked tickets static void updateTpsDebug() { // TPS 1 pri/sec split - tsOutputChannels.debugFloatField1 = Sensor::getOrZero(SensorType::Tps1Primary) - Sensor::getOrZero(SensorType::Tps1Secondary); + engine->outputChannels.debugFloatField1 = Sensor::getOrZero(SensorType::Tps1Primary) - Sensor::getOrZero(SensorType::Tps1Secondary); // TPS 2 pri/sec split - tsOutputChannels.debugFloatField2 = Sensor::getOrZero(SensorType::Tps2Primary) - Sensor::getOrZero(SensorType::Tps2Secondary); + engine->outputChannels.debugFloatField2 = Sensor::getOrZero(SensorType::Tps2Primary) - Sensor::getOrZero(SensorType::Tps2Secondary); // TPS1 - TPS2 split - tsOutputChannels.debugFloatField3 = Sensor::getOrZero(SensorType::Tps1) - Sensor::getOrZero(SensorType::Tps2); + engine->outputChannels.debugFloatField3 = Sensor::getOrZero(SensorType::Tps1) - Sensor::getOrZero(SensorType::Tps2); // Pedal pri/sec split - tsOutputChannels.debugFloatField4 = Sensor::getOrZero(SensorType::AcceleratorPedalPrimary) - Sensor::getOrZero(SensorType::AcceleratorPedalSecondary); + engine->outputChannels.debugFloatField4 = Sensor::getOrZero(SensorType::AcceleratorPedalPrimary) - Sensor::getOrZero(SensorType::AcceleratorPedalSecondary); // TPS 1 pri/sec ratio - useful for ford ETB that has partial-range second channel - tsOutputChannels.debugFloatField5 = 100 * Sensor::getOrZero(SensorType::Tps1Primary) / Sensor::getOrZero(SensorType::Tps1Secondary); + engine->outputChannels.debugFloatField5 = 100 * Sensor::getOrZero(SensorType::Tps1Primary) / Sensor::getOrZero(SensorType::Tps1Secondary); } void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels) { @@ -877,7 +877,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels) { void prepareTunerStudioOutputs(void) { // sensor state for EFI Analytics Tuner Studio - updateTunerStudioState(&tsOutputChannels); + updateTunerStudioState(&engine->outputChannels); } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/controllers/actuators/ac_control.cpp b/firmware/controllers/actuators/ac_control.cpp index 20822771e4..f4384f154d 100644 --- a/firmware/controllers/actuators/ac_control.cpp +++ b/firmware/controllers/actuators/ac_control.cpp @@ -59,8 +59,8 @@ void AcController::onSlowCallback() { enginePins.acRelay.setValue(isEnabled); #if EFI_TUNER_STUDIO - tsOutputChannels.acSwitchState = engine->acSwitchState; - tsOutputChannels.acState = isEnabled; + engine->outputChannels.acSwitchState = engine->acSwitchState; + engine->outputChannels.acState = isEnabled; #endif // EFI_TUNER_STUDIO } diff --git a/firmware/controllers/actuators/alternator_controller.cpp b/firmware/controllers/actuators/alternator_controller.cpp index ae393f0edf..f097c8573a 100644 --- a/firmware/controllers/actuators/alternator_controller.cpp +++ b/firmware/controllers/actuators/alternator_controller.cpp @@ -46,7 +46,7 @@ void AlternatorController::onFastCallback() { // this block could be executed even in on/off alternator control mode // but at least we would reflect latest state #if EFI_TUNER_STUDIO - alternatorPid.postState(&tsOutputChannels.alternatorStatus); + alternatorPid.postState(&engine->outputChannels.alternatorStatus); #endif /* EFI_TUNER_STUDIO */ // todo: migrate this to FSIO @@ -77,7 +77,7 @@ void AlternatorController::onFastCallback() { enginePins.alternatorPin.setValue(newState); currentPlainOnOffState = newState; #if EFI_TUNER_STUDIO - tsOutputChannels.alternatorOnOff = newState; + engine->outputChannels.alternatorOnOff = newState; #endif /* EFI_TUNER_STUDIO */ return; diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp index 43a4eb06b7..edba5139b4 100644 --- a/firmware/controllers/actuators/boost_control.cpp +++ b/firmware/controllers/actuators/boost_control.cpp @@ -86,7 +86,7 @@ expected BoostController::getOpenLoop(float target) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_BOOST) { - tsOutputChannels.debugFloatField1 = openLoop; + engine->outputChannels.debugFloatField1 = openLoop; } #endif @@ -129,8 +129,8 @@ expected BoostController::getClosedLoop(float target, float manifoldP #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_BOOST) { - tsOutputChannels.debugFloatField2 = closedLoop; - tsOutputChannels.debugFloatField3 = target; + engine->outputChannels.debugFloatField2 = closedLoop; + engine->outputChannels.debugFloatField3 = target; } #endif /* EFI_TUNER_STUDIO */ @@ -142,7 +142,7 @@ void BoostController::setOutput(expected output) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_BOOST) { - tsOutputChannels.debugFloatField3 = percent; + engine->outputChannels.debugFloatField3 = percent; } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index b3e7144058..ed625d759d 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -266,7 +266,7 @@ expected EtbController::getSetpointIdleValve() const { // VW ETB idle mode uses an ETB only for idle (a mini-ETB sets the lower stop, and a normal cable // can pull the throttle up off the stop.), so we directly control the throttle with the idle position. #if EFI_TUNER_STUDIO - tsOutputChannels.etbTarget = m_idlePosition; + engine->outputChannels.etbTarget = m_idlePosition; #endif // EFI_TUNER_STUDIO return clampF(0, m_idlePosition, 100); } @@ -327,7 +327,7 @@ expected EtbController::getSetpointEtb() const { #if EFI_TUNER_STUDIO if (m_function == ETB_Throttle1) { - tsOutputChannels.etbTarget = targetPosition; + engine->outputChannels.etbTarget = targetPosition; } #endif // EFI_TUNER_STUDIO @@ -416,33 +416,33 @@ expected EtbController::getClosedLoopAutotune(percent_t target, perce m_autotuneCounter++; // Multiplex 3 signals on to the {mode, value} format - tsOutputChannels.calibrationMode = (uint8_t)static_cast(m_autotuneCurrentParam + 3); + engine->outputChannels.calibrationMode = (uint8_t)static_cast(m_autotuneCurrentParam + 3); switch (m_autotuneCurrentParam) { case 0: - tsOutputChannels.calibrationValue = kp; + engine->outputChannels.calibrationValue = kp; break; case 1: - tsOutputChannels.calibrationValue = ki; + engine->outputChannels.calibrationValue = ki; break; case 2: - tsOutputChannels.calibrationValue = kd; + engine->outputChannels.calibrationValue = kd; break; } // Also output to debug channels if configured if (engineConfiguration->debugMode == DBG_ETB_AUTOTUNE) { // a - amplitude of output (TPS %) - tsOutputChannels.debugFloatField1 = m_a; + engine->outputChannels.debugFloatField1 = m_a; // b - amplitude of input (Duty cycle %) - tsOutputChannels.debugFloatField2 = b; + engine->outputChannels.debugFloatField2 = b; // Tu - oscillation period (seconds) - tsOutputChannels.debugFloatField3 = m_tu; + engine->outputChannels.debugFloatField3 = m_tu; - tsOutputChannels.debugFloatField4 = ku; - tsOutputChannels.debugFloatField5 = kp; - tsOutputChannels.debugFloatField6 = ki; - tsOutputChannels.debugFloatField7 = kd; + engine->outputChannels.debugFloatField4 = ku; + engine->outputChannels.debugFloatField5 = kp; + engine->outputChannels.debugFloatField6 = ki; + engine->outputChannels.debugFloatField7 = kd; } #endif } @@ -472,7 +472,7 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs if (m_function == ETB_Throttle1) { #if EFI_TUNER_STUDIO // Error is positive if the throttle needs to open further - tsOutputChannels.etb1Error = target - observation; + engine->outputChannels.etb1Error = target - observation; #endif /* EFI_TUNER_STUDIO */ } @@ -485,7 +485,7 @@ expected EtbController::getClosedLoop(percent_t target, percent_t obs #if EFI_TUNER_STUDIO if (m_function == ETB_Throttle1) { - tsOutputChannels.etbIntegralError = errorIntegral; + engine->outputChannels.etbIntegralError = errorIntegral; } #endif // EFI_TUNER_STUDIO @@ -504,7 +504,7 @@ void EtbController::setOutput(expected outputValue) { #if EFI_TUNER_STUDIO // Only report first-throttle stats if (m_function == ETB_Throttle1) { - tsOutputChannels.etb1DutyCycle = outputValue.value_or(0); + engine->outputChannels.etb1DutyCycle = outputValue.value_or(0); } #endif @@ -531,9 +531,9 @@ void EtbController::update() { #if EFI_TUNER_STUDIO // Only debug throttle #1 if (m_function == ETB_Throttle1) { - m_pid.postState(&tsOutputChannels.etbStatus); - tsOutputChannels.etbFeedForward = engine->engineState.etbFeedForward; - tsOutputChannels.etbStatus.output = directPwmValue; + m_pid.postState(&engine->outputChannels.etbStatus); + engine->outputChannels.etbFeedForward = engine->engineState.etbFeedForward; + engine->outputChannels.etbStatus.output = directPwmValue; } #endif /* EFI_TUNER_STUDIO */ @@ -551,7 +551,7 @@ void EtbController::update() { } } - tsOutputChannels.etbCurrentTarget = engine->engineState.targetFromTable; + engine->outputChannels.etbCurrentTarget = engine->engineState.targetFromTable; m_pid.iTermMin = engineConfiguration->etb_iTermMin; m_pid.iTermMax = engineConfiguration->etb_iTermMax; @@ -628,21 +628,21 @@ struct EtbImpl final : public EtbController { } // Write out the learned values to TS, waiting briefly after setting each to let TS grab it - tsOutputChannels.calibrationMode = (uint8_t)functionToCalModePriMax(myFunction); - tsOutputChannels.calibrationValue = primaryMax * TPS_TS_CONVERSION; + engine->outputChannels.calibrationMode = (uint8_t)functionToCalModePriMax(myFunction); + engine->outputChannels.calibrationValue = primaryMax * TPS_TS_CONVERSION; chThdSleepMilliseconds(500); - tsOutputChannels.calibrationMode = (uint8_t)functionToCalModePriMin(myFunction); - tsOutputChannels.calibrationValue = primaryMin * TPS_TS_CONVERSION; + engine->outputChannels.calibrationMode = (uint8_t)functionToCalModePriMin(myFunction); + engine->outputChannels.calibrationValue = primaryMin * TPS_TS_CONVERSION; chThdSleepMilliseconds(500); - tsOutputChannels.calibrationMode = (uint8_t)functionToCalModeSecMax(myFunction); - tsOutputChannels.calibrationValue = secondaryMax * TPS_TS_CONVERSION; + engine->outputChannels.calibrationMode = (uint8_t)functionToCalModeSecMax(myFunction); + engine->outputChannels.calibrationValue = secondaryMax * TPS_TS_CONVERSION; chThdSleepMilliseconds(500); - tsOutputChannels.calibrationMode = (uint8_t)functionToCalModeSecMin(myFunction); - tsOutputChannels.calibrationValue = secondaryMin * TPS_TS_CONVERSION; + engine->outputChannels.calibrationMode = (uint8_t)functionToCalModeSecMin(myFunction); + engine->outputChannels.calibrationValue = secondaryMin * TPS_TS_CONVERSION; chThdSleepMilliseconds(500); - tsOutputChannels.calibrationMode = (uint8_t)TsCalMode::None; + engine->outputChannels.calibrationMode = (uint8_t)TsCalMode::None; m_isAutocal = false; return; diff --git a/firmware/controllers/actuators/fuel_pump.cpp b/firmware/controllers/actuators/fuel_pump.cpp index d3653f9fd4..77fa114f97 100644 --- a/firmware/controllers/actuators/fuel_pump.cpp +++ b/firmware/controllers/actuators/fuel_pump.cpp @@ -18,6 +18,6 @@ void FuelPumpController::onSlowCallback() { enginePins.fuelPumpRelay.setValue(isPumpOn); #if EFI_TUNER_STUDIO - tsOutputChannels.isFuelPumpOn = isPumpOn; + engine->outputChannels.isFuelPumpOn = isPumpOn; #endif } diff --git a/firmware/controllers/actuators/gppwm/gppwm.cpp b/firmware/controllers/actuators/gppwm/gppwm.cpp index 49faa81c47..dc0f2770a1 100644 --- a/firmware/controllers/actuators/gppwm/gppwm.cpp +++ b/firmware/controllers/actuators/gppwm/gppwm.cpp @@ -55,7 +55,7 @@ void updateGppwm() { #ifdef EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_GPPWM) { - scaled_channel* debugFloats = &tsOutputChannels.debugFloatField1; + scaled_channel* debugFloats = &engine->outputChannels.debugFloatField1; debugFloats[i] = result; } #endif diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 4bd382aea7..eae659d8e9 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -451,17 +451,17 @@ float IdleController::getClosedLoop(IIdleController::Phase phase, float tpsPos, } #if EFI_TUNER_STUDIO - tsOutputChannels.isIdleClosedLoop = phase == Phase::Idling; - tsOutputChannels.isIdleCoasting = phase == Phase::Coasting; + engine->outputChannels.isIdleClosedLoop = phase == Phase::Idling; + engine->outputChannels.isIdleCoasting = phase == Phase::Coasting; if (engineConfiguration->idleMode == IM_AUTO) { // see also tsOutputChannels->idlePosition - getIdlePid()->postState(&tsOutputChannels.idleStatus); - tsOutputChannels.idleState = engine->idle.idleState; + getIdlePid()->postState(&engine->outputChannels.idleStatus); + engine->outputChannels.idleState = engine->idle.idleState; } else { - tsOutputChannels.idleCurrentPosition = iacPosition; + engine->outputChannels.idleCurrentPosition = iacPosition; extern StepperMotor iacMotor; - tsOutputChannels.idleTargetPosition = iacMotor.getTargetPosition(); + engine->outputChannels.idleTargetPosition = iacMotor.getTargetPosition(); } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/controllers/actuators/vvt.cpp b/firmware/controllers/actuators/vvt.cpp index 0ca268e3fa..5ffa7eb49c 100644 --- a/firmware/controllers/actuators/vvt.cpp +++ b/firmware/controllers/actuators/vvt.cpp @@ -55,7 +55,7 @@ expected VvtController::getSetpoint() { float target = m_targetMap->getValue(rpm, load); #if EFI_TUNER_STUDIO - tsOutputChannels.vvtTargets[index] = target; + engine->outputChannels.vvtTargets[index] = target; #endif return target; @@ -79,8 +79,8 @@ expected VvtController::getClosedLoop(angle_t target, angle_t observa static debug_mode_e debugModeByIndex[4] = {DBG_VVT_1_PID, DBG_VVT_2_PID, DBG_VVT_3_PID, DBG_VVT_4_PID}; if (engineConfiguration->debugMode == debugModeByIndex[index]) { - m_pid.postState(&tsOutputChannels); - tsOutputChannels.debugIntField3 = (int)(10 * target); + m_pid.postState(&engine->outputChannels); + engine->outputChannels.debugIntField3 = (int)(10 * target); } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index 274a3aadea..20d213a581 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -72,14 +72,14 @@ floatms_t TpsAccelEnrichment::getTpsEnrichment() { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_TPS_ACCEL) { - tsOutputChannels.debugFloatField1 = tpsFrom; - tsOutputChannels.debugFloatField2 = tpsTo; - tsOutputChannels.debugFloatField3 = valueFromTable; - tsOutputChannels.debugFloatField4 = extraFuel; - tsOutputChannels.debugFloatField5 = accumulatedValue; - tsOutputChannels.debugFloatField6 = maxExtraPerPeriod; - tsOutputChannels.debugFloatField7 = maxInjectedPerPeriod; - tsOutputChannels.debugIntField1 = cycleCnt; + engine->outputChannels.debugFloatField1 = tpsFrom; + engine->outputChannels.debugFloatField2 = tpsTo; + engine->outputChannels.debugFloatField3 = valueFromTable; + engine->outputChannels.debugFloatField4 = extraFuel; + engine->outputChannels.debugFloatField5 = accumulatedValue; + engine->outputChannels.debugFloatField6 = maxExtraPerPeriod; + engine->outputChannels.debugFloatField7 = maxInjectedPerPeriod; + engine->outputChannels.debugIntField1 = cycleCnt; } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index d235e15ec5..fa8322da4e 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -92,10 +92,10 @@ angle_t getAdvanceCorrections(int rpm) { float pidTimingCorrection = engine->module().unmock().getIdleTimingAdjustment(rpm); #if EFI_TUNER_STUDIO - tsOutputChannels.timingIatCorrection = iatCorrection; - tsOutputChannels.timingCltCorrection = engine->engineState.cltTimingCorrection; - tsOutputChannels.timingPidCorrection = pidTimingCorrection; - tsOutputChannels.multiSparkCounter = engine->engineState.multispark.count; + engine->outputChannels.timingIatCorrection = iatCorrection; + engine->outputChannels.timingCltCorrection = engine->engineState.cltTimingCorrection; + engine->outputChannels.timingPidCorrection = pidTimingCorrection; + engine->outputChannels.multiSparkCounter = engine->engineState.multispark.count; #endif /* EFI_TUNER_STUDIO */ return iatCorrection diff --git a/firmware/controllers/algo/airmass/speed_density_airmass.cpp b/firmware/controllers/algo/airmass/speed_density_airmass.cpp index 95d85f764d..b17b59f150 100644 --- a/firmware/controllers/algo/airmass/speed_density_airmass.cpp +++ b/firmware/controllers/algo/airmass/speed_density_airmass.cpp @@ -47,7 +47,7 @@ float SpeedDensityAirmass::getMap(int rpm) const { } #if EFI_TUNER_STUDIO - tsOutputChannels.fallbackMap = fallbackMap; + engine->outputChannels.fallbackMap = fallbackMap; #endif // EFI_TUNER_STUDIO return fallbackMap; diff --git a/firmware/controllers/algo/dynoview.cpp b/firmware/controllers/algo/dynoview.cpp index 7059f3a518..390fd34ce5 100644 --- a/firmware/controllers/algo/dynoview.cpp +++ b/firmware/controllers/algo/dynoview.cpp @@ -46,11 +46,11 @@ void DynoView::update(vssSrc src) { updateAcceleration(deltaTime, deltaSpeed); #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_LOGIC_ANALYZER) { - tsOutputChannels.debugIntField1 = deltaTime; - tsOutputChannels.debugFloatField1 = vss; - tsOutputChannels.debugFloatField2 = speed; - tsOutputChannels.debugFloatField3 = deltaSpeed; - tsOutputChannels.debugFloatField4 = acceleration; + engine->outputChannels.debugIntField1 = deltaTime; + engine->outputChannels.debugFloatField1 = vss; + engine->outputChannels.debugFloatField2 = speed; + engine->outputChannels.debugFloatField3 = deltaSpeed; + engine->outputChannels.debugFloatField4 = acceleration; } #endif /* EFI_TUNER_STUDIO */ updateHP(); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 0d8c9cb8e2..1224f563ef 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -377,11 +377,11 @@ void Engine::preCalculate() { #if EFI_TUNER_STUDIO // we take 2 bytes of crc32, no idea if it's right to call it crc16 or not // we have a hack here - we rely on the fact that engineMake is the first of three relevant fields - tsOutputChannels.engineMakeCodeNameCrc16 = crc32(engineConfiguration->engineMake, 3 * VEHICLE_INFO_SIZE); + engine->outputChannels.engineMakeCodeNameCrc16 = crc32(engineConfiguration->engineMake, 3 * VEHICLE_INFO_SIZE); // we need and can empty warning message for CRC purposes memset(config->warning_message, 0, sizeof(error_message_t)); - tsOutputChannels.tuneCrc16 = crc32(config, sizeof(persistent_config_s)); + engine->outputChannels.tuneCrc16 = crc32(config, sizeof(persistent_config_s)); #endif /* EFI_TUNER_STUDIO */ } diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 20610a1d96..347bcdb765 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -116,6 +116,8 @@ public: // todo: technical debt: enableOverdwellProtection #3553 bool enableOverdwellProtection = true; + TunerStudioOutputChannels outputChannels; + /** * Sometimes for instance during shutdown we need to completely supress CAN TX */ diff --git a/firmware/controllers/algo/fuel/injector_model.cpp b/firmware/controllers/algo/fuel/injector_model.cpp index a7cadb8438..e5d680a4b3 100644 --- a/firmware/controllers/algo/fuel/injector_model.cpp +++ b/firmware/controllers/algo/fuel/injector_model.cpp @@ -65,8 +65,8 @@ float InjectorModel::getInjectorFlowRatio() const { float flowRatio = sqrtf(pressureRatio); #if EFI_TUNER_STUDIO - tsOutputChannels.injectorFlowPressureDelta = pressureDelta; - tsOutputChannels.injectorFlowPressureRatio = pressureRatio; + engine->outputChannels.injectorFlowPressureDelta = pressureDelta; + engine->outputChannels.injectorFlowPressureRatio = pressureRatio; #endif // EFI_TUNER_STUDIO // TODO: should the flow ratio be clamped? diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index 6296cc7efd..c9438cc2af 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -87,10 +87,10 @@ bool LaunchControlBase::isLaunchConditionMet(int rpm) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_LAUNCH) { - tsOutputChannels.debugIntField1 = rpmCondition; - tsOutputChannels.debugIntField2 = tpsCondition; - tsOutputChannels.debugIntField3 = speedCondition; - tsOutputChannels.debugIntField4 = activateSwitchCondition; + engine->outputChannels.debugIntField1 = rpmCondition; + engine->outputChannels.debugIntField2 = tpsCondition; + engine->outputChannels.debugIntField3 = speedCondition; + engine->outputChannels.debugIntField4 = activateSwitchCondition; } #endif /* EFI_TUNER_STUDIO */ @@ -120,10 +120,10 @@ void LaunchControlBase::update() { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_LAUNCH) { - tsOutputChannels.debugIntField5 = engine->clutchDownState; - tsOutputChannels.debugFloatField1 = launchActivatePinState; - tsOutputChannels.debugFloatField2 = isLaunchCondition; - tsOutputChannels.debugFloatField3 = combinedConditions; + engine->outputChannels.debugIntField5 = engine->clutchDownState; + engine->outputChannels.debugFloatField1 = launchActivatePinState; + engine->outputChannels.debugFloatField2 = isLaunchCondition; + engine->outputChannels.debugFloatField3 = combinedConditions; } #endif /* EFI_TUNER_STUDIO */ } diff --git a/firmware/controllers/algo/wall_fuel.cpp b/firmware/controllers/algo/wall_fuel.cpp index 1952926034..1bf29aaeb9 100644 --- a/firmware/controllers/algo/wall_fuel.cpp +++ b/firmware/controllers/algo/wall_fuel.cpp @@ -77,8 +77,8 @@ float WallFuel::adjust(float desiredMassGrams) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_KNOCK) { - tsOutputChannels.debugFloatField1 = alpha; - tsOutputChannels.debugFloatField2 = beta; + engine->outputChannels.debugFloatField1 = alpha; + engine->outputChannels.debugFloatField2 = beta; } #endif // EFI_TUNER_STUDIO @@ -95,8 +95,8 @@ float WallFuel::adjust(float desiredMassGrams) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_KNOCK) { - tsOutputChannels.debugFloatField3 = fuelFilmMass; - tsOutputChannels.debugFloatField4 = M_cmd; + engine->outputChannels.debugFloatField3 = fuelFilmMass; + engine->outputChannels.debugFloatField4 = M_cmd; } #endif // EFI_TUNER_STUDIO @@ -112,7 +112,7 @@ float WallFuel::adjust(float desiredMassGrams) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_KNOCK) { - tsOutputChannels.debugFloatField5 = fuelFilmMassNext; + engine->outputChannels.debugFloatField5 = fuelFilmMassNext; } #endif // EFI_TUNER_STUDIO diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index 825a4b9744..c5bd413216 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -379,7 +379,7 @@ static void handleCommandX14(uint16_t index) { case 0x10: engine->etbAutoTune = false; #if EFI_TUNER_STUDIO - tsOutputChannels.calibrationMode = (uint8_t)TsCalMode::None; + engine->outputChannels.calibrationMode = (uint8_t)TsCalMode::None; #endif // EFI_TUNER_STUDIO return; #endif diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index a5afb0e6ba..4bdd04729b 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -731,7 +731,7 @@ void canDashboardHaltech(CanCycle cycle) { { CanTxMessage msg(0x36A, 4); /* Knock Level 1 */ - tmp = (tsOutputChannels.knockLevel * 100); + tmp = (engine->outputChannels.knockLevel * 100); msg[0] = (tmp >> 8); msg[1] = (tmp & 0x00ff); /* Knock Level 2 */ diff --git a/firmware/controllers/engine_cycle/knock_logic.cpp b/firmware/controllers/engine_cycle/knock_logic.cpp index 50ef6da21e..06138cf72a 100644 --- a/firmware/controllers/engine_cycle/knock_logic.cpp +++ b/firmware/controllers/engine_cycle/knock_logic.cpp @@ -51,14 +51,14 @@ bool KnockController::onKnockSenseCompleted(uint8_t cylinderNumber, float dbv, e #if EFI_TUNER_STUDIO // Pass through per-cylinder peak detector float cylPeak = peakDetectors[cylinderNumber].detect(dbv, lastKnockTime); - tsOutputChannels.knock[cylinderNumber] = roundf(cylPeak); + engine->outputChannels.knock[cylinderNumber] = roundf(cylPeak); // Pass through all-cylinders peak detector - tsOutputChannels.knockLevel = allCylinderPeakDetector.detect(dbv, lastKnockTime); + engine->outputChannels.knockLevel = allCylinderPeakDetector.detect(dbv, lastKnockTime); // If this was a knock, count it! if (isKnock) { - tsOutputChannels.knockCount++; + engine->outputChannels.knockCount++; } #endif // EFI_TUNER_STUDIO diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index b5f98931d4..5813d27b55 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -105,7 +105,7 @@ void mapAveragingAdcCallback(adcsample_t adcValue) { float instantVoltage = adcToVoltsDivided(adcValue); float instantMap = convertMap(instantVoltage).value_or(0); #if EFI_TUNER_STUDIO - tsOutputChannels.instantMAPValue = instantMap; + engine->outputChannels.instantMAPValue = instantMap; #endif // EFI_TUNER_STUDIO if (engineConfiguration->vvtMode[0] == VVT_MAP_V_TWIN && @@ -113,10 +113,10 @@ void mapAveragingAdcCallback(adcsample_t adcValue) { engine->triggerCentral.mapState.add(instantMap); bool isPeak = engine->triggerCentral.mapState.isPeak(engineConfiguration->mapCamLookForLowPeaks); #if EFI_TUNER_STUDIO - tsOutputChannels.TEMPLOG_map_length = MAP_CAM_BUFFER; - tsOutputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = engine->triggerCentral.mapState.current; + engine->outputChannels.TEMPLOG_map_length = MAP_CAM_BUFFER; + engine->outputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = engine->triggerCentral.mapState.current; if (isPeak) { - tsOutputChannels.TEMPLOG_map_peak++; + engine->outputChannels.TEMPLOG_map_peak++; } #endif //EFI_TUNER_STUDIO if (isPeak) { diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 891cbbb28c..1f0925e2ff 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -168,16 +168,16 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) { // todo: smarted solution for index to field mapping switch (event->cylinderIndex) { case 0: - tsOutputChannels.debugFloatField1 = ratio; + engine->outputChannels.debugFloatField1 = ratio; break; case 1: - tsOutputChannels.debugFloatField2 = ratio; + engine->outputChannels.debugFloatField2 = ratio; break; case 2: - tsOutputChannels.debugFloatField3 = ratio; + engine->outputChannels.debugFloatField3 = ratio; break; case 3: - tsOutputChannels.debugFloatField4 = ratio; + engine->outputChannels.debugFloatField4 = ratio; break; } #endif diff --git a/firmware/controllers/gear_controller.cpp b/firmware/controllers/gear_controller.cpp index 52a45eda89..0a9b429683 100644 --- a/firmware/controllers/gear_controller.cpp +++ b/firmware/controllers/gear_controller.cpp @@ -25,6 +25,6 @@ gear_e GearControllerBase::setDesiredGear(gear_e gear) { void GearControllerBase::postState() { #if EFI_TUNER_STUDIO - tsOutputChannels.tcuDesiredGear = getDesiredGear(); + engine->outputChannels.tcuDesiredGear = getDesiredGear(); #endif } diff --git a/firmware/controllers/lua/lua.cpp b/firmware/controllers/lua/lua.cpp index cddb569ef6..ec100c43ae 100644 --- a/firmware/controllers/lua/lua.cpp +++ b/firmware/controllers/lua/lua.cpp @@ -96,8 +96,8 @@ static void* myAlloc(void* /*ud*/, void* ptr, size_t osize, size_t nsize) { if (engineConfiguration->debugMode == DBG_LUA) { switch (HeapIdx) { - case 0: tsOutputChannels.debugIntField1 = heaps[HeapIdx].used(); break; - case 1: tsOutputChannels.debugIntField2 = heaps[HeapIdx].used(); break; + case 0: engine->outputChannels.debugIntField1 = heaps[HeapIdx].used(); break; + case 1: engine->outputChannels.debugIntField2 = heaps[HeapIdx].used(); break; } } diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index 6e9ceb2afb..eec2fd1087 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -321,7 +321,7 @@ static int lua_setDebug(lua_State* l) { return 0; } - auto firstDebugField = &tsOutputChannels.debugFloatField1; + auto firstDebugField = &engine->outputChannels.debugFloatField1; firstDebugField[idx - 1] = val; return 0; diff --git a/firmware/controllers/math/closed_loop_fuel.cpp b/firmware/controllers/math/closed_loop_fuel.cpp index 5818cfb410..35832feb7b 100644 --- a/firmware/controllers/math/closed_loop_fuel.cpp +++ b/firmware/controllers/math/closed_loop_fuel.cpp @@ -94,7 +94,7 @@ ClosedLoopFuelResult fuelClosedLoopCorrection() { size_t binIdx = computeStftBin(GET_RPM(), getFuelingLoad(), engineConfiguration->stft); #if EFI_TUNER_STUDIO - tsOutputChannels.fuelClosedLoopBinIdx = binIdx; + engine->outputChannels.fuelClosedLoopBinIdx = binIdx; #endif // EFI_TUNER_STUDIO ClosedLoopFuelResult result; diff --git a/firmware/controllers/sensors/AemXSeriesLambda.cpp b/firmware/controllers/sensors/AemXSeriesLambda.cpp index 53f55a147d..f69c189b83 100644 --- a/firmware/controllers/sensors/AemXSeriesLambda.cpp +++ b/firmware/controllers/sensors/AemXSeriesLambda.cpp @@ -31,10 +31,10 @@ void AemXSeriesWideband::decodeFrame(const CANRxFrame& frame, efitick_t nowNt) { float sensorEsr = frame.data8[3] * 4; float nernstVoltage = frame.data8[4] / 200.0f; - tsOutputChannels.debugFloatField1 = pumpDuty; - tsOutputChannels.debugFloatField2 = sensorEsr; - tsOutputChannels.debugFloatField3 = nernstVoltage; - tsOutputChannels.debugFloatField4 = lambdaFloat; + engine->outputChannels.debugFloatField1 = pumpDuty; + engine->outputChannels.debugFloatField2 = sensorEsr; + engine->outputChannels.debugFloatField3 = nernstVoltage; + engine->outputChannels.debugFloatField4 = lambdaFloat; } #endif diff --git a/firmware/controllers/sensors/software_knock.cpp b/firmware/controllers/sensors/software_knock.cpp index 6fcf7e8887..7bc92f954b 100644 --- a/firmware/controllers/sensors/software_knock.cpp +++ b/firmware/controllers/sensors/software_knock.cpp @@ -179,8 +179,8 @@ void processLastKnockEvent() { float filtered = knockFilter.filter(volts); if (i == localCount - 1 && engineConfiguration->debugMode == DBG_KNOCK) { - tsOutputChannels.debugFloatField1 = volts; - tsOutputChannels.debugFloatField2 = filtered; + engine->outputChannels.debugFloatField1 = volts; + engine->outputChannels.debugFloatField2 = filtered; } sumSq += filtered * filtered; diff --git a/firmware/controllers/simple_tcu.cpp b/firmware/controllers/simple_tcu.cpp index 5ffed98111..e4fce18b85 100644 --- a/firmware/controllers/simple_tcu.cpp +++ b/firmware/controllers/simple_tcu.cpp @@ -19,11 +19,11 @@ void SimpleTransmissionController::update(gear_e gear) { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_TCU) { - tsOutputChannels.debugIntField1 = config->tcuSolenoidTable[static_cast(gear) + 1][0]; - tsOutputChannels.debugIntField2 = config->tcuSolenoidTable[static_cast(gear) + 1][1]; - tsOutputChannels.debugIntField3 = config->tcuSolenoidTable[static_cast(gear) + 1][2]; - tsOutputChannels.debugIntField4 = config->tcuSolenoidTable[static_cast(gear) + 1][3]; - tsOutputChannels.debugIntField5 = config->tcuSolenoidTable[static_cast(gear) + 1][4]; + engine->outputChannels.debugIntField1 = config->tcuSolenoidTable[static_cast(gear) + 1][0]; + engine->outputChannels.debugIntField2 = config->tcuSolenoidTable[static_cast(gear) + 1][1]; + engine->outputChannels.debugIntField3 = config->tcuSolenoidTable[static_cast(gear) + 1][2]; + engine->outputChannels.debugIntField4 = config->tcuSolenoidTable[static_cast(gear) + 1][3]; + engine->outputChannels.debugIntField5 = config->tcuSolenoidTable[static_cast(gear) + 1][4]; } #endif } diff --git a/firmware/controllers/system/timer/single_timer_executor.cpp b/firmware/controllers/system/timer/single_timer_executor.cpp index 303b333fa5..9b253aea4c 100644 --- a/firmware/controllers/system/timer/single_timer_executor.cpp +++ b/firmware/controllers/system/timer/single_timer_executor.cpp @@ -178,11 +178,11 @@ void initSingleTimerExecutorHardware(void) { void executorStatistics() { if (engineConfiguration->debugMode == DBG_EXECUTOR) { #if EFI_TUNER_STUDIO - tsOutputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter; - tsOutputChannels.debugIntField2 = ___engine.executor.executeAllPendingActionsInvocationCounter; - tsOutputChannels.debugIntField3 = ___engine.executor.scheduleCounter; - tsOutputChannels.debugIntField4 = ___engine.executor.executeCounter; - tsOutputChannels.debugIntField5 = ___engine.executor.maxExecuteCounter; + engine->outputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter; + engine->outputChannels.debugIntField2 = ___engine.executor.executeAllPendingActionsInvocationCounter; + engine->outputChannels.debugIntField3 = ___engine.executor.scheduleCounter; + engine->outputChannels.debugIntField4 = ___engine.executor.executeCounter; + engine->outputChannels.debugIntField5 = ___engine.executor.maxExecuteCounter; #endif /* EFI_TUNER_STUDIO */ } } diff --git a/firmware/controllers/tcu.cpp b/firmware/controllers/tcu.cpp index f416016e13..ab1ada52cc 100644 --- a/firmware/controllers/tcu.cpp +++ b/firmware/controllers/tcu.cpp @@ -26,6 +26,6 @@ gear_e TransmissionControllerBase::getCurrentGear() const { void TransmissionControllerBase::postState() { #if EFI_TUNER_STUDIO - tsOutputChannels.tcuCurrentGear = getCurrentGear(); + engine->outputChannels.tcuCurrentGear = getCurrentGear(); #endif } diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 36161907cc..b7f9a740e5 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -105,7 +105,7 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) { return vvtMode != VVT_INACTIVE && vvtMode != VVT_2JZ && vvtMode != VVT_HONDA_K - && vvtMode != VVT_MAP_V_TWIN_ANOTHER && + && vvtMode != VVT_MAP_V_TWIN_ANOTHER && vvtMode != VVT_SECOND_HALF && vvtMode != VVT_FIRST_HALF; } @@ -115,9 +115,7 @@ static angle_t syncAndReport(TriggerCentral *tc, int divider, int remainder) { angle_t offset = tc->triggerState.syncSymmetricalCrank(divider, remainder, engineCycle); if (offset > 0) { -#if EFI_TUNER_STUDIO - tsOutputChannels.vvtSyncCounter++; -#endif /* EFI_TUNER_STUDIO */ + engine->outputChannels.vvtSyncCounter++; } return offset; } @@ -287,8 +285,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { engine->vvtTriggerConfiguration[camIndex], front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt); // yes we log data from all VVT channels into same fields for now - tsOutputChannels.vvtSyncGapRatio = vvtState->currentGap; - tsOutputChannels.vvtStateIndex = vvtState->currentCycle.current_index; + engine->outputChannels.vvtSyncGapRatio = vvtState->currentGap; + engine->outputChannels.vvtStateIndex = vvtState->currentCycle.current_index; } tc->vvtCamCounter++; @@ -303,7 +301,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { #endif // EFI_UNIT_TEST #if EFI_TUNER_STUDIO - tsOutputChannels.vvtCurrentPosition = currentPosition; + engine->outputChannels.vvtCurrentPosition = currentPosition; #endif /* EFI_TUNER_STUDIO */ switch(engineConfiguration->vvtMode[camIndex]) { @@ -325,7 +323,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { return; } #if EFI_TUNER_STUDIO - tsOutputChannels.vvtCounter++; + engine->outputChannels.vvtCounter++; #endif /* EFI_TUNER_STUDIO */ } default: @@ -618,8 +616,8 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta signal, timestamp); #if EFI_TUNER_STUDIO - tsOutputChannels.triggerSyncGapRatio = triggerState.currentGap; - tsOutputChannels.triggerStateIndex = triggerState.currentCycle.current_index; + engine->outputChannels.triggerSyncGapRatio = triggerState.currentGap; + engine->outputChannels.triggerStateIndex = triggerState.currentCycle.current_index; #endif /* EFI_TUNER_STUDIO */ @@ -667,7 +665,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta auto toothAngle = engine->triggerCentral.triggerFormDetails.eventAngles[triggerIndexForListeners] - tdcPosition(); wrapAngle(toothAngle, "currentEnginePhase", CUSTOM_ERR_6555); #if EFI_TUNER_STUDIO - tsOutputChannels.currentEnginePhase = toothAngle; + engine->outputChannels.currentEnginePhase = toothAngle; #endif // EFI_TUNER_STUDIO if (engineConfiguration->vvtMode[0] == VVT_MAP_V_TWIN_ANOTHER) { @@ -685,9 +683,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta hwHandleVvtCamSignal(TV_FALL, stamp, /*index*/0); } #if EFI_TUNER_STUDIO - tsOutputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = map; - tsOutputChannels.TEMPLOG_map_peak = mapCamCounter; - tsOutputChannels.TEMPLOG_MAP_AT_DIFF = map - mapCamPrevCycleValue; + engine->outputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = map; + engine->outputChannels.TEMPLOG_map_peak = mapCamCounter; + engine->outputChannels.TEMPLOG_MAP_AT_DIFF = map - mapCamPrevCycleValue; #endif // EFI_TUNER_STUDIO mapCamPrevCycleValue = map; diff --git a/firmware/development/logic_analyzer.cpp b/firmware/development/logic_analyzer.cpp index e7f752a03c..bf3b9ffdc8 100644 --- a/firmware/development/logic_analyzer.cpp +++ b/firmware/development/logic_analyzer.cpp @@ -269,11 +269,11 @@ static void getChannelFreqAndDuty(int index, scaled_channel *duty, scaled void reportLogicAnalyzerToTS() { #if EFI_TUNER_STUDIO scaled_channel tmp; - getChannelFreqAndDuty(0,&tsOutputChannels.debugFloatField1, &tsOutputChannels.debugIntField1); - getChannelFreqAndDuty(1,&tsOutputChannels.debugFloatField2, &tsOutputChannels.debugIntField2); - getChannelFreqAndDuty(2,&tsOutputChannels.debugFloatField3, &tsOutputChannels.debugIntField3); - getChannelFreqAndDuty(3,&tsOutputChannels.debugFloatField4, &tmp); - tsOutputChannels.debugIntField4 = (uint16_t)tmp; + getChannelFreqAndDuty(0,&engine->outputChannels.debugFloatField1, &engine->outputChannels.debugIntField1); + getChannelFreqAndDuty(1,&engine->outputChannels.debugFloatField2, &engine->outputChannels.debugIntField2); + getChannelFreqAndDuty(2,&engine->outputChannels.debugFloatField3, &engine->outputChannels.debugIntField3); + getChannelFreqAndDuty(3,&engine->outputChannels.debugFloatField4, &tmp); + engine->outputChannels.debugIntField4 = (uint16_t)tmp; #endif } diff --git a/firmware/hw_layer/mass_storage/mass_storage_init.cpp b/firmware/hw_layer/mass_storage/mass_storage_init.cpp index 6dc29c9c01..a26aceae80 100644 --- a/firmware/hw_layer/mass_storage/mass_storage_init.cpp +++ b/firmware/hw_layer/mass_storage/mass_storage_init.cpp @@ -71,7 +71,7 @@ void attachMsdSdCard(BaseBlockDevice* blkdev) { #if EFI_TUNER_STUDIO // SD MSD attached, enable indicator in TS - tsOutputChannels.sd_msd = true; + engine->outputChannels.sd_msd = true; #endif } diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 032be918ce..a2aebc1fad 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -392,7 +392,7 @@ static bool mountMmc() { #if EFI_TUNER_STUDIO // If not null, card is present - tsOutputChannels.sd_present = cardBlockDevice != nullptr; + engine->outputChannels.sd_present = cardBlockDevice != nullptr; #endif #if HAL_USE_USB_MSD @@ -513,7 +513,7 @@ static THD_FUNCTION(MMCmonThread, arg) { } #if EFI_TUNER_STUDIO - tsOutputChannels.sd_logging_internal = true; + engine->outputChannels.sd_logging_internal = true; #endif while (true) { @@ -525,10 +525,10 @@ static THD_FUNCTION(MMCmonThread, arg) { #endif if (engineConfiguration->debugMode == DBG_SD_CARD) { - tsOutputChannels.debugIntField1 = totalLoggedBytes; - tsOutputChannels.debugIntField2 = totalWritesCounter; - tsOutputChannels.debugIntField3 = totalSyncCounter; - tsOutputChannels.debugIntField4 = fileCreatedCounter; + engine->outputChannels.debugIntField1 = totalLoggedBytes; + engine->outputChannels.debugIntField2 = totalWritesCounter; + engine->outputChannels.debugIntField3 = totalSyncCounter; + engine->outputChannels.debugIntField4 = fileCreatedCounter; } writeLogLine(logBuffer); diff --git a/firmware/hw_layer/sensors/cj125.cpp b/firmware/hw_layer/sensors/cj125.cpp index 419ee416c0..2946208b76 100644 --- a/firmware/hw_layer/sensors/cj125.cpp +++ b/firmware/hw_layer/sensors/cj125.cpp @@ -299,7 +299,7 @@ void CJ125::calibrate() { #if EFI_TUNER_STUDIO if (engineConfiguration->debugMode == DBG_CJ125) { - cjPostState(&tsOutputChannels); + cjPostState(&engine->outputChannels); } #endif /* EFI_TUNER_STUDIO */ diff --git a/firmware/hw_layer/stepper.cpp b/firmware/hw_layer/stepper.cpp index 72f8cdb54a..d0c943df7f 100644 --- a/firmware/hw_layer/stepper.cpp +++ b/firmware/hw_layer/stepper.cpp @@ -60,7 +60,7 @@ void StepperMotorBase::changeCurrentPosition(bool positive) { void StepperMotorBase::postCurrentPosition(void) { if (engineConfiguration->debugMode == DBG_IDLE_CONTROL) { #if EFI_TUNER_STUDIO - tsOutputChannels.debugIntField5 = m_currentPosition; + engine->outputChannels.debugIntField5 = m_currentPosition; #endif /* EFI_TUNER_STUDIO */ } }