瀏覽代碼

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

haxar 13 年之前
父節點
當前提交
79a466ca26
共有 1 個文件被更改,包括 4 次插入6 次删除
  1. 4
    6
      Marlin/temperature.cpp

+ 4
- 6
Marlin/temperature.cpp 查看文件

@@ -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()

Loading…
取消
儲存