refactoring: extract method
This commit is contained in:
parent
916b16af8f
commit
ae98105fdc
|
@ -90,6 +90,12 @@ void setManualIdleValvePosition(int positionPercent) {
|
|||
engineConfiguration->manIdlePosition = positionPercent;
|
||||
}
|
||||
|
||||
static void startInputPinIfValid(const char *msg, brain_pin_e pin, pin_input_mode_e mode) {
|
||||
if (isBrainPinValid(pin)) {
|
||||
efiSetPadMode(msg, engineConfiguration->clutchDownPin, getInputMode(mode));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
|
||||
percent_t getIdlePosition() {
|
||||
|
@ -100,25 +106,13 @@ void startPedalPins() {
|
|||
#if EFI_PROD_CODE
|
||||
// this is neutral/no gear switch input. on Miata it's wired both to clutch pedal and neutral in gearbox
|
||||
// this switch is not used yet
|
||||
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
|
||||
efiSetPadMode("clutch down switch", engineConfiguration->clutchDownPin,
|
||||
getInputMode(engineConfiguration->clutchDownPinMode));
|
||||
}
|
||||
startInputPinIfValid("clutch down switch", engineConfiguration->clutchDownPin, engineConfiguration->clutchDownPinMode);
|
||||
|
||||
if (isBrainPinValid(engineConfiguration->clutchUpPin)) {
|
||||
efiSetPadMode("clutch up switch", engineConfiguration->clutchUpPin,
|
||||
getInputMode(engineConfiguration->clutchUpPinMode));
|
||||
}
|
||||
startInputPinIfValid("clutch up switch", engineConfiguration->clutchUpPin, engineConfiguration->clutchUpPinMode);
|
||||
|
||||
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
|
||||
efiSetPadMode("throttle pedal up switch", engineConfiguration->throttlePedalUpPin,
|
||||
getInputMode(engineConfiguration->throttlePedalUpPinMode));
|
||||
}
|
||||
startInputPinIfValid("throttle pedal up switch", engineConfiguration->throttlePedalUpPin, engineConfiguration->throttlePedalUpPinMode);
|
||||
|
||||
if (isBrainPinValid(engineConfiguration->brakePedalPin)) {
|
||||
efiSetPadMode("brake pedal switch", engineConfiguration->brakePedalPin,
|
||||
getInputMode(engineConfiguration->brakePedalPinMode));
|
||||
}
|
||||
startInputPinIfValid("brake pedal switch", engineConfiguration->brakePedalPin, engineConfiguration->brakePedalPinMode);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue