refactoring
This commit is contained in:
parent
d66bd27f96
commit
384b459ca0
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue