From 13c9de1c805049e5c436ba969b2dda456a60c9cd Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 29 Oct 2022 23:04:24 -0400 Subject: [PATCH] refactoring: helper method --- .../boards/hellen/hellen121vag/board_configuration.cpp | 6 ++++-- firmware/controllers/actuators/electronic_throttle.cpp | 7 ++----- firmware/controllers/algo/defaults/default_base_engine.cpp | 5 +++++ firmware/controllers/algo/defaults/defaults.h | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp index 4d6faca2f4..404383dd9c 100644 --- a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp @@ -14,6 +14,7 @@ #include "custom_engine.h" #include "electronic_throttle_impl.h" #include "hellen_meta.h" +#include "defaults.h" static void setInjectorPins() { engineConfiguration->injectionPins[0] = H176_LS_1; // 96 - INJ_1 @@ -74,8 +75,9 @@ static void setupDefaultSensorInputs() { engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; - engineConfiguration->throttlePedalPositionAdcChannel = H144_IN_PPS; // 34 In PPS1 - engineConfiguration->throttlePedalPositionSecondAdcChannel = H144_IN_AUX2; // 35 In PPS2 + // 34 In PPS1 + // 35 In PPS2 + setPPSInputs(H144_IN_PPS, H144_IN_AUX2); engineConfiguration->throttlePedalUpVoltage = 0.4; engineConfiguration->throttlePedalWOTVoltage = 2; diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index e08325843c..46d4e7a4db 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -80,6 +80,7 @@ #include "dc_motor.h" #include "dc_motors.h" #include "pid_auto_tune.h" +#include "defaults.h" #if defined(HAS_OS_ACCESS) #error "Unexpected OS ACCESS HERE" @@ -1110,11 +1111,7 @@ void setProteusHitachiEtbDefaults() { engineConfiguration->tps2_1AdcChannel = PROTEUS_IN_TPS2_1; // EFI_ADC_0: "Analog Volt 5" engineConfiguration->tps2_2AdcChannel = PROTEUS_IN_ANALOG_VOLT_5; - // EFI_ADC_1: "Analog Volt 6" - engineConfiguration->throttlePedalPositionAdcChannel = PROTEUS_IN_ANALOG_VOLT_6; - - // EFI_ADC_2: "Analog Volt 7" - engineConfiguration->throttlePedalPositionSecondAdcChannel = PROTEUS_IN_PPS2; + setPPSInputs(PROTEUS_IN_ANALOG_VOLT_6, PROTEUS_IN_PPS2); #endif // HW_PROTEUS } diff --git a/firmware/controllers/algo/defaults/default_base_engine.cpp b/firmware/controllers/algo/defaults/default_base_engine.cpp index 498a8b60ce..906aa35f3f 100644 --- a/firmware/controllers/algo/defaults/default_base_engine.cpp +++ b/firmware/controllers/algo/defaults/default_base_engine.cpp @@ -96,3 +96,8 @@ void setDefaultBaseEngine() { setDefaultVrThresholds(); } + +void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) { + engineConfiguration->throttlePedalPositionAdcChannel = pps1; + engineConfiguration->throttlePedalPositionSecondAdcChannel = pps2; +} \ No newline at end of file diff --git a/firmware/controllers/algo/defaults/defaults.h b/firmware/controllers/algo/defaults/defaults.h index 014fbd4816..1e7a371712 100644 --- a/firmware/controllers/algo/defaults/defaults.h +++ b/firmware/controllers/algo/defaults/defaults.h @@ -7,3 +7,4 @@ void setDefaultBaseEngine(); void setDefaultFuel(); void setDefaultIgnition(); void setDefaultCranking(); +void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2);