From 06e52a0bc723676a7222579c87ff6153b758d2d2 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 3 Jul 2024 01:24:14 -0700 Subject: [PATCH] put ignition pin back --- firmware/controllers/settings.cpp | 20 ++++++++++++++++++++ firmware/integration/rusefi_config.txt | 1 + 2 files changed, 21 insertions(+) diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index d5e3ce1fb7..438cb5a887 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -137,6 +137,25 @@ static brain_pin_e parseBrainPinWithErrorMessage(const char *pinName) { return pin; } +/** + * For example: + * set_ignition_pin 1 PD7 + * todo: this method counts index from 1 while at least 'set_trigger_input_pin' counts from 0. + * todo: make things consistent + */ +static void setIgnitionPin(const char *indexStr, const char *pinName) { + int index = atoi(indexStr) - 1; // convert from human index into software index + if (index < 0 || index >= MAX_CYLINDER_COUNT) + return; + brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); + if (pin == Gpio::Invalid) { + return; + } + efiPrintf("setting ignition pin[%d] to %s please save&restart", index, hwPortname(pin)); + engineConfiguration->ignitionPins[index] = pin; + incrementGlobalConfigurationVersion(); +} + static void setIndividualPin(const char *pinName, brain_pin_e *targetPin, const char *name) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); if (pin == Gpio::Invalid) { @@ -479,6 +498,7 @@ void initSettings() { addConsoleActionS("get", getValue); #if EFI_PROD_CODE + addConsoleActionSS(CMD_IGNITION_PIN, setIgnitionPin); addConsoleActionSS(CMD_TRIGGER_PIN, setTriggerInputPin); addConsoleActionSS(CMD_TRIGGER_SIMULATOR_PIN, setTriggerSimulatorPin); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index c10b17b083..df774e4320 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1774,6 +1774,7 @@ end_struct #define CMD_IDLE_PIN "set_idle_pin" #define CMD_BOOST_PIN "set_boost_pin" #define CMD_TRIGGER_SIMULATOR_PIN "set_trigger_simulator_pin" +#define CMD_IGNITION_PIN "set_ignition_pin" #define CMD_RESET_ENGINE_SNIFFER "reset_engine_chart" #define CMD_FUNCTIONAL_TEST_MODE "test_mode"