diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index f089cea374..48530f09e4 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -38,6 +38,7 @@ All notable user-facing or behavior-altering changes will be documented in this ## Removed - Remove engine load acceleration enrichment #3357 + - FSIO removed from user interface #2928 ## October 2021 Release - "Pierogi Day" diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 737a2fe42e..ea431d57ce 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -1181,10 +1181,6 @@ void applyNonPersistentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_ENGINE_CONTROL ENGINE(initializeTriggerWaveform(PASS_ENGINE_PARAMETER_SIGNATURE)); #endif // EFI_ENGINE_CONTROL - -#if EFI_FSIO - applyFsioConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE); -#endif // EFI_FSIO } #if EFI_ENGINE_CONTROL diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index b6b376966a..98875ec721 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -78,7 +78,6 @@ static LEElement sysElements[SYS_ELEMENT_POOL_SIZE] CCM_OPTIONAL; CCM_OPTIONAL LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE); static LEElement userElements[UD_ELEMENT_POOL_SIZE] CCM_OPTIONAL; -CCM_OPTIONAL LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE); class FsioPointers { public: @@ -182,161 +181,16 @@ static void setFsioAnalogInputPin(const char *indexStr, const char *pinName) { efiPrintf("FSIO analog input pin #%d [%s]", (index + 1), hwPortname(pin)); } -static void setFsioDigitalInputPin(const char *indexStr, const char *pinName) { - // todo: reduce code duplication between all "set pin methods" - int index = atoi(indexStr) - 1; - if (index < 0 || index >= FSIO_COMMAND_COUNT) { - efiPrintf("invalid FSIO 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) { - efiPrintf("invalid pin name [%s]", pinName); - return; - } - CONFIG(fsioDigitalInputs)[index] = pin; - efiPrintf("FSIO digital input pin #%d [%s]", (index + 1), hwPortname(pin)); -} - -static void setFsioPidOutputPin(const char *indexStr, const char *pinName) { - int index = atoi(indexStr) - 1; - if (index < 0 || index >= CAM_INPUTS_COUNT) { - efiPrintf("invalid VVT 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) { - efiPrintf("invalid pin name [%s]", pinName); - return; - } - engineConfiguration->vvtPins[index] = pin; - efiPrintf("VVT pid pin #%d [%s]", (index + 1), hwPortname(pin)); -} - -static void showFsioInfo(void); - -static void setFsioOutputPin(const char *indexStr, const char *pinName) { - int index = atoi(indexStr) - 1; - if (index < 0 || index >= FSIO_COMMAND_COUNT) { - efiPrintf("invalid FSIO 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) { - efiPrintf("invalid pin name [%s]", pinName); - return; - } - CONFIG(fsioOutputPins)[index] = pin; - efiPrintf("FSIO output pin #%d [%s]", (index + 1), hwPortname(pin)); - efiPrintf("please writeconfig and reboot for pin to take effect"); - showFsioInfo(); -} #endif /* EFI_PROD_CODE */ #endif -void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - userPool.reset(); - for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { - const char *formula = config->fsioFormulas[i]; - int len = strlen(formula); - LEElement *logic = userPool.parseExpression(formula); - if (len > 0 && logic == NULL) { - warning(CUSTOM_FSIO_PARSING, "parsing [%s]", formula); - } - - state.fsioLogics[i] = logic; - } -} - void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX) { (void)previousConfiguration; -#if EFI_FSIO - applyFsioConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE); -#endif } static LECalculator calc CCM_OPTIONAL; -static SimplePwm fsioPwm[FSIO_COMMAND_COUNT] CCM_OPTIONAL; - -// that's crazy, but what's an alternative? we need const char *, a shared buffer would not work for pin repository -static const char *getGpioPinName(int index) { - switch (index) { - case 0: - return "FSIO_OUT_0"; - case 1: - return "FSIO_OUT_1"; - case 10: - return "FSIO_OUT_10"; - case 11: - return "FSIO_OUT_11"; - case 12: - return "FSIO_OUT_12"; - case 13: - return "FSIO_OUT_13"; - case 14: - return "FSIO_OUT_14"; - case 15: - return "FSIO_OUT_15"; - case 2: - return "FSIO_OUT_2"; - case 3: - return "FSIO_OUT_3"; - case 4: - return "FSIO_OUT_4"; - case 5: - return "FSIO_OUT_5"; - case 6: - return "FSIO_OUT_6"; - case 7: - return "FSIO_OUT_7"; - case 8: - return "FSIO_OUT_8"; - case 9: - return "FSIO_OUT_9"; - } - return NULL; -} - -float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { - if (state.fsioLogics[index] == NULL) { - warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); - return NAN; - } else { - return calc.evaluate("FSIO", engine->fsioState.fsioLastValue[index], state.fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX); - } -} - -/** - * @param index from zero for (FSIO_COMMAND_COUNT - 1) - */ -static void runFsioCalculation(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { - if (strlen(config->fsioFormulas[index]) == 0) { - engine->fsioState.fsioLastValue[index] = NAN; - return; - } - - bool isPwmMode = CONFIG(fsioFrequency)[index] != NO_PWM; - - float fvalue = getFsioOutputValue(index PASS_ENGINE_PARAMETER_SUFFIX); - engine->fsioState.fsioLastValue[index] = fvalue; - - if (isPwmMode) { - fsioPwm[index].setSimplePwmDutyCycle(fvalue); - } else { - int value = (int) fvalue; - if (value != enginePins.fsioOutputs[index].getLogicValue()) { - // efiPrintf("setting %s %s", getIo_pin_e(pin), boolToString(value)); - enginePins.fsioOutputs[index].setValue(value); - } - } -} - - static const char * action2String(le_action_e action) { static char buffer[_MAX_FILLER]; switch(action) { @@ -387,23 +241,6 @@ static void setPinState(const char * msg, OutputPin *pin, LEElement *element DEC } } - -#if EFI_PROD_CODE -static void setFsioFrequency(int index, int frequency) { - index--; - if (index < 0 || index >= FSIO_COMMAND_COUNT) { - efiPrintf("invalid FSIO index: %d", index); - return; - } - CONFIG(fsioFrequency)[index] = frequency; - if (frequency == 0) { - efiPrintf("FSIO output #%d@%s set to on/off mode", index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); - } else { - efiPrintf("Setting FSIO frequency %dHz on #%d@%s", frequency, index + 1, hwPortname(CONFIG(fsioOutputPins)[index])); - } -} -#endif /* EFI_PROD_CODE */ - /** * @param out param! current and new value as long as element is not NULL * @return 'true' if value has changed @@ -426,10 +263,6 @@ static bool updateValueOrWarning(int humanIndex, const char *msg, float *value D * this method should be invoked periodically to calculate FSIO and toggle corresponding FSIO outputs */ void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - for (int index = 0; index < FSIO_COMMAND_COUNT; index++) { - runFsioCalculation(index PASS_ENGINE_PARAMETER_SUFFIX); - } - #if EFI_FUEL_PUMP if (isBrainPinValid(CONFIG(fuelPumpPin))) { setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic PASS_ENGINE_PARAMETER_SUFFIX); @@ -489,37 +322,8 @@ static void showFsio(const char *msg, LEElement *element) { static void showFsioInfo(void) { #if EFI_PROD_CODE || EFI_SIMULATOR - efiPrintf("sys used %d/user used %d", sysPool.getSize(), userPool.getSize()); showFsio("fuel", fuelPumpLogic); - for (int i = 0; i < CAM_INPUTS_COUNT ; i++) { - brain_pin_e pin = engineConfiguration->vvtPins[i]; - if (isBrainPinValid(pin)) { - efiPrintf("VVT pid #%d [%s]", (i + 1), - hwPortname(pin)); - - } - } - - - - for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { - char * exp = config->fsioFormulas[i]; - if (exp[0] != 0) { - /** - * in case of FSIO user interface indexes are starting with 0, the argument for that - * is the fact that the target audience is more software developers - */ - int freq = CONFIG(fsioFrequency)[i]; - const char *modeMessage = freq == 0 ? " (on/off mode)" : ""; - efiPrintf("FSIO #%d [%s] at %s@%dHz%s value=%.2f", (i + 1), exp, - hwPortname(CONFIG(fsioOutputPins)[i]), - freq, modeMessage, - engine->fsioState.fsioLastValue[i]); -// efiPrintf("user-defined #%d value=%.2f", i, engine->engineConfigurationPtr2->fsioLastValue[i]); - showFsio(NULL, state.fsioLogics[i]); - } - } for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { float v = CONFIG(scriptSetting)[i]; if (!cisnan(v)) { @@ -550,30 +354,6 @@ static void setFsioSetting(float humanIndexF, float value) { #endif } -void setFsioExpression(const char *indexStr, const char *quotedLine DECLARE_CONFIG_PARAMETER_SUFFIX) { - int index = atoi(indexStr) - 1; - if (index < 0 || index >= FSIO_COMMAND_COUNT) { - efiPrintf("invalid FSIO index: %d", index); - return; - } - char * l = unquote((char*) quotedLine); - if (strlen(l) > LE_COMMAND_LENGTH - 1) { - efiPrintf("Too long %d", strlen(l)); - return; - } - - efiPrintf("setting user out #%d to [%s]", index + 1, l); - strcpy(config->fsioFormulas[index], l); -} - -void applyFsioExpression(const char *indexStr, const char *quotedLine DECLARE_ENGINE_PARAMETER_SUFFIX) { - setFsioExpression(indexStr, quotedLine PASS_CONFIG_PARAMETER_SUFFIX); - - // this would apply the changes - applyFsioConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE); - showFsioInfo(); -} - ValueProvider3D *getFSIOTable(int index) { switch (index) { default: diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index 44ad0375b3..7be9465d7f 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -24,10 +24,7 @@ expected getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFI void initFsioImpl(DECLARE_ENGINE_PARAMETER_SIGNATURE); void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE); -void setFsioExpression(const char *indexStr, const char *quotedLine DECLARE_CONFIG_PARAMETER_SUFFIX); -void applyFsioExpression(const char *indexStr, const char *quotedLine DECLARE_ENGINE_PARAMETER_SUFFIX); -float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX); -void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); + void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX); void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE);