2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file table_helper.cpp
|
|
|
|
* @brief Helper methods related to 3D & 2D tables manipulation (maps and curves)
|
|
|
|
*
|
|
|
|
* @date Jul 6, 2014
|
2017-01-03 03:05:22 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "table_helper.h"
|
|
|
|
#include "efilib.h"
|
|
|
|
#include "interpolation.h"
|
|
|
|
|
2018-01-07 08:17:49 -08:00
|
|
|
void setLinearCurve(float array[], int size, float from, float to, float precision) {
|
2015-07-10 06:01:56 -07:00
|
|
|
for (int i = 0; i < size; i++) {
|
2016-08-26 15:02:39 -07:00
|
|
|
float value = interpolateMsg("setTable", 0, from, size - 1, to, i);
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* rounded values look nicer, also we want to avoid precision mismatch with Tuner Studio
|
|
|
|
*/
|
|
|
|
array[i] = efiRound(value, precision);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-21 19:01:31 -08:00
|
|
|
void setRpmBin(float array[], int size, float idleRpm, float topRpm) {
|
|
|
|
array[0] = idleRpm - 150;
|
2016-07-06 20:02:59 -07:00
|
|
|
int rpmStep = (int)(efiRound((topRpm - idleRpm) / (size - 2), 50) - 150);
|
2016-01-21 19:01:31 -08:00
|
|
|
for (int i = 1; i < size - 1;i++)
|
|
|
|
array[i] = idleRpm + rpmStep * (i - 1);
|
|
|
|
array[size - 1] = topRpm;
|
|
|
|
}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
void setTableBin(float array[], int size, float from, float to) {
|
2018-01-07 08:17:49 -08:00
|
|
|
setLinearCurve(array, size, from, to, 0.01);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2017-06-11 11:59:03 -07:00
|
|
|
/**
|
|
|
|
* initialize RPM table axis using default RPM range
|
|
|
|
*/
|
2015-07-10 06:01:56 -07:00
|
|
|
void setRpmTableBin(float array[], int size) {
|
2016-01-21 19:01:31 -08:00
|
|
|
setRpmBin(array, size, 800, 7000);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|