Parcourir la source

make analog2tempBed return a precise celsius reading for BED_USES_THERMISTOR, complementing changes to analog2temp in d15f01e

haxar il y a 13 ans
Parent
révision
79a466ca26
1 fichiers modifiés avec 4 ajouts et 6 suppressions
  1. 4
    6
      Marlin/temperature.cpp

+ 4
- 6
Marlin/temperature.cpp Voir le fichier

@@ -397,7 +397,7 @@ float analog2temp(int raw, uint8_t e) {
397 397
 // For bed temperature measurement.
398 398
 float analog2tempBed(int raw) {
399 399
   #ifdef BED_USES_THERMISTOR
400
-    int celsius = 0;
400
+    float celsius = 0;
401 401
     byte i;
402 402
 
403 403
     raw = (1023 * OVERSAMPLENR) - raw;
@@ -408,9 +408,8 @@ float analog2tempBed(int raw) {
408 408
       {
409 409
         celsius  = PGM_RD_W(bedtemptable[i-1][1]) + 
410 410
           (raw - PGM_RD_W(bedtemptable[i-1][0])) * 
411
-          (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
412
-          (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
413
-
411
+          (float)(PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
412
+          (float)(PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
414 413
         break;
415 414
       }
416 415
     }
@@ -419,13 +418,12 @@ float analog2tempBed(int raw) {
419 418
     if (i == bedtemptable_len) celsius = PGM_RD_W(bedtemptable[i-1][1]);
420 419
 
421 420
     return celsius;
422
-    
423 421
   #elif defined BED_USES_AD595
424 422
     return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
425 423
   #else
426 424
     #warning No heater-type defined for the bed.
425
+    return 0;
427 426
   #endif
428
-  return 0;
429 427
 }
430 428
 
431 429
 void tp_init()

Chargement…
Annuler
Enregistrer