diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 82beaabbc5..ebfa7a5b3d 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -451,7 +451,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { for (int i = 0; i < LE_COMMAND_COUNT; i++) { boardConfiguration->fsioPins[i] = GPIO_UNASSIGNED; config->le_formulas[i][0] = 0; - boardConfiguration->fsioInputs[i] = GPIO_UNASSIGNED; + boardConfiguration->fsioDigitalInputs[i] = GPIO_UNASSIGNED; engineConfiguration->fsioInputModes[i] = PI_DEFAULT; } for (int i = 0; i < JOYSTICK_PIN_COUNT; i++) { diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 0293b4ebe3..84f1a846a1 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Sat Apr 25 18:11:41 EDT 2015 +// this section was generated by config_definition.jar on Sat Apr 25 21:03:34 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -623,9 +623,10 @@ typedef struct { */ pin_input_mode_e clutchUpPinMode; /** + * These input pins allow us to pull toggle buttons state * offset 804 */ - brain_pin_e fsioInputs[LE_COMMAND_COUNT]; + brain_pin_e fsioDigitalInputs[LE_COMMAND_COUNT]; /** * offset 868 */ @@ -1289,4 +1290,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Sat Apr 25 18:11:41 EDT 2015 +// this section was generated by config_definition.jar on Sat Apr 25 21:03:34 EDT 2015 diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index d2ea65b84b..ebdb3dbc2b 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -98,7 +98,23 @@ float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) { // todo: that's about bench test mode, wrong header for sure! #include "injector_central.h" -static void setFsioPin(const char *indexStr, const char *pinName) { +static void setFsioInputPin(const char *indexStr, const char *pinName) { + int index = atoi(indexStr) - 1; + if (index < 0 || index >= LE_COMMAND_COUNT) { + scheduleMsg(logger, "invalid index %d", index); + return; + } + brain_pin_e pin = parseBrainPin(pinName); + // todo: extract method - code duplication with other 'set_xxx_pin' methods? + if (pin == GPIO_INVALID) { + scheduleMsg(logger, "invalid pin name [%s]", pinName); + return; + } + boardConfiguration->fsioDigitalInputs[index] = pin; + scheduleMsg(logger, "FSIO input pin #%d [%s]", (index + 1), hwPortname(pin)); +} + +static void setFsioOutputPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr) - 1; if (index < 0 || index >= LE_COMMAND_COUNT) { scheduleMsg(logger, "invalid index %d", index); @@ -111,7 +127,7 @@ static void setFsioPin(const char *indexStr, const char *pinName) { return; } boardConfiguration->fsioPins[index] = pin; - scheduleMsg(logger, "FSIO pin #%d [%s]", (index + 1), hwPortname(pin)); + scheduleMsg(logger, "FSIO output pin #%d [%s]", (index + 1), hwPortname(pin)); } #endif @@ -267,6 +283,13 @@ static void showFsioInfo(void) { scheduleMsg(logger, "user property #%d: %f", i + 1, v); } } + for (int i = 0; i < LE_COMMAND_COUNT; i++) { + brain_pin_e inputPin = boardConfiguration->fsioDigitalInputs[i]; + if (inputPin != GPIO_UNASSIGNED) { + scheduleMsg(logger, "FSIO digital input #%d: %s", i, hwPortname(inputPin)); + } + } + } /** @@ -292,7 +315,7 @@ static void setFsioFrequency(int index, int frequency) { scheduleMsg(logger, "Setting FSIO frequency %d on #%d", frequency, index + 1); } -static void setUserOutput(const char *indexStr, const char *quotedLine, Engine *engine) { +static void setFsioExpression(const char *indexStr, const char *quotedLine, Engine *engine) { int index = atoi(indexStr) - 1; if (index < 0 || index >= LE_COMMAND_COUNT) { scheduleMsg(logger, "invalid index %d", index); @@ -390,20 +413,22 @@ void initFsioImpl(Logging *sharedLogger, Engine *engine) { } for (int i = 0; i < LE_COMMAND_COUNT; i++) { - brain_pin_e inputPin = boardConfiguration->fsioInputs[i]; + brain_pin_e inputPin = boardConfiguration->fsioDigitalInputs[i]; if (inputPin != GPIO_UNASSIGNED) { mySetPadMode2("FSIO input", inputPin, getInputMode(engineConfiguration->fsioInputModes[i])); - } } #endif /* EFI_PROD_CODE */ - addConsoleActionSSP("set_fsio", (VoidCharPtrCharPtrVoidPtr) setUserOutput, engine); - addConsoleActionSS("set_fsio_pin", (VoidCharPtrCharPtr) setFsioPin); - addConsoleActionII("set_fsio_frequency", (VoidIntInt) setFsioFrequency); + addConsoleActionSSP("set_fsio_expression", (VoidCharPtrCharPtrVoidPtr) setFsioExpression, engine); + addConsoleActionSS("set_fsio_output_pin", (VoidCharPtrCharPtr) setFsioOutputPin); + addConsoleActionII("set_fsio_output_frequency", (VoidIntInt) setFsioFrequency); + addConsoleActionFF("set_fsio_setting", setFsioSetting); + + addConsoleActionSS("set_fsio_input_pin", (VoidCharPtrCharPtr) setFsioInputPin); addConsoleAction("fsioinfo", showFsioInfo); addConsoleActionSP("eval", (VoidCharPtrVoidPtr) eval, engine); diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 112ac57692..cadf266e58 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -484,6 +484,7 @@ static void configureInputs(void) { addChannel(engineConfiguration->cltAdcChannel, ADC_SLOW); addChannel(engineConfiguration->iatAdcChannel, ADC_SLOW); addChannel(engineConfiguration->afr.hwChannel, ADC_SLOW); + addChannel(engineConfiguration->acSwitchAdc, ADC_SLOW); } void initAdcInputs(bool boardTestMode) { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index f86ba4baca..7609372e9d 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -402,7 +402,7 @@ brain_pin_e vehicleSpeedSensorInputPin; brain_pin_e clutchUpPin;Some vehicles have a switch to indicate that clutch pedal is all the way up pin_input_mode_e clutchUpPinMode; - brain_pin_e[LE_COMMAND_COUNT iterate] fsioInputs; + brain_pin_e[LE_COMMAND_COUNT iterate] fsioDigitalInputs;These input pins allow us to pull toggle buttons state; int unusedbs; diff --git a/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java b/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java index 8915b09225..10f45739f9 100644 --- a/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java +++ b/java_console/ui/src/com/rusefi/ui/fsio/FlexibleControls.java @@ -32,7 +32,7 @@ public class FlexibleControls { panel.add(new JLabel("Human-readable")); panel.add(normalForm); panel.add(human2rpm); - panel.add(new JLabel("RPM form")); + panel.add(new JLabel("RPN form")); panel.add(rpnForm); normalForm.setText("(time_since_boot < 4) | (rpm > 0)");