1
0
forked from me/IronOS

Fix utils length calc

This commit is contained in:
Ben V. Brown
2021-04-28 21:05:49 +10:00
parent 33278e672d
commit b06c58bb81
3 changed files with 6 additions and 5 deletions

View File

@@ -216,8 +216,10 @@ const uint16_t uVtoDegC[] = {
38137, 500, //
};
#endif
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
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)); }

View File

@@ -8,9 +8,8 @@
#include <Utils.h>
int32_t Utils::InterpolateLookupTable(const uint16_t *lookupTable,
const uint16_t value) {
const int noItems, const uint16_t value) {
if (value) {
int noItems = sizeof(lookupTable) / (2 * sizeof(uint16_t));
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 (value < lookupTable[i * 2]) {

View File

@@ -11,9 +11,9 @@
class Utils {
public:
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,
int32_t y2, int32_t x) ;
int32_t y2, int32_t x);
};