16 #include <type_traits>
18 #ifndef DEBUG_INTERPOLATION
19 #define DEBUG_INTERPOLATION FALSE
22 #define INTERPOLATION_A(x1, y1, x2, y2) ((y1 - y2) / (x1 - x2))
26 float interpolateMsg(
const char *msg,
float x1,
float y1,
float x2,
float y2,
float x);
31 template<
typename TValue,
int TSize>
33 for (
size_t i = 0; i < TSize - 1; i++) {
34 float cur = values[i];
35 float next = values[i + 1];
42 template<
typename TValue,
int TSize>
56 template<
typename kType>
58 float fvalue = (float)value;
59 if (std::isnan(fvalue)) {
82 middle = (left + right) / 2;
89 if (middle != 0 && array[middle - 1] > array[middle]) {
98 if (value < array[middle]) {
100 }
else if (value > array[middle]) {
114 template<
typename VType,
typename kType>
119 values[index] = value;
Buffered console output stream header.
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x)
Linear interpolation by two points.
float interpolateClampedWithValidation(float x1, float y1, float x2, float y2, float x)
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
int findIndexMsg(const char *msg, const kType array[], int size, kType value)
Binary search.
void ensureArrayIsAscendingOrDefault(const char *msg, const TValue(&values)[TSize])
void setCurveValue(const kType bins[], VType values[], int size, float key, float value)
void ensureArrayIsAscending(const char *msg, const TValue(&values)[TSize])
bool warning(ObdCode code, const char *fmt,...)
void firmwareError(ObdCode code, const char *fmt,...)
Standard and custom OBD-II error codes.
@ CUSTOM_ERR_OUT_OF_ORDER