Fix utils length calc
This commit is contained in:
@@ -216,8 +216,10 @@ const uint16_t uVtoDegC[] = {
|
|||||||
38137, 500, //
|
38137, 500, //
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
|
||||||
|
|
||||||
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
||||||
return Utils::InterpolateLookupTable(uVtoDegC,tipuVDelta);
|
return Utils::InterpolateLookupTable(uVtoDegC,uVtoDegCItems,tipuVDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
|
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
#include <Utils.h>
|
#include <Utils.h>
|
||||||
|
|
||||||
int32_t Utils::InterpolateLookupTable(const uint16_t *lookupTable,
|
int32_t Utils::InterpolateLookupTable(const uint16_t *lookupTable,
|
||||||
const uint16_t value) {
|
const int noItems, const uint16_t value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
int noItems = sizeof(lookupTable) / (2 * sizeof(uint16_t));
|
|
||||||
for (int i = 1; i < (noItems - 1); i++) {
|
for (int i = 1; i < (noItems - 1); i++) {
|
||||||
// If current tip temp is less than current lookup, then this current lookup is the higher point to interpolate
|
// If current tip temp is less than current lookup, then this current lookup is the higher point to interpolate
|
||||||
if (value < lookupTable[i * 2]) {
|
if (value < lookupTable[i * 2]) {
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
class Utils {
|
class Utils {
|
||||||
public:
|
public:
|
||||||
static int32_t InterpolateLookupTable(const uint16_t *lookupTable,
|
static int32_t InterpolateLookupTable(const uint16_t *lookupTable,
|
||||||
const uint16_t value);
|
const int noItems, const uint16_t value);
|
||||||
static int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2,
|
static int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2,
|
||||||
int32_t y2, int32_t x) ;
|
int32_t y2, int32_t x);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user