diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index d90ef6af6b..fde70aa38d 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -152,7 +152,7 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { setWholeTimingTable(10 PASS_ENGINE_PARAMETER); // set_whole_fuel_map 5 setWholeFuelMap(5 PASS_ENGINE_PARAMETER); - setMap(config->afrTable, 13.5); + setAfrMap(config->afrTable, 13.5); setSingleCoilDwell(engineConfiguration); engineConfiguration->ignitionMode = IM_ONE_COIL; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 5cb8bc75a8..2e9b0b5e9d 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -131,6 +131,14 @@ void setConstantDwell(floatms_t dwellMs DECLARE_ENGINE_PARAMETER_S) { } } +void setAfrMap(afr_table_t table, float value) { + for (int l = 0; l < FUEL_LOAD_COUNT; l++) { + for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) { + table[l][rpmIndex] = value; + } + } +} + void setMap(fuel_table_t table, float value) { for (int l = 0; l < FUEL_LOAD_COUNT; l++) { for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) { @@ -367,7 +375,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { // set_whole_timing_map 3 setWholeFuelMap(3 PASS_ENGINE_PARAMETER); - setMap(config->afrTable, 14.7); + setAfrMap(config->afrTable, 14.7); setDefaultVETable(PASS_ENGINE_PARAMETER_F); diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index 91d00c6673..e7c8855019 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -20,8 +20,8 @@ #include "fsio_core.h" #include "fsio_impl.h" -extern fsio8_Map3D_t fsioTable1; -extern fsio8_Map3D_t fsioTable2; +extern fsio8_Map3D_f32t fsioTable1; +extern fsio8_Map3D_f32t fsioTable2; LENameOrdinalPair * LE_FIRST = NULL; @@ -265,9 +265,15 @@ bool LECalculator::processElement(Engine *engine, LEElement *element) { if (index < 1 || index > 2) { push(element->action, NAN); } else { - fsio8_Map3D_t *t = index == 1 ? &fsioTable1 : &fsioTable2; + if (index == 1) { + fsio8_Map3D_f32t *t = &fsioTable1; - push(element->action, t->getValue(xValue, yValue)); + push(element->action, t->getValue(xValue, yValue)); + } else { + fsio8_Map3D_f32t *t = &fsioTable2; + + push(element->action, t->getValue(xValue, yValue)); + } } } break; diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index 306651654b..9bc52316df 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -17,8 +17,8 @@ #define NO_PWM 0 -fsio8_Map3D_t fsioTable1("fsio#1"); -fsio8_Map3D_t fsioTable2("fsio#2"); +fsio8_Map3D_f32t fsioTable1("fsio#1"); +fsio8_Map3D_f32t fsioTable2("fsio#2"); /** diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index 8bd1dcaf29..2eff700a7e 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -13,7 +13,8 @@ #include "engine.h" #include "table_helper.h" -typedef Map3D fsio8_Map3D_t; +typedef Map3D fsio8_Map3D_f32t; +typedef Map3D fsio8_Map3D_u8t; /** * In human language that's diff --git a/firmware/controllers/core/interpolation.cpp b/firmware/controllers/core/interpolation.cpp index 9f9950a09f..af5754fa23 100644 --- a/firmware/controllers/core/interpolation.cpp +++ b/firmware/controllers/core/interpolation.cpp @@ -17,8 +17,10 @@ #include "efilib2.h" #include "interpolation.h" +bool needInterpolationLoggingValue = true; + int needInterpolationLogging(void) { - return true; + return needInterpolationLoggingValue; } #define BINARY_PERF true diff --git a/firmware/controllers/core/interpolation.h b/firmware/controllers/core/interpolation.h index 7d42879d44..f667165f42 100644 --- a/firmware/controllers/core/interpolation.h +++ b/firmware/controllers/core/interpolation.h @@ -12,6 +12,7 @@ #include "datalogging.h" #include "efilib.h" #include "obd_error_codes.h" +#include "error_handling.h" #define INTERPOLATION_A(x1, y1, x2, y2) ((y1 - y2) / (x1 - x2)) diff --git a/firmware/controllers/core/table_helper.h b/firmware/controllers/core/table_helper.h index 5f8db6580e..c1e1d0359f 100644 --- a/firmware/controllers/core/table_helper.h +++ b/firmware/controllers/core/table_helper.h @@ -112,6 +112,7 @@ void Map3D::setAll(vType value) { } } +typedef Map3D afr_Map3D_t; typedef Map3D ign_Map3D_t; typedef Map3D fuel_Map3D_t; typedef Map3D baroCorr_Map3D_t; diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 6d377e941a..51e72de15b 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -24,7 +24,7 @@ fuel_Map3D_t veMap("VE"); fuel_Map3D_t ve2Map("VE2"); -fuel_Map3D_t afrMap("AFR"); +afr_Map3D_t afrMap("AFR"); baroCorr_Map3D_t baroCorrMap("baro"); #define tpMin 0 diff --git a/unit_tests/map_resize.cpp b/unit_tests/map_resize.cpp index aa85aa78e5..fbaf8fc2b6 100644 --- a/unit_tests/map_resize.cpp +++ b/unit_tests/map_resize.cpp @@ -97,7 +97,7 @@ static float newKeyBin[newKeySize]; //EngineConfiguration *engineConfiguration; -extern int needInterpolationLogging; +extern bool needInterpolationLoggingValue; void resizeMap(void) { // float keyMin = 1.2; @@ -124,7 +124,7 @@ void resizeMap(void) { // engineConfiguration->fuelRpmBins, // FUEL_RPM_COUNT, fuel_ptrs)); - needInterpolationLogging = 0; + needInterpolationLoggingValue = 0; // printf("static float ad_maf_table[AD_LOAD_COUNT] = {"); // for (int i = 0; i < newKeySize; i++) {