@@ -283,31 +283,31 @@ float ThermocoupleK:: tempReadtoCelsius(const int16_t rawADC) {
283283 // Búsqueda lineal en la tabla (de menor a mayor valor ADC)
284284 for (uint16_t i = 0 ; i < TEMP_TABLE_SIZE - 1 ; i++) {
285285
286- int16_t adc1 = pgm_read_word (&table_thermocouple_k[i].adc );
287- int16_t adc2 = pgm_read_word (&table_thermocouple_k[i + 1 ].adc );
288- // Serial.print(i); Serial.print(" "); Serial.print(adc1); Serial.print(" "); Serial.print(adc2);
289-
290- if (rawADC >= adc1 && rawADC < adc2) { // in-between tableValue and nextValue
291- // Approximate temperature via linear interpolation
292- // float frac = float(rawADC - adc2) / float(adc1 - adc2);
293- int16_t t1 = pgm_read_word (&table_thermocouple_k[i].temp );
294- int16_t t2 = pgm_read_word (&table_thermocouple_k[i+1 ].temp );
295- // Serial.print(" "); Serial.print(t1); Serial.print(" "); Serial.print(t2);
296- float tempC = t1 + (float ) (rawADC - adc1) * (float (t2 - t1) / float (adc2 - adc1)); // TEMP_TABLE_OFFSET + i + frac;
297- return tempC;
298- }
299- // Serial.println("");
286+ int16_t adc1 = pgm_read_word (&table_thermocouple_k[i].adc );
287+ int16_t adc2 = pgm_read_word (&table_thermocouple_k[i + 1 ].adc );
288+ // Serial.print(i); Serial.print(" "); Serial.print(adc1); Serial.print(" "); Serial.print(adc2);
289+
290+ if (rawADC >= adc1 && rawADC < adc2) { // in-between tableValue and nextValue
291+ // Approximate temperature via linear interpolation
292+ // float frac = float(rawADC - adc2) / float(adc1 - adc2);
293+ int16_t t1 = pgm_read_word (&table_thermocouple_k[i].temp );
294+ int16_t t2 = pgm_read_word (&table_thermocouple_k[i+1 ].temp );
295+ // Serial.print(" "); Serial.print(t1); Serial.print(" "); Serial.print(t2);
296+ float tempC = t1 + (float ) (rawADC - adc1) * (float (t2 - t1) / float (adc2 - adc1)); // TEMP_TABLE_OFFSET + i + frac;
297+ return tempC;
298+ }
299+ // Serial.println("");
300300 }
301301
302302 return TEMP_MIN_TEMP;
303303}
304304
305305float ThermocoupleK:: calcTempCelsius() {
306- _Tcold = ads1118.convertInternalTemp (_raw_cold);
307- _Thot = tempReadtoCelsius (_raw_hot);
308- // SERIAL_ECHOPGM("ADS1118 TCold "); SERIAL_ECHOLN(_Tcold);
309- // SERIAL_ECHOPGM("ADS1118 THot "); SERIAL_ECHOLN(_Thot);
310- return _Thot + _Tcold;
306+ _Tcold = ads1118.convertInternalTemp (_raw_cold);
307+ _Thot = tempReadtoCelsius (_raw_hot);
308+ // SERIAL_ECHOPGM("ADS1118 TCold "); SERIAL_ECHOLN(_Tcold);
309+ // SERIAL_ECHOPGM("ADS1118 THot "); SERIAL_ECHOLN(_Thot);
310+ return _Thot + _Tcold;
311311}
312312
313313void ThermocoupleK::setRawCold (const int16_t raw_cold) {
0 commit comments