From 384b459ca0f509892d3e9a21ea134d10b1d341b7 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 4 Jun 2017 15:50:33 -0400 Subject: [PATCH] refactoring --- firmware/controllers/injector_central.cpp | 12 ++++++------ firmware/controllers/injector_central.h | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 1ab40cc700..d6f1cb0774 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -45,7 +45,7 @@ bool isRunningBenchTest(void) { return isRunningBench; } -void assertCylinderId(int cylinderId, const char *msg) { +static void assertCylinderId(int cylinderId, const char *msg) { int isValid = cylinderId >= 1 && cylinderId <= engineConfiguration->specs.cylindersCount; if (!isValid) { // we are here only in case of a fatal issue - at this point it is fine to make some blocking i-o @@ -58,12 +58,12 @@ void assertCylinderId(int cylinderId, const char *msg) { /** * @param cylinderId - from 1 to NUMBER_OF_CYLINDERS */ -int isInjectorEnabled(int cylinderId) { +static int isInjectorEnabled(int cylinderId) { assertCylinderId(cylinderId, "isInjectorEnabled"); return is_injector_enabled[cylinderId - 1]; } -static void printStatus(void) { +static void printInjectorsStatus(void) { for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) { scheduleMsg(logger, "injector_%d_%d", isInjectorEnabled(id)); } @@ -72,7 +72,7 @@ static void printStatus(void) { static void setInjectorEnabled(int id, int value) { efiAssertVoid(id >= 0 && id < engineConfiguration->specs.cylindersCount, "injector id"); is_injector_enabled[id] = value; - printStatus(); + printInjectorsStatus(); } static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs, @@ -304,14 +304,14 @@ void initInjectorCentral(Logging *sharedLogger) { logger = sharedLogger; chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); - for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { + for (int i = 0; i < INJECTION_PIN_COUNT; i++) { is_injector_enabled[i] = true; } startInjectionPins(); startIgnitionPins(); - printStatus(); + printInjectorsStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleAction("fuelpumpbench", fuelPumpBench); diff --git a/firmware/controllers/injector_central.h b/firmware/controllers/injector_central.h index 91182857c0..359c422b44 100644 --- a/firmware/controllers/injector_central.h +++ b/firmware/controllers/injector_central.h @@ -19,8 +19,6 @@ void fuelPumpBench(void); void milBench(void); void initInjectorCentral(Logging *sharedLogger); bool isRunningBenchTest(void); -int isInjectorEnabled(int cylinderId); -void assertCylinderId(int cylinderId, const char *msg); void stopInjectionPins(void); void startInjectionPins(void);