fix thermistor lookup table interpolation code

Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
This commit is contained in:
Vik Olliver 2011-02-02 18:23:10 +11:00 committed by Michael Moon
parent f1b526696b
commit fa91ef8472
1 changed files with 1 additions and 1 deletions

2
temp.c
View File

@ -192,7 +192,7 @@ void temp_sensor_tick() {
for (j = 1; j < NUMTEMPS; j++) {
if (pgm_read_word(&(temptable[j][0])) > temp) {
// 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;
}
}