From 9377a01aec508d5b1c137167b7b029c33f8c08c5 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 7 Jul 2021 05:31:05 -0700 Subject: [PATCH] store cylinder count as plain number (#2915) * update test framework * eh * hey look it's fewer warnings * unwind * fix * config * configs * logic * even java had some * no need to be a typedef * paste in actual cylinder count --- firmware/controllers/algo/rusefi_types.h | 2 -- firmware/controllers/bench_test.cpp | 4 ++-- firmware/controllers/engine_cycle/fuel_schedule.cpp | 4 ++-- firmware/controllers/math/engine_math.cpp | 4 ++-- firmware/integration/rusefi_config.txt | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index 0092390365..10a9f1e566 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -119,8 +119,6 @@ typedef uint8_t gppwm_table_t[GPPWM_LOAD_COUNT][GPPWM_RPM_COUNT]; // this is different type simply to have different hi/low range in rusefi.ini typedef ignition_table_t angle_table_t; -typedef uint32_t cylinders_count_t; - typedef int16_t fsio_pwm_freq_t; typedef float fsio_setting_t; diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index f6a083d122..7e819fb56c 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -134,7 +134,7 @@ static void pinbench(const char *delayStr, const char *onTimeStr, const char *of isBenchTestPending = true; // let's signal bench thread to wake up } -static void doRunFuel(cylinders_count_t humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr, +static void doRunFuel(size_t humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr, const char *countStr) { if (humanIndex < 1 || humanIndex > engineConfiguration->specs.cylindersCount) { efiPrintf("Invalid index: %d", humanIndex); @@ -243,7 +243,7 @@ static void fuelbench(const char * onTimeStr, const char *offTimeStr, const char fuelbench2("0", "1", onTimeStr, offTimeStr, countStr); } -static void doRunSpark(cylinders_count_t humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr, +static void doRunSpark(size_t humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr, const char *countStr) { if (humanIndex < 1 || humanIndex > engineConfiguration->specs.cylindersCount) { efiPrintf("Invalid index: %d", humanIndex); diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index 0c0ced811b..d155d55b47 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -133,7 +133,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF } void FuelSchedule::addFuelEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - for (cylinders_count_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) { + for (size_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) { InjectionEvent *ev = &elements[cylinderIndex]; ev->ownIndex = cylinderIndex; // todo: is this assignment needed here? we now initialize in constructor bool result = addFuelEventsForCylinder(cylinderIndex PASS_ENGINE_PARAMETER_SUFFIX); @@ -153,7 +153,7 @@ void FuelSchedule::onTriggerTooth(size_t toothIndex, int rpm, efitick_t nowNt DE return; } - for (cylinders_count_t i = 0; i < CONFIG(specs.cylindersCount); i++) { + for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) { elements[i].onTriggerTooth(toothIndex, rpm, nowNt); } } diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 48b94f00ab..812843c692 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -369,7 +369,7 @@ static int getIgnitionPinForIndex(int cylinderIndex DECLARE_ENGINE_PARAMETER_SUF void prepareIgnitionPinIndices(ignition_mode_e ignitionMode DECLARE_ENGINE_PARAMETER_SUFFIX) { (void)ignitionMode; #if EFI_ENGINE_CONTROL - for (cylinders_count_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) { + for (size_t cylinderIndex = 0; cylinderIndex < CONFIG(specs.cylindersCount); cylinderIndex++) { ENGINE(ignitionPin[cylinderIndex]) = getIgnitionPinForIndex(cylinderIndex PASS_ENGINE_PARAMETER_SUFFIX); } #endif /* EFI_ENGINE_CONTROL */ @@ -413,7 +413,7 @@ void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } #endif /* EFI_UNIT_TEST */ - for (cylinders_count_t i = 0; i < CONFIG(specs.cylindersCount); i++) { + for (size_t i = 0; i < CONFIG(specs.cylindersCount); i++) { ENGINE(ignitionPositionWithinEngineCycle[i]) = ENGINE(engineCycle) * i / CONFIG(specs.cylindersCount); } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index b7319f3c35..97b35bea67 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -592,8 +592,7 @@ float[DWELL_CURVE_SIZE] sparkDwellRpmBins;On Single Coil or Wasted Spark setups struct_no_prefix specs_s float displacement;Engine displacement, in litres\nsee also cylindersCount;"L", 1, 0, 0, 1000, 2 -custom cylinders_count_t 4 bits, U32, @OFFSET@, [0:3], "INVALID", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, "INVALID", "INVALID", "INVALID" -cylinders_count_t cylindersCount; +uint32_t cylindersCount;;"", 1, 0, 1, @@MAX_CYLINDER_COUNT@@, 0 ! see firing_order.h ! FO_1 = 0