fix thermistor lookup table interpolation code
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
This commit is contained in:
parent
f1b526696b
commit
fa91ef8472
2
temp.c
2
temp.c
|
|
@ -192,7 +192,7 @@ void temp_sensor_tick() {
|
||||||
for (j = 1; j < NUMTEMPS; j++) {
|
for (j = 1; j < NUMTEMPS; j++) {
|
||||||
if (pgm_read_word(&(temptable[j][0])) > temp) {
|
if (pgm_read_word(&(temptable[j][0])) > temp) {
|
||||||
// multiply by 4 because internal temp is stored as 14.2 fixed point
|
// multiply by 4 because internal temp is stored as 14.2 fixed point
|
||||||
temp = pgm_read_word(&(temptable[j][1])) * 4 + (pgm_read_word(&(temptable[j][0])) - temp) * 4 * (pgm_read_word(&(temptable[j-1][1])) - pgm_read_word(&(temptable[j][1]))) / (pgm_read_word(&(temptable[j][0])) - pgm_read_word(&(temptable[j-1][0])));
|
temp = pgm_read_word(&(temptable[j][1])) * 4 + (temp - pgm_read_word(&(temptable[j-1][0]))) * 4 * (pgm_read_word(&(temptable[j][1])) - pgm_read_word(&(temptable[j-1][1]))) / (pgm_read_word(&(temptable[j][0])) - pgm_read_word(&(temptable[j-1][0])));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue