From 8b197451edf2c0b2dba923e6ba868d4f25e76c8d Mon Sep 17 00:00:00 2001 From: rusEfi Date: Wed, 26 Nov 2014 22:03:05 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/core/le_functions.cpp | 3 +++ firmware/controllers/core/logic_expression.h | 1 + firmware/controllers/engine_controller.cpp | 5 ++++- firmware/controllers/sensors/allsensors.cpp | 12 ++++++++++++ firmware/controllers/sensors/allsensors.h | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/core/le_functions.cpp b/firmware/controllers/core/le_functions.cpp index 7ed43452cc..c2e5dce782 100644 --- a/firmware/controllers/core/le_functions.cpp +++ b/firmware/controllers/core/le_functions.cpp @@ -22,6 +22,7 @@ static LENameOrdinalPair leMaf(LE_METHOD_MAF, "maf"); static LENameOrdinalPair leVBatt(LE_METHOD_VBATT, "vbatt"); static LENameOrdinalPair leFan(LE_METHOD_FAN, "fan"); static LENameOrdinalPair leCoolant(LE_METHOD_COOLANT, "coolant"); +static LENameOrdinalPair leAcToggle(LE_METHOD_AC_TOGGLE, "ac_toggle"); static LENameOrdinalPair leFanOnSetting(LE_METHOD_FAN_ON_SETTING, "fan_on_setting"); static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING, "fan_off_setting"); static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot"); @@ -32,6 +33,8 @@ float getLEValue(Engine *engine, le_action_e action) { switch (action) { case LE_METHOD_FAN: return getOutputPinValue(FAN_RELAY); + case LE_METHOD_AC_TOGGLE: + return getAcToggle(engine); case LE_METHOD_COOLANT: return getCoolantTemperature(engine); case LE_METHOD_INTAKE_AIR: diff --git a/firmware/controllers/core/logic_expression.h b/firmware/controllers/core/logic_expression.h index bd1b4a15fb..b8d840c0fb 100644 --- a/firmware/controllers/core/logic_expression.h +++ b/firmware/controllers/core/logic_expression.h @@ -38,6 +38,7 @@ typedef enum { LE_METHOD_MAF = 107, LE_METHOD_INTAKE_AIR = 108, LE_METHOD_VBATT = 109, + LE_METHOD_AC_TOGGLE = 110, Force_4b_le_action = ENUM_SIZE_HACK, diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 2f22f954f5..1fdcc37694 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -277,7 +277,9 @@ static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel, } static void printAnalogChannelInfo(const char *name, adc_channel_e hwChannel) { - printAnalogChannelInfoExt(name, hwChannel, getVoltage(hwChannel)); + if (hwChannel != EFI_ADC_NONE) { + printAnalogChannelInfoExt(name, hwChannel, getVoltage(hwChannel)); + } } static void printAnalogInfo(void) { @@ -292,6 +294,7 @@ static void printAnalogInfo(void) { if (engineConfiguration->hasBaroSensor) { printAnalogChannelInfo("BARO", engineConfiguration->baroSensor.hwChannel); } + printAnalogChannelInfo("A/C sw", engineConfiguration->acSwitchAdc); printAnalogChannelInfoExt("Vbatt", engineConfiguration->vbattAdcChannel, getVBatt(engineConfiguration)); } diff --git a/firmware/controllers/sensors/allsensors.cpp b/firmware/controllers/sensors/allsensors.cpp index 8a1481c72c..8fae42d8af 100644 --- a/firmware/controllers/sensors/allsensors.cpp +++ b/firmware/controllers/sensors/allsensors.cpp @@ -12,3 +12,15 @@ void initSensors(Engine *engine) { initThermistors(engine); } + +// todo: move this somewhere else? maybe. +bool getAcToggle(Engine *engine) { + engine_configuration_s *engineConfiguration = engine->engineConfiguration; + /** + * todo: make this flexible + * + * for now we are looking for a pull-up. High level means input switch is floating (which is OFF position) + * low value means input is ground - which means ON. + */ + return getVoltageDivided(engine->engineConfiguration->acSwitchAdc) < 2.5; +} diff --git a/firmware/controllers/sensors/allsensors.h b/firmware/controllers/sensors/allsensors.h index 49ba691b5e..36766bb145 100644 --- a/firmware/controllers/sensors/allsensors.h +++ b/firmware/controllers/sensors/allsensors.h @@ -27,4 +27,6 @@ void initSensors(Engine *engine); +bool getAcToggle(Engine *engine); + #endif /*SENSORS_H_*/