refactoring: better variable names

This commit is contained in:
rusefillc 2023-04-12 22:44:57 -04:00
parent 306ec7711d
commit d9a1e5adaa
1 changed files with 24 additions and 24 deletions

View File

@ -118,19 +118,19 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float startDelayMs
static volatile bool isBenchTestPending = false; static volatile bool isBenchTestPending = false;
static bool widebandUpdatePending = false; static bool widebandUpdatePending = false;
static float onTime; static float onTimeMs;
static float offTime; static float offTimeMs;
static float startDelayMs; static float startDelayMs;
static int count; static int count;
static brain_pin_e brainPin; static brain_pin_e brainPin;
static OutputPin* pinX; static OutputPin* pinX;
static void pinbench(float startdelay, float ontime, float offtime, int iterations, static void pinbench(float startdelay, float p_ontimeMs, float p_offtimeMs, int iterations,
OutputPin* pinParam, brain_pin_e brainPinParam) OutputPin* pinParam, brain_pin_e brainPinParam)
{ {
startDelayMs = startdelay; startDelayMs = startdelay;
onTime = ontime; onTimeMs = p_ontimeMs;
offTime = offtime; offTimeMs = p_offtimeMs;
count = iterations; count = iterations;
pinX = pinParam; pinX = pinParam;
brainPin = brainPinParam; brainPin = brainPinParam;
@ -140,12 +140,12 @@ static void pinbench(float startdelay, float ontime, float offtime, int iteratio
/*==========================================================================*/ /*==========================================================================*/
static void doRunFuelInjBench(size_t humanIndex, float delay, float onTime, float offTime, int count) { static void doRunFuelInjBench(size_t humanIndex, float delay, float onTimeMs, float offTimeMs, int count) {
if (humanIndex < 1 || humanIndex > engineConfiguration->specs.cylindersCount) { if (humanIndex < 1 || humanIndex > engineConfiguration->specs.cylindersCount) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTime, offTime, count, pinbench(delay, onTimeMs, offTimeMs, count,
&enginePins.injectors[humanIndex - 1], engineConfiguration->injectionPins[humanIndex - 1]); &enginePins.injectors[humanIndex - 1], engineConfiguration->injectionPins[humanIndex - 1]);
} }
@ -167,12 +167,12 @@ static void doRunSolenoidBench(size_t humanIndex, float delay, float onTime, flo
&enginePins.tcuSolenoids[humanIndex - 1], engineConfiguration->tcu_solenoid[humanIndex - 1]); &enginePins.tcuSolenoids[humanIndex - 1], engineConfiguration->tcu_solenoid[humanIndex - 1]);
} }
static void doRunBenchTestLuaOutput(size_t humanIndex, float delay, float onTime, float offTime, int count) { static void doRunBenchTestLuaOutput(size_t humanIndex, float delay, float onTimeMs, float offTimeMs, int count) {
if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) { if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
efiPrintf("Invalid index: %d", humanIndex); efiPrintf("Invalid index: %d", humanIndex);
return; return;
} }
pinbench(delay, onTime, offTime, count, pinbench(delay, onTimeMs, offTimeMs, count,
&enginePins.luaOutputPins[humanIndex - 1], engineConfiguration->luaOutputPins[humanIndex - 1]); &enginePins.luaOutputPins[humanIndex - 1], engineConfiguration->luaOutputPins[humanIndex - 1]);
} }
@ -180,50 +180,50 @@ static void doRunBenchTestLuaOutput(size_t humanIndex, float delay, float onTime
* delay 100, cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times * delay 100, cylinder #2, 5ms ON, 1000ms OFF, repeat 3 times
* fuelInjBenchExt 100 2 5 1000 3 * fuelInjBenchExt 100 2 5 1000 3
*/ */
static void fuelInjBenchExt(float delay, float humanIndex, float onTime, float offTime, float count) { static void fuelInjBenchExt(float delay, float humanIndex, float onTimeMs, float offTimeMs, float count) {
doRunFuelInjBench((int)humanIndex, delay, onTime, offTime, (int)count); doRunFuelInjBench((int)humanIndex, delay, onTimeMs, offTimeMs, (int)count);
} }
/** /**
* fuelbench 5 1000 2 * fuelbench 5 1000 2
*/ */
static void fuelInjBench(float onTime, float offTime, float count) { static void fuelInjBench(float onTimeMs, float offTimeMs, float count) {
fuelInjBenchExt(0.0, 1, onTime, offTime, count); fuelInjBenchExt(0.0, 1, onTimeMs, offTimeMs, count);
} }
/** /**
* sparkbench2 0 1 5 1000 2 * sparkbench2 0 1 5 1000 2
*/ */
static void sparkBenchExt(float delay, float humanIndex, float onTime, float offTime, float count) { static void sparkBenchExt(float delay, float humanIndex, float onTime, float offTimeMs, float count) {
doRunSparkBench((int)humanIndex, delay, onTime, offTime, (int)count); doRunSparkBench((int)humanIndex, delay, onTime, offTimeMs, (int)count);
} }
/** /**
* sparkbench 5 400 2 * sparkbench 5 400 2
* 5 ms ON, 400 ms OFF, two times * 5 ms ON, 400 ms OFF, two times
*/ */
static void sparkBench(float onTime, float offTime, float count) { static void sparkBench(float onTime, float offTimeMs, float count) {
sparkBenchExt(0.0, 1, onTime, offTime, count); sparkBenchExt(0.0, 1, onTime, offTimeMs, count);
} }
/** /**
* delay 100, solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times * delay 100, solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times
* tcusolbench 100 2 1000 1000 3 * tcusolbench 100 2 1000 1000 3
*/ */
static void tcuSolenoidBench(float delay, float humanIndex, float onTime, float offTime, float count) { static void tcuSolenoidBench(float delay, float humanIndex, float onTime, float offTimeMs, float count) {
doRunSolenoidBench((int)humanIndex, delay, onTime, offTime, (int)count); doRunSolenoidBench((int)humanIndex, delay, onTime, offTimeMs, (int)count);
} }
/** /**
* delay 100, channel #1, 5ms ON, 1000ms OFF, repeat 3 times * delay 100, channel #1, 5ms ON, 1000ms OFF, repeat 3 times
* fsiobench2 100 1 5 1000 3 * fsiobench2 100 1 5 1000 3
*/ */
static void luaOutBench2(float delay, float humanIndex, float onTime, float offTime, float count) { static void luaOutBench2(float delay, float humanIndex, float onTime, float offTimeMs, float count) {
doRunBenchTestLuaOutput((int)humanIndex, delay, onTime, offTime, (int)count); doRunBenchTestLuaOutput((int)humanIndex, delay, onTime, offTimeMs, (int)count);
} }
static void fanBenchExt(float onTime) { static void fanBenchExt(float onTimeMs) {
pinbench(0.0, onTime, 100.0, 1.0, pinbench(0.0, onTimeMs, 100.0, 1.0,
&enginePins.fanRelay, engineConfiguration->fanPin); &enginePins.fanRelay, engineConfiguration->fanPin);
} }
@ -286,7 +286,7 @@ private:
// naive inter-thread communication - waiting for a flag // naive inter-thread communication - waiting for a flag
if (isBenchTestPending) { if (isBenchTestPending) {
isBenchTestPending = false; isBenchTestPending = false;
runBench(brainPin, pinX, startDelayMs, onTime, offTime, count); runBench(brainPin, pinX, startDelayMs, onTimeMs, offTimeMs, count);
} }
if (widebandUpdatePending) { if (widebandUpdatePending) {