diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index e885e4554c..acd3761d16 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -53,6 +53,7 @@ #include "start_stop.h" #include "dynoview.h" #include "vr_pwm.h" +#include "adc_subscription.h" #if EFI_SENSOR_CHART #include "sensor_chart.h" @@ -235,68 +236,16 @@ char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *bu return buffer; } -static char pinNameBuffer[16]; - #if HAL_USE_ADC extern AdcDevice fastAdc; #endif /* HAL_USE_ADC */ -static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel, float adcVoltage, - float dividerCoeff) { -#if HAL_USE_ADC - if (!isAdcChannelValid(hwChannel)) { - efiPrintf("ADC is not assigned for %s", name); - return; - } +static void printSensorInfo() { + // Print info about analog mappings + AdcSubscription::PrintInfo(); - float voltage = adcVoltage * dividerCoeff; - efiPrintf("%s ADC%d m=%d %s adc=%.2f/input=%.2fv/divider=%.2f", name, hwChannel, getAdcMode(hwChannel), - getPinNameByAdcChannel(name, hwChannel, pinNameBuffer), adcVoltage, voltage, dividerCoeff); -#endif /* HAL_USE_ADC */ -} - -static void printAnalogChannelInfo(const char *name, adc_channel_e hwChannel) { -#if HAL_USE_ADC - printAnalogChannelInfoExt(name, hwChannel, getVoltage(name, hwChannel), engineConfiguration->analogInputDividerCoefficient); -#endif /* HAL_USE_ADC */ -} - -static void printAnalogInfo() { - efiPrintf("analogInputDividerCoefficient: %.2f", engineConfiguration->analogInputDividerCoefficient); - - printAnalogChannelInfo("hip9011", engineConfiguration->hipOutputChannel); - printAnalogChannelInfo("fuel gauge", engineConfiguration->fuelLevelSensor); - printAnalogChannelInfo("TPS1 Primary", engineConfiguration->tps1_1AdcChannel); - printAnalogChannelInfo("TPS1 Secondary", engineConfiguration->tps1_2AdcChannel); - printAnalogChannelInfo("TPS2 Primary", engineConfiguration->tps2_1AdcChannel); - printAnalogChannelInfo("TPS2 Secondary", engineConfiguration->tps2_2AdcChannel); - printAnalogChannelInfo("LPF", engineConfiguration->lowPressureFuel.hwChannel); - printAnalogChannelInfo("HPF", engineConfiguration->highPressureFuel.hwChannel); - printAnalogChannelInfo("pPS1", engineConfiguration->throttlePedalPositionAdcChannel); - printAnalogChannelInfo("pPS2", engineConfiguration->throttlePedalPositionSecondAdcChannel); - printAnalogChannelInfo("CLT", engineConfiguration->clt.adcChannel); - printAnalogChannelInfo("IAT", engineConfiguration->iat.adcChannel); - printAnalogChannelInfo("AuxT1", engineConfiguration->auxTempSensor1.adcChannel); - printAnalogChannelInfo("AuxT2", engineConfiguration->auxTempSensor2.adcChannel); - printAnalogChannelInfo("MAF", engineConfiguration->mafAdcChannel); - for (int i = 0; i < AUX_ANALOG_INPUT_COUNT ; i++) { - adc_channel_e ch = engineConfiguration->auxAnalogInputs[i]; - printAnalogChannelInfo("Aux analog", ch); - } - - printAnalogChannelInfo("AFR", engineConfiguration->afr.hwChannel); - printAnalogChannelInfo("MAP", engineConfiguration->map.sensor.hwChannel); - printAnalogChannelInfo("BARO", engineConfiguration->baroSensor.hwChannel); - - printAnalogChannelInfo("OilP", engineConfiguration->oilPressure.hwChannel); - - printAnalogChannelInfo("CJ UR", engineConfiguration->cj125ur); - printAnalogChannelInfo("CJ UA", engineConfiguration->cj125ua); - - printAnalogChannelInfo("HIP9011", engineConfiguration->hipOutputChannel); - - printAnalogChannelInfoExt("Vbatt", engineConfiguration->vbattAdcChannel, getVoltage("vbatt", engineConfiguration->vbattAdcChannel), - engineConfiguration->vbattDividerCoeff); + // Print info about all sensors + Sensor::showAllSensorInfo(); } #define isOutOfBounds(offset) ((offset<0) || (offset) >= (int) sizeof(engine_configuration_s)) @@ -650,7 +599,7 @@ bool validateConfig() { #if !EFI_UNIT_TEST void initEngineController() { - addConsoleAction("analoginfo", printAnalogInfo); + addConsoleAction("sensorinfo", printSensorInfo); #if EFI_PROD_CODE && EFI_ENGINE_CONTROL initBenchTest(); diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index a3a9f9861a..0f73f2c428 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -229,19 +229,6 @@ void printTPSInfo(void) { printTpsSenser("TPS2", SensorType::Tps2, engineConfiguration->tps2Min, engineConfiguration->tps2Max, engineConfiguration->tps2_1AdcChannel); } -static void printTemperatureInfo() { -#if EFI_ANALOG_SENSORS - Sensor::showAllSensorInfo(); - - efiPrintf("fan=%s @ %s", boolToString(enginePins.fanRelay.getLogicValue()), - hwPortname(engineConfiguration->fanPin)); - - efiPrintf("A/C relay=%s @ %s", boolToString(enginePins.acRelay.getLogicValue()), - hwPortname(engineConfiguration->acRelayPin)); - -#endif /* EFI_ANALOG_SENSORS */ -} - static void setCrankingRpm(int value) { engineConfiguration->cranking.rpm = value; doPrintConfiguration(); @@ -274,8 +261,6 @@ static void setCrankingIACExtra(float percent) { static void setCrankingFuel(float timeMs) { engineConfiguration->cranking.baseFuel = timeMs; efiPrintf("cranking_fuel %.2f", timeMs); - - printTemperatureInfo(); } static void setGlobalTriggerAngleOffset(float value) { @@ -824,14 +809,6 @@ void scheduleStopEngine(void) { doScheduleStopEngine(); } -static void printAllInfo() { - printTemperatureInfo(); - printTPSInfo(); -#if EFI_ENGINE_SNIFFER - efiPrintf("waveChartUsedSize=%d", waveChartUsedSize); -#endif -} - #if ! EFI_UNIT_TEST const plain_get_short_s getS_plain[] = { {"idle_pid_min", (uint16_t *)&engineConfiguration->idleRpmPid.minValue}, @@ -1145,11 +1122,9 @@ void initSettings(void) { // todo: start saving values into flash right away? addConsoleAction("showconfig", doPrintConfiguration); - addConsoleAction("tempinfo", printTemperatureInfo); addConsoleAction("tpsinfo", printTPSInfo); addConsoleAction("calibrate_tps_1_closed", grabTPSIsClosed); addConsoleAction("calibrate_tps_1_wot", grabTPSIsWideOpen); - addConsoleAction("info", printAllInfo); addConsoleAction("set_one_coil_ignition", setOneCoilIgnition); addConsoleAction("set_wasted_spark_ignition", setWastedIgnition); diff --git a/firmware/hw_layer/adc/adc_subscription.cpp b/firmware/hw_layer/adc/adc_subscription.cpp index a482411f85..bd8af6f5c9 100644 --- a/firmware/hw_layer/adc/adc_subscription.cpp +++ b/firmware/hw_layer/adc/adc_subscription.cpp @@ -130,4 +130,33 @@ void AdcSubscription::UpdateSubscribers(efitick_t nowNt) { } } +#if EFI_PROD_CODE +void AdcSubscription::PrintInfo() { + for (size_t i = 0; i < efi::size(s_entries); i++) { + auto& entry = s_entries[i]; + + if (!entry.Sensor) { + // Skip unconfigured entries + continue; + } + + const auto name = entry.Sensor->getSensorName(); + float mcuVolts = getVoltage("sensor", entry.Channel); + float sensorVolts = mcuVolts * entry.VoltsPerAdcVolt; + auto channel = entry.Channel; + + char pinNameBuffer[16]; + + efiPrintf( + "%s ADC%d m=%d %s adc=%.2f/input=%.2fv/divider=%.2f", + name, + channel, + getAdcMode(channel), + getPinNameByAdcChannel(name, channel, pinNameBuffer), + mcuVolts, sensorVolts, entry.VoltsPerAdcVolt + ); + } +} +#endif // EFI_PROD_CODE + #endif // !EFI_UNIT_TEST diff --git a/firmware/hw_layer/adc/adc_subscription.h b/firmware/hw_layer/adc/adc_subscription.h index 661e891359..37cb2f066f 100644 --- a/firmware/hw_layer/adc/adc_subscription.h +++ b/firmware/hw_layer/adc/adc_subscription.h @@ -12,4 +12,6 @@ public: static void SubscribeSensor(FunctionalSensor &sensor, adc_channel_e channel, float lowpassCutoff, float voltsPerAdcVolt = 0.0f); static void UnsubscribeSensor(FunctionalSensor& sensor); static void UpdateSubscribers(efitick_t nowNt); + + static void PrintInfo(); }; diff --git a/java_console/ui/src/main/java/com/rusefi/ui/RecentCommands.java b/java_console/ui/src/main/java/com/rusefi/ui/RecentCommands.java index 7742d16beb..96809ed4ef 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/RecentCommands.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/RecentCommands.java @@ -36,7 +36,7 @@ public class RecentCommands { private static final String STOPENGINE = "stopengine"; private static final String SHOWCONFIG = "showconfig"; private static final String HELP = "help"; - private static final String ANALOGINFO = "analoginfo"; + private static final String SENSORINFO = "sensorinfo"; private static final String IDLEINFO = "idleinfo"; private static final String ALTINFO = "altinfo"; private static final String TPSINFO = "tpsinfo"; @@ -47,7 +47,6 @@ public class RecentCommands { private static final String SPEEDINFO = "speedinfo"; private static final String joystickINFO = "joystickinfo"; private static final String FUELINFO = "fuelinfo"; - private static final String TEMPINFO = "tempinfo"; private static final String HIPINFO = "hipinfo"; private static final String SDINFO = "sdinfo"; private static final String FSIOINFO = "fsioinfo"; @@ -60,7 +59,7 @@ public class RecentCommands { ImageIcon infoIcon = AutoupdateUtil.loadIcon("info.png"); COMMAND_ICONS.put(SHOWCONFIG, infoIcon); COMMAND_ICONS.put(HELP, AutoupdateUtil.loadIcon("help.jpg")); - COMMAND_ICONS.put(ANALOGINFO, infoIcon); + COMMAND_ICONS.put(SENSORINFO, infoIcon); COMMAND_ICONS.put(CMD_TRIGGERINFO, AutoupdateUtil.loadIcon("trigger.jpg")); COMMAND_ICONS.put(IDLEINFO, infoIcon); COMMAND_ICONS.put(ALTINFO, AutoupdateUtil.loadIcon("alternator.jpg")); @@ -71,7 +70,6 @@ public class RecentCommands { COMMAND_ICONS.put(joystickINFO, AutoupdateUtil.loadIcon("joystick.png")); COMMAND_ICONS.put(CANINFO, infoIcon); COMMAND_ICONS.put(FUELINFO, infoIcon); - COMMAND_ICONS.put(TEMPINFO, infoIcon); COMMAND_ICONS.put(HIPINFO, AutoupdateUtil.loadIcon("knock.jpg")); COMMAND_ICONS.put(SDINFO, AutoupdateUtil.loadIcon("sdinfo.jpg")); COMMAND_ICONS.put(FSIOINFO, infoIcon); @@ -121,7 +119,7 @@ public class RecentCommands { add(HELP); add(SHOWCONFIG); add(STOPENGINE); - add(ANALOGINFO); + add(SENSORINFO); add(CMD_TRIGGERINFO); add(TSINFO); add(SPEEDINFO); @@ -149,7 +147,6 @@ public class RecentCommands { add(MAPINFO); add(ACCELINFO); add(FUELINFO); - add(TEMPINFO); add(HIPINFO); add(SDINFO); add(FSIOINFO);