better error handling
This commit is contained in:
parent
f1b65ed4aa
commit
a0b0af5acc
|
@ -211,7 +211,7 @@ int findIndex(const float array[], int size, float value) {
|
|||
* @brief One-dimensional table lookup with linear interpolation
|
||||
*/
|
||||
float interpolate2d(float value, float bin[], float values[], int size) {
|
||||
int index = findIndex(bin, size, value);
|
||||
int index = findIndexMsg("value", bin, size, value);
|
||||
|
||||
if (index == -1)
|
||||
return values[0];
|
||||
|
@ -222,7 +222,7 @@ float interpolate2d(float value, float bin[], float values[], int size) {
|
|||
}
|
||||
|
||||
void setTableValue(float bins[], float values[], int size, float key, float value) {
|
||||
int index = findIndex(bins, size, key);
|
||||
int index = findIndexMsg("tbVl", bins, size, key);
|
||||
if (index == -1)
|
||||
index = 0;
|
||||
values[index] = value;
|
||||
|
|
|
@ -806,9 +806,9 @@ static void setTimingMap(const char * rpmStr, const char *loadStr, const char *v
|
|||
float engineLoad = atoff(loadStr);
|
||||
float value = atoff(valueStr);
|
||||
|
||||
int rpmIndex = findIndex(config->ignitionRpmBins, IGN_RPM_COUNT, rpm);
|
||||
int rpmIndex = findIndexMsg("setTM", config->ignitionRpmBins, IGN_RPM_COUNT, rpm);
|
||||
rpmIndex = rpmIndex < 0 ? 0 : rpmIndex;
|
||||
int loadIndex = findIndex(config->ignitionLoadBins, IGN_LOAD_COUNT, engineLoad);
|
||||
int loadIndex = findIndexMsg("setTM", config->ignitionLoadBins, IGN_LOAD_COUNT, engineLoad);
|
||||
loadIndex = loadIndex < 0 ? 0 : loadIndex;
|
||||
|
||||
config->ignitionTable[loadIndex][rpmIndex] = value;
|
||||
|
@ -820,9 +820,9 @@ static void setFuelMap(const char * rpmStr, const char *loadStr, const char *val
|
|||
float engineLoad = atoff(loadStr);
|
||||
float value = atoff(valueStr);
|
||||
|
||||
int rpmIndex = findIndex(config->fuelRpmBins, FUEL_RPM_COUNT, rpm);
|
||||
int rpmIndex = findIndexMsg("setFM", config->fuelRpmBins, FUEL_RPM_COUNT, rpm);
|
||||
rpmIndex = rpmIndex < 0 ? 0 : rpmIndex;
|
||||
int loadIndex = findIndex(config->fuelLoadBins, FUEL_LOAD_COUNT, engineLoad);
|
||||
int loadIndex = findIndexMsg("setTM", config->fuelLoadBins, FUEL_LOAD_COUNT, engineLoad);
|
||||
loadIndex = loadIndex < 0 ? 0 : loadIndex;
|
||||
|
||||
config->fuelTable[loadIndex][rpmIndex] = value;
|
||||
|
|
Loading…
Reference in New Issue