Kaynağa Gözat

Add typedef celsius_t (#21374)

Scott Lahteine 3 yıl önce
ebeveyn
işleme
e5ff55a1be
No account linked to committer's email address
35 değiştirilmiş dosya ile 252 ekleme ve 298 silme
  1. 6
    0
      Marlin/src/core/types.h
  2. 1
    1
      Marlin/src/feature/mmu/mmu2.cpp
  3. 2
    3
      Marlin/src/feature/pause.cpp
  4. 1
    1
      Marlin/src/feature/pause.h
  5. 4
    4
      Marlin/src/feature/powerloss.cpp
  6. 2
    2
      Marlin/src/feature/powerloss.h
  7. 2
    2
      Marlin/src/gcode/bedlevel/G26.cpp
  8. 5
    1
      Marlin/src/gcode/lcd/M145.cpp
  9. 28
    33
      Marlin/src/gcode/parser.h
  10. 3
    3
      Marlin/src/gcode/temp/M104_M109.cpp
  11. 3
    3
      Marlin/src/gcode/temp/M140_M190.cpp
  12. 5
    5
      Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
  13. 9
    10
      Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
  14. 11
    11
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  15. 16
    16
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  16. 14
    12
      Marlin/src/lcd/dwin/e3v2/dwin.cpp
  17. 2
    2
      Marlin/src/lcd/dwin/e3v2/dwin.h
  18. 5
    5
      Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp
  19. 3
    3
      Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp
  20. 5
    5
      Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp
  21. 3
    3
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
  22. 2
    2
      Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp
  23. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  24. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  25. 3
    3
      Marlin/src/lcd/marlinui.h
  26. 2
    2
      Marlin/src/lcd/menu/menu_configuration.cpp
  27. 3
    3
      Marlin/src/lcd/tft/ui_320x240.cpp
  28. 3
    3
      Marlin/src/lcd/tft/ui_480x320.cpp
  29. 3
    3
      Marlin/src/module/motion.cpp
  30. 7
    7
      Marlin/src/module/motion.h
  31. 4
    4
      Marlin/src/module/planner.cpp
  32. 2
    1
      Marlin/src/module/planner.h
  33. 43
    67
      Marlin/src/module/temperature.cpp
  34. 45
    73
      Marlin/src/module/temperature.h
  35. 1
    1
      Marlin/src/module/thermistor/thermistors.h

+ 6
- 0
Marlin/src/core/types.h Dosyayı Görüntüle

@@ -72,6 +72,12 @@ struct IF<true, L, R> { typedef L type; };
72 72
 //
73 73
 typedef float feedRate_t;
74 74
 
75
+//
76
+// celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14).
77
+// For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100
78
+//
79
+typedef int16_t celsius_t;
80
+
75 81
 // Conversion macros
76 82
 #define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
77 83
 #define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)

+ 1
- 1
Marlin/src/feature/mmu/mmu2.cpp Dosyayı Görüntüle

@@ -775,7 +775,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
775 775
   bool response = false;
776 776
   mmu_print_saved = false;
777 777
   xyz_pos_t resume_position;
778
-  int16_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder);
778
+  celsius_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder);
779 779
 
780 780
   KEEPALIVE_STATE(PAUSED_FOR_USER);
781 781
 

+ 2
- 3
Marlin/src/feature/pause.cpp Dosyayı Görüntüle

@@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
555 555
  * - Send host action for resume, if configured
556 556
  * - Resume the current SD print job, if any
557 557
  */
558
-void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, int16_t targetTemp/*=0*/ DXC_ARGS) {
558
+void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, const celsius_t targetTemp/*=0*/ DXC_ARGS) {
559 559
   DEBUG_SECTION(rp, "resume_print", true);
560 560
   DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " targetTemp:", targetTemp DXC_SAY);
561 561
 
@@ -577,9 +577,8 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
577 577
     thermalManager.reset_hotend_idle_timer(e);
578 578
   }
579 579
 
580
-  if (targetTemp > thermalManager.degTargetHotend(active_extruder)) {
580
+  if (targetTemp > thermalManager.degTargetHotend(active_extruder))
581 581
     thermalManager.setTargetHotend(targetTemp, active_extruder);
582
-  }
583 582
 
584 583
   // Load the new filament
585 584
   load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS);

+ 1
- 1
Marlin/src/feature/pause.h Dosyayı Görüntüle

@@ -90,7 +90,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
90 90
 void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS);
91 91
 
92 92
 void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH,
93
-                    const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS);
93
+                    const int8_t max_beep_count=0, const celsius_t targetTemp=0 DXC_PARAMS);
94 94
 
95 95
 bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0,
96 96
                     const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);

+ 4
- 4
Marlin/src/feature/powerloss.cpp Dosyayı Görüntüle

@@ -201,10 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
201 201
     #endif
202 202
 
203 203
     #if EXTRUDERS
204
-      HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target;
204
+      HOTEND_LOOP() info.target_temperature[e] = thermalManager.degTargetHotend(e);
205 205
     #endif
206 206
 
207
-    TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target);
207
+    TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.degTargetBed());
208 208
 
209 209
     #if HAS_FAN
210 210
       COPY(info.fan_speed, thermalManager.fan_speed);
@@ -343,7 +343,7 @@ void PrintJobRecovery::resume() {
343 343
   #endif
344 344
 
345 345
   #if HAS_HEATED_BED
346
-    const int16_t bt = info.target_temperature_bed;
346
+    const celsius_t bt = info.target_temperature_bed;
347 347
     if (bt) {
348 348
       // Restore the bed temperature
349 349
       sprintf_P(cmd, PSTR("M190 S%i"), bt);
@@ -354,7 +354,7 @@ void PrintJobRecovery::resume() {
354 354
   // Restore all hotend temperatures
355 355
   #if HAS_HOTEND
356 356
     HOTEND_LOOP() {
357
-      const int16_t et = info.target_temperature[e];
357
+      const celsius_t et = info.target_temperature[e];
358 358
       if (et) {
359 359
         #if HAS_MULTI_HOTEND
360 360
           sprintf_P(cmd, PSTR("T%i S"), e);

+ 2
- 2
Marlin/src/feature/powerloss.h Dosyayı Görüntüle

@@ -66,8 +66,8 @@ typedef struct {
66 66
     float filament_size[EXTRUDERS];
67 67
   #endif
68 68
 
69
-  TERN_(HAS_HOTEND,     int16_t target_temperature[HOTENDS]);
70
-  TERN_(HAS_HEATED_BED, int16_t target_temperature_bed);
69
+  TERN_(HAS_HOTEND,     celsius_t target_temperature[HOTENDS]);
70
+  TERN_(HAS_HEATED_BED, celsius_t target_temperature_bed);
71 71
   TERN_(HAS_FAN,        uint8_t fan_speed[FAN_COUNT]);
72 72
 
73 73
   TERN_(HAS_LEVELING, float fade);

+ 2
- 2
Marlin/src/gcode/bedlevel/G26.cpp Dosyayı Görüntüle

@@ -533,7 +533,7 @@ void GcodeSuite::G26() {
533 533
   #if HAS_HEATED_BED
534 534
 
535 535
     // Get a temperature from 'I' or 'B'
536
-    int16_t bedtemp = 0;
536
+    celsius_t bedtemp = 0;
537 537
 
538 538
     // Use the 'I' index if temperature presets are defined
539 539
     #if PREHEAT_COUNT
@@ -616,7 +616,7 @@ void GcodeSuite::G26() {
616 616
   g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size
617 617
 
618 618
   // Get a temperature from 'I' or 'H'
619
-  int16_t noztemp = 0;
619
+  celsius_t noztemp = 0;
620 620
 
621 621
   // Accept 'I' if temperature presets are defined
622 622
   #if PREHEAT_COUNT

+ 5
- 1
Marlin/src/gcode/lcd/M145.cpp Dosyayı Görüntüle

@@ -27,6 +27,10 @@
27 27
 #include "../gcode.h"
28 28
 #include "../../lcd/marlinui.h"
29 29
 
30
+#if HAS_HOTEND
31
+  #include "../../module/temperature.h"
32
+#endif
33
+
30 34
 /**
31 35
  * M145: Set the heatup state for a material in the LCD menu
32 36
  *
@@ -43,7 +47,7 @@ void GcodeSuite::M145() {
43 47
     preheat_t &mat = ui.material_preset[material];
44 48
     #if HAS_HOTEND
45 49
       if (parser.seenval('H'))
46
-        mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT));
50
+        mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0));
47 51
     #endif
48 52
     #if HAS_HEATED_BED
49 53
       if (parser.seenval('B'))

+ 28
- 33
Marlin/src/gcode/parser.h Dosyayı Görüntüle

@@ -352,50 +352,45 @@ public:
352 352
       static inline PGM_P temp_units_name() {
353 353
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
354 354
       }
355
-      static inline float to_temp_units(const float &f) {
355
+      static inline float to_temp_units(celsius_t c) {
356 356
         switch (input_temp_units) {
357
-          case TEMPUNIT_F:
358
-            return f * 0.5555555556f + 32;
359
-          case TEMPUNIT_K:
360
-            return f + 273.15f;
361
-          case TEMPUNIT_C:
362 357
           default:
363
-            return f;
358
+          case TEMPUNIT_C: return c;
359
+          case TEMPUNIT_K: return c + 273.15f;
360
+          case TEMPUNIT_F: return c * 0.5555555556f + 32;
364 361
         }
365 362
       }
366 363
 
367 364
     #endif // HAS_LCD_MENU && !DISABLE_M503
368 365
 
369
-    static inline float value_celsius() {
370
-      const float f = value_float();
366
+    static inline celsius_t value_celsius() {
367
+      float f = value_float();
371 368
       switch (input_temp_units) {
372
-        case TEMPUNIT_F:
373
-          return (f - 32) * 0.5555555556f;
374
-        case TEMPUNIT_K:
375
-          return f - 273.15f;
376
-        case TEMPUNIT_C:
377 369
         default:
378
-          return f;
370
+        case TEMPUNIT_C: break;
371
+        case TEMPUNIT_K: f -= 273.15f;
372
+        case TEMPUNIT_F: f = (f - 32) * 0.5555555556f;
379 373
       }
374
+      return LROUND(f + 0.5f);
380 375
     }
381 376
 
382
-    static inline float value_celsius_diff() {
377
+    static inline celsius_t value_celsius_diff() {
378
+      float f = value_float();
383 379
       switch (input_temp_units) {
384
-        case TEMPUNIT_F:
385
-          return value_float() * 0.5555555556f;
386
-        case TEMPUNIT_C:
387
-        case TEMPUNIT_K:
388 380
         default:
389
-          return value_float();
381
+        case TEMPUNIT_C:
382
+        case TEMPUNIT_K: break;
383
+        case TEMPUNIT_F: f *= 0.5555555556f;
390 384
       }
385
+      return LROUND(f + 0.5f);
391 386
     }
392 387
 
393 388
   #else // !TEMPERATURE_UNITS_SUPPORT
394 389
 
395 390
     static inline float to_temp_units(int16_t c) { return (float)c; }
396 391
 
397
-    static inline float value_celsius()      { return value_float(); }
398
-    static inline float value_celsius_diff() { return value_float(); }
392
+    static inline celsius_t value_celsius()      { return value_int(); }
393
+    static inline celsius_t value_celsius_diff() { return value_int(); }
399 394
 
400 395
   #endif // !TEMPERATURE_UNITS_SUPPORT
401 396
 
@@ -404,16 +399,16 @@ public:
404 399
   void unknown_command_warning();
405 400
 
406 401
   // Provide simple value accessors with default option
407
-  static inline char*    stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string()   : dval; }
408
-  static inline float    floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
409
-  static inline bool     boolval(const char c, const bool dval=false)   { return seenval(c) ? value_bool()         : (seen(c) ? true : dval); }
410
-  static inline uint8_t  byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
411
-  static inline int16_t  intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
412
-  static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
413
-  static inline int32_t  longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
414
-  static inline uint32_t ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
415
-  static inline float    linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
416
-  static inline float    celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
402
+  static inline char*     stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string()   : dval; }
403
+  static inline float     floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
404
+  static inline bool      boolval(const char c, const bool dval=false)   { return seenval(c) ? value_bool()         : (seen(c) ? true : dval); }
405
+  static inline uint8_t   byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
406
+  static inline int16_t   intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
407
+  static inline uint16_t  ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }
408
+  static inline int32_t   longval(const char c, const int32_t dval=0)    { return seenval(c) ? value_long()         : dval; }
409
+  static inline uint32_t  ulongval(const char c, const uint32_t dval=0)  { return seenval(c) ? value_ulong()        : dval; }
410
+  static inline float     linearval(const char c, const float dval=0)    { return seenval(c) ? value_linear_units() : dval; }
411
+  static inline celsius_t celsiusval(const char c, const float dval=0)   { return seenval(c) ? value_celsius()      : dval; }
417 412
 
418 413
   #if ENABLED(MARLIN_DEV_MODE)
419 414
 

+ 3
- 3
Marlin/src/gcode/temp/M104_M109.cpp Dosyayı Görüntüle

@@ -69,7 +69,7 @@ void GcodeSuite::M104() {
69 69
   #endif
70 70
 
71 71
   bool got_temp = false;
72
-  int16_t temp = 0;
72
+  celsius_t temp = 0;
73 73
 
74 74
   // Accept 'I' if temperature presets are defined
75 75
   #if PREHEAT_COUNT
@@ -145,7 +145,7 @@ void GcodeSuite::M109() {
145 145
   #endif
146 146
 
147 147
   bool got_temp = false;
148
-  int16_t temp = 0;
148
+  celsius_t temp = 0;
149 149
 
150 150
   // Accept 'I' if temperature presets are defined
151 151
   #if PREHEAT_COUNT
@@ -161,7 +161,7 @@ void GcodeSuite::M109() {
161 161
   if (!got_temp) {
162 162
     no_wait_for_cooling = parser.seenval('S');
163 163
     got_temp = no_wait_for_cooling || parser.seenval('R');
164
-    if (got_temp) temp = int16_t(parser.value_celsius());
164
+    if (got_temp) temp = parser.value_celsius();
165 165
   }
166 166
 
167 167
   if (got_temp) {

+ 3
- 3
Marlin/src/gcode/temp/M140_M190.cpp Dosyayı Görüntüle

@@ -44,7 +44,7 @@ void GcodeSuite::M140() {
44 44
   if (DEBUGGING(DRYRUN)) return;
45 45
 
46 46
   bool got_temp = false;
47
-  int16_t temp = 0;
47
+  celsius_t temp = 0;
48 48
 
49 49
   // Accept 'I' if temperature presets are defined
50 50
   #if PREHEAT_COUNT
@@ -94,7 +94,7 @@ void GcodeSuite::M190() {
94 94
   if (DEBUGGING(DRYRUN)) return;
95 95
 
96 96
   bool got_temp = false;
97
-  int16_t temp = 0;
97
+  celsius_t temp = 0;
98 98
 
99 99
   // Accept 'I' if temperature presets are defined
100 100
   #if PREHEAT_COUNT
@@ -110,7 +110,7 @@ void GcodeSuite::M190() {
110 110
   if (!got_temp) {
111 111
     no_wait_for_cooling = parser.seenval('S');
112 112
     got_temp = no_wait_for_cooling || parser.seenval('R');
113
-    if (got_temp) temp = int16_t(parser.value_celsius());
113
+    if (got_temp) temp = parser.value_celsius();
114 114
   }
115 115
 
116 116
   if (!got_temp) return;

+ 5
- 5
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Dosyayı Görüntüle

@@ -520,15 +520,15 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
520 520
 FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
521 521
   #if HAS_HEATED_BED
522 522
     const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
523
-    const float t1 = (isBed ? thermalManager.degBed()       : thermalManager.degHotend(heater_id)),
524
-                t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
523
+    const celsius_t t1 = (isBed ? thermalManager.degBed()       : thermalManager.degHotend(heater_id)),
524
+                    t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
525 525
   #else
526
-    const float t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
526
+    const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
527 527
   #endif
528 528
 
529 529
   if (prefix >= 0) lcd_put_wchar(prefix);
530 530
 
531
-  lcd_put_u8str(i16tostr3rj(t1 + 0.5));
531
+  lcd_put_u8str(i16tostr3rj(t1));
532 532
   lcd_put_wchar('/');
533 533
 
534 534
   #if !HEATER_IDLE_HANDLER
@@ -541,7 +541,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
541 541
     }
542 542
     else
543 543
   #endif
544
-      lcd_put_u8str(i16tostr3left(t2 + 0.5));
544
+      lcd_put_u8str(i16tostr3left(t2));
545 545
 
546 546
   if (prefix >= 0) {
547 547
     lcd_put_wchar(LCD_STR_DEGREE[0]);

+ 9
- 10
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp Dosyayı Görüntüle

@@ -434,33 +434,32 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
434 434
   uint8_t pic_hot_bits;
435 435
   #if HAS_HEATED_BED
436 436
     const bool isBed = heater_id < 0;
437
-    const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id));
438
-    const float t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
437
+    const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)),
438
+                    t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
439 439
   #else
440
-    const float t1 = thermalManager.degHotend(heater_id);
441
-    const float t2 = thermalManager.degTargetHotend(heater_id);
440
+    const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
442 441
   #endif
443 442
 
444 443
   #if HOTENDS < 2
445 444
     if (heater_id == H_E0) {
446 445
       lcd.setCursor(2, 5);  lcd.print(prefix); //HE
447
-      lcd.setCursor(1, 6);  lcd.print(i16tostr3rj(t1 + 0.5));
446
+      lcd.setCursor(1, 6);  lcd.print(i16tostr3rj(t1));
448 447
       lcd.setCursor(1, 7);
449 448
     }
450 449
     else {
451 450
       lcd.setCursor(6, 5);  lcd.print(prefix); //BED
452
-      lcd.setCursor(6, 6);  lcd.print(i16tostr3rj(t1 + 0.5));
451
+      lcd.setCursor(6, 6);  lcd.print(i16tostr3rj(t1));
453 452
       lcd.setCursor(6, 7);
454 453
     }
455 454
   #else
456 455
     if (heater_id > H_BED) {
457
-      lcd.setCursor(heater_id * 4, 5);  lcd.print(prefix); //HE1 or HE2 or HE3
458
-      lcd.setCursor(heater_id * 4, 6);  lcd.print(i16tostr3rj(t1 + 0.5));
456
+      lcd.setCursor(heater_id * 4, 5);  lcd.print(prefix); // HE1 or HE2 or HE3
457
+      lcd.setCursor(heater_id * 4, 6);  lcd.print(i16tostr3rj(t1));
459 458
       lcd.setCursor(heater_id * 4, 7);
460 459
     }
461 460
     else {
462 461
       lcd.setCursor(13, 5);  lcd.print(prefix); //BED
463
-      lcd.setCursor(13, 6);  lcd.print(i16tostr3rj(t1 + 0.5));
462
+      lcd.setCursor(13, 6);  lcd.print(i16tostr3rj(t1));
464 463
       lcd.setCursor(13, 7);
465 464
     }
466 465
   #endif // HOTENDS <= 1
@@ -475,7 +474,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
475 474
     }
476 475
     else
477 476
   #endif // !HEATER_IDLE_HANDLER
478
-      lcd.print(i16tostr3rj(t2 + 0.5));
477
+      lcd.print(i16tostr3rj(t2));
479 478
 
480 479
   switch (heater_id) {
481 480
     case H_BED: pic_hot_bits = ICON_BED;   break;

+ 11
- 11
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Dosyayı Görüntüle

@@ -187,7 +187,7 @@
187 187
 #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
188 188
 #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
189 189
 
190
-FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
190
+FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
191 191
   const char *str = i16tostr3rj(temp);
192 192
   const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
193 193
   lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
@@ -206,8 +206,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
206 206
 
207 207
     const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id);
208 208
 
209
-    const float temp = thermalManager.degHotend(heater_id),
210
-              target = thermalManager.degTargetHotend(heater_id);
209
+    const celsius_t temp = thermalManager.degHotend(heater_id),
210
+                  target = thermalManager.degTargetHotend(heater_id);
211 211
 
212 212
     #if DISABLED(STATUS_HOTEND_ANIM)
213 213
       #define STATIC_HOTEND true
@@ -277,11 +277,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
277 277
       #else
278 278
         constexpr bool dodraw = true;
279 279
       #endif
280
-      if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
280
+      if (dodraw) _draw_centered_temp(target, tx, 7);
281 281
     }
282 282
 
283 283
     if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
284
-      _draw_centered_temp(temp + 0.5f, tx, 28);
284
+      _draw_centered_temp(temp, tx, 28);
285 285
 
286 286
     if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) {
287 287
       u8g.setColorIndex(0); // set to white on black
@@ -303,8 +303,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
303 303
 
304 304
     const uint8_t tx = STATUS_BED_TEXT_X;
305 305
 
306
-    const float temp = thermalManager.degBed(),
307
-              target = thermalManager.degTargetBed();
306
+    const celsius_t temp = thermalManager.degBed(),
307
+                  target = thermalManager.degTargetBed();
308 308
 
309 309
     #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM)
310 310
       const bool isHeat = BED_ALT();
@@ -350,11 +350,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
350 350
       #else
351 351
         constexpr bool dodraw = true;
352 352
       #endif
353
-      if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
353
+      if (dodraw) _draw_centered_temp(target, tx, 7);
354 354
     }
355 355
 
356 356
     if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
357
-      _draw_centered_temp(temp + 0.5f, tx, 28);
357
+      _draw_centered_temp(temp, tx, 28);
358 358
 
359 359
     if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) {
360 360
       u8g.setColorIndex(0); // set to white on black
@@ -370,10 +370,10 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
370 370
   FORCE_INLINE void _draw_chamber_status() {
371 371
     #if HAS_HEATED_CHAMBER
372 372
       if (PAGE_UNDER(7))
373
-        _draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7);
373
+        _draw_centered_temp(thermalManager.degTargetChamber(), STATUS_CHAMBER_TEXT_X, 7);
374 374
     #endif
375 375
     if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
376
-      _draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
376
+      _draw_centered_temp(thermalManager.degChamber(), STATUS_CHAMBER_TEXT_X, 28);
377 377
   }
378 378
 #endif
379 379
 

+ 16
- 16
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Dosyayı Görüntüle

@@ -691,15 +691,15 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
691 691
   // We only add the target temperatures to the checksum
692 692
   // because the actual temps fluctuate so by updating
693 693
   // them only during blinks we gain a bit of stability.
694
-  const bool       blink             = ui.get_blink();
695
-  const uint16_t   feedrate_perc     = feedrate_percentage;
696
-  const uint16_t   fs                = thermalManager.scaledFanSpeed(0);
697
-  const int16_t    extruder_1_target = thermalManager.degTargetHotend(0);
694
+  const bool blink = ui.get_blink();
695
+  const uint16_t feedrate_perc = feedrate_percentage;
696
+  const uint16_t fs = thermalManager.scaledFanSpeed(0);
697
+  const celsius_t extruder_1_target = thermalManager.degTargetHotend(0);
698 698
   #if HAS_MULTI_HOTEND
699
-    const int16_t  extruder_2_target = thermalManager.degTargetHotend(1);
699
+    const celsius_t extruder_2_target = thermalManager.degTargetHotend(1);
700 700
   #endif
701 701
   #if HAS_HEATED_BED
702
-    const int16_t  bed_target        = thermalManager.degTargetBed();
702
+    const celsius_t bed_target = thermalManager.degTargetBed();
703 703
   #endif
704 704
   static uint16_t last_checksum = 0;
705 705
   const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target
@@ -712,19 +712,19 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
712 712
 
713 713
 void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
714 714
   if (forceUpdate || indicators_changed()) {
715
-    const bool       blink             = ui.get_blink();
716
-    const duration_t elapsed           = print_job_timer.duration();
717
-    duration_t       remaining         = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time());
718
-    const uint16_t   feedrate_perc     = feedrate_percentage;
719
-    const int16_t    extruder_1_temp   = thermalManager.degHotend(0),
720
-                     extruder_1_target = thermalManager.degTargetHotend(0);
715
+    const bool       blink              = ui.get_blink();
716
+    const duration_t elapsed            = print_job_timer.duration();
717
+    duration_t       remaining          = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time());
718
+    const uint16_t   feedrate_perc      = feedrate_percentage;
719
+    const celsius_t  extruder_1_temp    = thermalManager.degHotend(0),
720
+                     extruder_1_target  = thermalManager.degTargetHotend(0);
721 721
     #if HAS_MULTI_HOTEND
722
-      const int16_t  extruder_2_temp   = thermalManager.degHotend(1),
723
-                     extruder_2_target = thermalManager.degTargetHotend(1);
722
+      const celsius_t extruder_2_temp   = thermalManager.degHotend(1),
723
+                      extruder_2_target = thermalManager.degTargetHotend(1);
724 724
     #endif
725 725
     #if HAS_HEATED_BED
726
-      const int16_t  bed_temp          = thermalManager.degBed(),
727
-                     bed_target        = thermalManager.degTargetBed();
726
+      const celsius_t bed_temp          = thermalManager.degBed(),
727
+                      bed_target        = thermalManager.degTargetBed();
728 728
     #endif
729 729
 
730 730
     draw_extruder_1_temp(extruder_1_temp, extruder_1_target, forceUpdate);

+ 14
- 12
Marlin/src/lcd/dwin/e3v2/dwin.cpp Dosyayı Görüntüle

@@ -1578,20 +1578,22 @@ void _draw_xyz_position(const bool force) {
1578 1578
 
1579 1579
 void update_variable() {
1580 1580
   #if HAS_HOTEND
1581
-    static float _hotendtemp = 0;
1582
-    const bool _new_hotend_temp = _hotendtemp != thermalManager.temp_hotend[0].celsius;
1583
-    if (_new_hotend_temp) _hotendtemp = thermalManager.temp_hotend[0].celsius;
1584
-    static int16_t _hotendtarget = 0;
1585
-    const bool _new_hotend_target = _hotendtarget != thermalManager.temp_hotend[0].target;
1586
-    if (_new_hotend_target) _hotendtarget = thermalManager.temp_hotend[0].target;
1581
+    static celsius_t _hotendtemp = 0, _hotendtarget = 0;
1582
+    const celsius_t hc = thermalManager.degHotend(0),
1583
+                    ht = thermalManager.degTargetHotend(0);
1584
+    const bool _new_hotend_temp = _hotendtemp != hc,
1585
+               _new_hotend_target = _hotendtarget != ht;
1586
+    if (_new_hotend_temp) _hotendtemp = hc;
1587
+    if (_new_hotend_target) _hotendtarget = ht;
1587 1588
   #endif
1588 1589
   #if HAS_HEATED_BED
1589
-    static float _bedtemp = 0;
1590
-    const bool _new_bed_temp = _bedtemp != thermalManager.temp_bed.celsius;
1591
-    if (_new_bed_temp) _bedtemp = thermalManager.temp_bed.celsius;
1592
-    static int16_t _bedtarget = 0;
1593
-    const bool _new_bed_target = _bedtarget != thermalManager.temp_bed.target;
1594
-    if (_new_bed_target) _bedtarget = thermalManager.temp_bed.target;
1590
+    static celsius_t _bedtemp = 0, _bedtarget = 0;
1591
+    const celsius_t bc = thermalManager.degBed(),
1592
+                    bt = thermalManager.degTargetBed();
1593
+    const bool _new_bed_temp = _bedtemp != bc,
1594
+               _new_bed_target = _bedtarget != bt;
1595
+    if (_new_bed_temp) _bedtemp = bc;
1596
+    if (_new_bed_target) _bedtarget = bt;
1595 1597
   #endif
1596 1598
   #if HAS_FAN
1597 1599
     static uint8_t _fanspeed = 0;

+ 2
- 2
Marlin/src/lcd/dwin/e3v2/dwin.h Dosyayı Görüntüle

@@ -234,8 +234,8 @@ extern char print_filename[16];
234 234
 extern millis_t dwin_heat_time;
235 235
 
236 236
 typedef struct {
237
-  TERN_(HAS_HOTEND,     int16_t E_Temp    = 0);
238
-  TERN_(HAS_HEATED_BED, int16_t Bed_Temp  = 0);
237
+  TERN_(HAS_HOTEND,     celsius_t E_Temp    = 0);
238
+  TERN_(HAS_HEATED_BED, celsius_t Bed_Temp  = 0);
239 239
   TERN_(HAS_FAN,        int16_t Fan_speed = 0);
240 240
   int16_t print_speed     = 100;
241 241
   float Max_Feedspeed     = 0;

+ 5
- 5
Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp Dosyayı Görüntüle

@@ -388,28 +388,28 @@ void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr
388 388
 }
389 389
 
390 390
 void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) {
391
-  uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
392
-  uint16_t acceptedvalue;
391
+  celsius_t newvalue = swap16(*(uint16_t*)val_ptr);
392
+  celsius_t acceptedvalue;
393 393
 
394 394
   switch (var.VP) {
395 395
     default: return;
396 396
     #if HOTENDS >= 1
397 397
       case VP_T_E0_Set:
398
-        NOMORE(newvalue, (uint16_t)HEATER_0_MAXTEMP);
398
+        NOMORE(newvalue, HEATER_0_MAXTEMP);
399 399
         thermalManager.setTargetHotend(newvalue, 0);
400 400
         acceptedvalue = thermalManager.degTargetHotend(0);
401 401
         break;
402 402
     #endif
403 403
     #if HOTENDS >= 2
404 404
       case VP_T_E1_Set:
405
-        NOMORE(newvalue, (uint16_t)HEATER_1_MAXTEMP);
405
+        NOMORE(newvalue, HEATER_1_MAXTEMP);
406 406
         thermalManager.setTargetHotend(newvalue, 1);
407 407
         acceptedvalue = thermalManager.degTargetHotend(1);
408 408
         break;
409 409
     #endif
410 410
     #if HAS_HEATED_BED
411 411
       case VP_T_Bed_Set:
412
-        NOMORE(newvalue, (uint16_t)BED_MAXTEMP);
412
+        NOMORE(newvalue, BED_MAXTEMP);
413 413
         thermalManager.setTargetBed(newvalue);
414 414
         acceptedvalue = thermalManager.degTargetBed();
415 415
         break;

+ 3
- 3
Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp Dosyayı Görüntüle

@@ -367,7 +367,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
367 367
 
368 368
   // Temperature Data
369 369
   #if HOTENDS >= 1
370
-    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
370
+    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
371 371
     VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
372 372
     VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
373 373
     VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@@ -388,7 +388,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
388 388
     #endif
389 389
   #endif
390 390
   #if HOTENDS >= 2
391
-    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
391
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
392 392
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
393 393
     VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
394 394
     VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@@ -400,7 +400,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
400 400
     VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload),
401 401
   #endif
402 402
   #if HAS_HEATED_BED
403
-    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
403
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
404 404
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
405 405
     VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
406 406
     VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

+ 5
- 5
Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp Dosyayı Görüntüle

@@ -364,13 +364,13 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
364 364
     VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr),
365 365
   #endif
366 366
 
367
-  { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
367
+  { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
368 368
   // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
369
-  { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay },
369
+  { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay },
370 370
 
371 371
   // Temperature Data
372 372
   #if HOTENDS >= 1
373
-    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
373
+    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
374 374
     VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
375 375
     VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
376 376
     VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@@ -391,7 +391,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
391 391
     #endif
392 392
   #endif
393 393
   #if HOTENDS >= 2
394
-    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
394
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
395 395
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
396 396
     VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
397 397
     VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@@ -399,7 +399,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
399 399
     VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
400 400
   #endif
401 401
   #if HAS_HEATED_BED
402
-    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
402
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
403 403
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
404 404
     VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
405 405
     VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

+ 3
- 3
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp Dosyayı Görüntüle

@@ -548,7 +548,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
548 548
 
549 549
   // Temperature Data
550 550
   #if HOTENDS >= 1
551
-    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
551
+    VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
552 552
     VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
553 553
     VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
554 554
     VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@@ -573,7 +573,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
573 573
   #endif
574 574
 
575 575
   #if HOTENDS >= 2
576
-    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
576
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
577 577
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
578 578
     VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
579 579
     VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@@ -593,7 +593,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
593 593
   #endif
594 594
 
595 595
   #if HAS_HEATED_BED
596
-    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
596
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
597 597
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
598 598
     VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
599 599
     VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

+ 2
- 2
Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp Dosyayı Görüntüle

@@ -216,7 +216,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
216 216
     #endif
217 217
   #endif
218 218
   #if HOTENDS >= 2
219
-    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
219
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendWordValueToDisplay),
220 220
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
221 221
     VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
222 222
     VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@@ -227,7 +227,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
227 227
     #endif
228 228
   #endif
229 229
   #if HAS_HEATED_BED
230
-    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
230
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
231 231
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
232 232
     VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
233 233
     VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp Dosyayı Görüntüle

@@ -515,7 +515,7 @@ void filament_dialog_handle() {
515 515
   }
516 516
 
517 517
   if (uiCfg.filament_load_heat_flg) {
518
-    const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
518
+    const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
519 519
     if (abs(diff) < 2 || diff > 0) {
520 520
       uiCfg.filament_load_heat_flg = false;
521 521
       lv_clear_dialog();
@@ -531,7 +531,7 @@ void filament_dialog_handle() {
531 531
   }
532 532
 
533 533
   if (uiCfg.filament_unload_heat_flg) {
534
-    const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
534
+    const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
535 535
     if (abs(diff) < 2 || diff > 0) {
536 536
       uiCfg.filament_unload_heat_flg = false;
537 537
       lv_clear_dialog();

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h Dosyayı Görüntüle

@@ -202,7 +202,7 @@ typedef struct {
202 202
             filamentchange_load_speed,
203 203
             filamentchange_unload_length,
204 204
             filamentchange_unload_speed;
205
-  int16_t   filament_limit_temp;
205
+  celsius_t filament_limit_temp;
206 206
   float     pausePosX, pausePosY, pausePosZ;
207 207
   uint32_t  curFilesize;
208 208
 } CFG_ITMES;
@@ -244,7 +244,7 @@ typedef struct {
244 244
            filament_loading_time_cnt,
245 245
            filament_unloading_time_cnt;
246 246
   float move_dist;
247
-  float hotendTargetTempBak;
247
+  celsius_t hotendTargetTempBak;
248 248
   float current_x_position_bak,
249 249
         current_y_position_bak,
250 250
         current_z_position_bak,

+ 3
- 3
Marlin/src/lcd/marlinui.h Dosyayı Görüntüle

@@ -110,9 +110,9 @@
110 110
 
111 111
 #if PREHEAT_COUNT
112 112
   typedef struct {
113
-    TERN_(HAS_HOTEND,     uint16_t hotend_temp);
114
-    TERN_(HAS_HEATED_BED, uint16_t bed_temp   );
115
-    TERN_(HAS_FAN,        uint16_t fan_speed  );
113
+    TERN_(HAS_HOTEND,     celsius_t hotend_temp);
114
+    TERN_(HAS_HEATED_BED, celsius_t bed_temp   );
115
+    TERN_(HAS_FAN,        uint16_t  fan_speed  );
116 116
   } preheat_t;
117 117
 #endif
118 118
 

+ 2
- 2
Marlin/src/lcd/menu/menu_configuration.cpp Dosyayı Görüntüle

@@ -325,10 +325,10 @@ void menu_advanced_settings();
325 325
       EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; });
326 326
     #endif
327 327
     #if HAS_TEMP_HOTEND
328
-      EDIT_ITEM(uint16_3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - HOTEND_OVERSHOOT);
328
+      EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - (HOTEND_OVERSHOOT));
329 329
     #endif
330 330
     #if HAS_HEATED_BED
331
-      EDIT_ITEM(uint16_3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET);
331
+      EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET);
332 332
     #endif
333 333
     #if ENABLED(EEPROM_SETTINGS)
334 334
       ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);

+ 3
- 3
Marlin/src/lcd/tft/ui_320x240.cpp Dosyayı Görüntüle

@@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() {
114 114
 void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
115 115
   MarlinImage image = imgHotEnd;
116 116
   uint16_t Color;
117
-  float currentTemperature, targetTemperature;
117
+  celsius_t currentTemperature, targetTemperature;
118 118
 
119 119
   if (Heater >= 0) { // HotEnd
120 120
     currentTemperature = thermalManager.degHotend(Heater);
@@ -175,13 +175,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
175 175
 
176 176
   tft.add_image(0, 18, image, Color);
177 177
 
178
-  tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5));
178
+  tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
179 179
   tft_string.add(LCD_STR_DEGREE);
180 180
   tft_string.trim();
181 181
   tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string);
182 182
 
183 183
   if (targetTemperature >= 0) {
184
-    tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5));
184
+    tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
185 185
     tft_string.add(LCD_STR_DEGREE);
186 186
     tft_string.trim();
187 187
     tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string);

+ 3
- 3
Marlin/src/lcd/tft/ui_480x320.cpp Dosyayı Görüntüle

@@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() {
114 114
 void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
115 115
   MarlinImage image = imgHotEnd;
116 116
   uint16_t Color;
117
-  float currentTemperature, targetTemperature;
117
+  celsius_t currentTemperature, targetTemperature;
118 118
 
119 119
   if (Heater >= 0) { // HotEnd
120 120
     currentTemperature = thermalManager.degHotend(Heater);
@@ -168,13 +168,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
168 168
 
169 169
   tft.add_image(8, 28, image, Color);
170 170
 
171
-  tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5));
171
+  tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
172 172
   tft_string.add(LCD_STR_DEGREE);
173 173
   tft_string.trim();
174 174
   tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string);
175 175
 
176 176
   if (targetTemperature >= 0) {
177
-    tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5));
177
+    tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
178 178
     tft_string.add(LCD_STR_DEGREE);
179 179
     tft_string.trim();
180 180
     tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string);

+ 3
- 3
Marlin/src/module/motion.cpp Dosyayı Görüntüle

@@ -940,11 +940,11 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
940 940
 
941 941
   DualXMode dual_x_carriage_mode         = DEFAULT_DUAL_X_CARRIAGE_MODE;
942 942
   float inactive_extruder_x              = X2_MAX_POS,                    // Used in mode 0 & 1
943
-        duplicate_extruder_x_offset      = DEFAULT_DUPLICATION_X_OFFSET;  // Used in mode 2
943
+        duplicate_extruder_x_offset      = DEFAULT_DUPLICATION_X_OFFSET;  // Used in mode 2 & 3
944 944
   xyz_pos_t raised_parked_position;                                       // Used in mode 1
945
-  bool active_extruder_parked            = false;                         // Used in mode 1 & 2
945
+  bool active_extruder_parked            = false;                         // Used in mode 1, 2 & 3
946 946
   millis_t delayed_move_time             = 0;                             // Used in mode 1
947
-  int16_t duplicate_extruder_temp_offset = 0;                             // Used in mode 2
947
+  celsius_t duplicate_extruder_temp_offset = 0;                           // Used in mode 2 & 3
948 948
   bool idex_mirrored_mode                = false;                         // Used in mode 3
949 949
 
950 950
   float x_home_pos(const uint8_t extruder) {

+ 7
- 7
Marlin/src/module/motion.h Dosyayı Görüntüle

@@ -463,13 +463,13 @@ FORCE_INLINE bool all_axes_trusted()                        { return xyz_bits ==
463 463
   };
464 464
 
465 465
   extern DualXMode dual_x_carriage_mode;
466
-  extern float inactive_extruder_x,               // Used in mode 0 & 1
467
-               duplicate_extruder_x_offset;       // Used in mode 2 & 3
468
-  extern xyz_pos_t raised_parked_position;        // Used in mode 1
469
-  extern bool active_extruder_parked;             // Used in mode 1, 2 & 3
470
-  extern millis_t delayed_move_time;              // Used in mode 1
471
-  extern int16_t duplicate_extruder_temp_offset;  // Used in mode 2 & 3
472
-  extern bool idex_mirrored_mode;                 // Used in mode 3
466
+  extern float inactive_extruder_x,                 // Used in mode 0 & 1
467
+               duplicate_extruder_x_offset;         // Used in mode 2 & 3
468
+  extern xyz_pos_t raised_parked_position;          // Used in mode 1
469
+  extern bool active_extruder_parked;               // Used in mode 1, 2 & 3
470
+  extern millis_t delayed_move_time;                // Used in mode 1
471
+  extern celsius_t duplicate_extruder_temp_offset;  // Used in mode 2 & 3
472
+  extern bool idex_mirrored_mode;                   // Used in mode 3
473 473
 
474 474
   FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; }
475 475
 

+ 4
- 4
Marlin/src/module/planner.cpp Dosyayı Görüntüle

@@ -197,9 +197,9 @@ float Planner::steps_to_mm[XYZE_N];             // (mm) Millimeters per step
197 197
 skew_factor_t Planner::skew_factor; // Initialized by settings.load()
198 198
 
199 199
 #if ENABLED(AUTOTEMP)
200
-  float Planner::autotemp_max = 250,
201
-        Planner::autotemp_min = 210,
202
-        Planner::autotemp_factor = 0.1f;
200
+  celsius_t Planner::autotemp_max = 250,
201
+            Planner::autotemp_min = 210;
202
+  float Planner::autotemp_factor = 0.1f;
203 203
   bool Planner::autotemp_enabled = false;
204 204
 #endif
205 205
 
@@ -1376,7 +1376,7 @@ void Planner::check_axes_activity() {
1376 1376
 
1377 1377
   #if ENABLED(AUTOTEMP_PROPORTIONAL)
1378 1378
     void Planner::_autotemp_update_from_hotend() {
1379
-      const int16_t target = thermalManager.degTargetHotend(active_extruder);
1379
+      const celsius_t target = thermalManager.degTargetHotend(active_extruder);
1380 1380
       autotemp_min = target + AUTOTEMP_MIN_P;
1381 1381
       autotemp_max = target + AUTOTEMP_MAX_P;
1382 1382
     }

+ 2
- 1
Marlin/src/module/planner.h Dosyayı Görüntüle

@@ -896,7 +896,8 @@ class Planner {
896 896
     #endif
897 897
 
898 898
     #if ENABLED(AUTOTEMP)
899
-      static float autotemp_min, autotemp_max, autotemp_factor;
899
+      static celsius_t autotemp_min, autotemp_max;
900
+      static float autotemp_factor;
900 901
       static bool autotemp_enabled;
901 902
       static void autotemp_update();
902 903
       static void autotemp_M104_M109();

+ 43
- 67
Marlin/src/module/temperature.cpp Dosyayı Görüntüle

@@ -253,7 +253,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
253 253
 
254 254
 #if HAS_HOTEND
255 255
   hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 }
256
-  const uint16_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
256
+  const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
257 257
 #endif
258 258
 
259 259
 #if ENABLED(AUTO_POWER_E_FANS)
@@ -368,12 +368,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
368 368
 #if HAS_HEATED_BED
369 369
   bed_info_t Temperature::temp_bed; // = { 0 }
370 370
   // Init min and max temp with extreme values to prevent false errors during startup
371
-  #ifdef BED_MINTEMP
372
-    int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP;
373
-  #endif
374
-  #ifdef BED_MAXTEMP
375
-    int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
376
-  #endif
371
+  int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP,
372
+          Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
377 373
   TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
378 374
   IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
379 375
 #endif
@@ -383,12 +379,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
383 379
   #if HAS_HEATED_CHAMBER
384 380
     millis_t next_cool_check_ms_2 = 0;
385 381
     float old_temp = 9999;
386
-    #ifdef CHAMBER_MINTEMP
387
-      int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP;
388
-    #endif
389
-    #ifdef CHAMBER_MAXTEMP
390
-      int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
391
-    #endif
382
+    int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP,
383
+            Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
392 384
     TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0});
393 385
     IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms);
394 386
   #endif
@@ -400,12 +392,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
400 392
     bool flag_cooler_state;
401 393
     //bool flag_cooler_excess = false;
402 394
     float previous_temp = 9999;
403
-    #ifdef COOLER_MINTEMP
404
-      int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP;
405
-    #endif
406
-    #ifdef COOLER_MAXTEMP
407
-      int16_t Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
408
-    #endif
395
+    int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP,
396
+            Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
409 397
     #if WATCH_COOLER
410 398
       cooler_watch_t Temperature::watch_cooler{0};
411 399
     #endif
@@ -419,7 +407,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
419 407
 
420 408
 #if ENABLED(PREVENT_COLD_EXTRUSION)
421 409
   bool Temperature::allow_cold_extrude = false;
422
-  int16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
410
+  celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
423 411
 #endif
424 412
 
425 413
 // private:
@@ -429,7 +417,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
429 417
 #endif
430 418
 
431 419
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
432
-  uint16_t Temperature::redundant_temperature_raw = 0;
420
+  celsius_t Temperature::redundant_temperature_raw = 0;
433 421
   float Temperature::redundant_temperature = 0.0;
434 422
 #endif
435 423
 
@@ -474,7 +462,7 @@ volatile bool Temperature::raw_temps_ready = false;
474 462
 #endif
475 463
 
476 464
 #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
477
-  uint16_t Temperature::singlenozzle_temp[EXTRUDERS];
465
+  celsius_t Temperature::singlenozzle_temp[EXTRUDERS];
478 466
   #if HAS_FAN
479 467
     uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS];
480 468
   #endif
@@ -1566,22 +1554,22 @@ void Temperature::manage_heater() {
1566 1554
  * Bisect search for the range of the 'raw' value, then interpolate
1567 1555
  * proportionally between the under and over values.
1568 1556
  */
1569
-#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{                            \
1570
-  uint8_t l = 0, r = LEN, m;                                          \
1571
-  for (;;) {                                                          \
1572
-    m = (l + r) >> 1;                                                 \
1573
-    if (!m) return int16_t(pgm_read_word(&TBL[0].celsius));           \
1574
-    if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \
1575
-    int16_t v00 = pgm_read_word(&TBL[m-1].value),                     \
1576
-          v10 = pgm_read_word(&TBL[m-0].value);                       \
1577
-         if (raw < v00) r = m;                                        \
1578
-    else if (raw > v10) l = m;                                        \
1579
-    else {                                                            \
1580
-      const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)),  \
1581
-                  v11 = int16_t(pgm_read_word(&TBL[m-0].celsius));    \
1582
-      return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \
1583
-    }                                                                 \
1584
-  }                                                                   \
1557
+#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{                                \
1558
+  uint8_t l = 0, r = LEN, m;                                              \
1559
+  for (;;) {                                                              \
1560
+    m = (l + r) >> 1;                                                     \
1561
+    if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius));             \
1562
+    if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \
1563
+    int16_t v00 = pgm_read_word(&TBL[m-1].value),                         \
1564
+            v10 = pgm_read_word(&TBL[m-0].value);                         \
1565
+         if (raw < v00) r = m;                                            \
1566
+    else if (raw > v10) l = m;                                            \
1567
+    else {                                                                \
1568
+      const celsius_t v01 = celsius_t(pgm_read_word(&TBL[m-1].celsius)),  \
1569
+                      v11 = celsius_t(pgm_read_word(&TBL[m-0].celsius));  \
1570
+      return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00);     \
1571
+    }                                                                     \
1572
+  }                                                                       \
1585 1573
 }while(0)
1586 1574
 
1587 1575
 #if HAS_USER_THERMISTORS
@@ -1663,7 +1651,7 @@ void Temperature::manage_heater() {
1663 1651
     SERIAL_EOL();
1664 1652
   }
1665 1653
 
1666
-  float Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
1654
+  celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
1667 1655
     //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
1668 1656
     //  static uint32_t clocks_total = 0;
1669 1657
     //  static uint32_t calls = 0;
@@ -1712,7 +1700,7 @@ void Temperature::manage_heater() {
1712 1700
 #if HAS_HOTEND
1713 1701
   // Derived from RepRap FiveD extruder::getTemperature()
1714 1702
   // For hot end temperature measurement.
1715
-  float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
1703
+  celsius_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
1716 1704
       if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
1717 1705
         SERIAL_ERROR_START();
1718 1706
         SERIAL_ECHO(e);
@@ -1821,7 +1809,7 @@ void Temperature::manage_heater() {
1821 1809
 
1822 1810
 #if HAS_HEATED_BED
1823 1811
   // For bed temperature measurement.
1824
-  float Temperature::analog_to_celsius_bed(const int raw) {
1812
+  celsius_t Temperature::analog_to_celsius_bed(const int raw) {
1825 1813
     #if TEMP_SENSOR_BED_IS_CUSTOM
1826 1814
       return user_thermistor_to_deg_c(CTI_BED, raw);
1827 1815
     #elif TEMP_SENSOR_BED_IS_THERMISTOR
@@ -1839,7 +1827,7 @@ void Temperature::manage_heater() {
1839 1827
 
1840 1828
 #if HAS_TEMP_CHAMBER
1841 1829
   // For chamber temperature measurement.
1842
-  float Temperature::analog_to_celsius_chamber(const int raw) {
1830
+  celsius_t Temperature::analog_to_celsius_chamber(const int raw) {
1843 1831
     #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
1844 1832
       return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
1845 1833
     #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
@@ -1857,7 +1845,7 @@ void Temperature::manage_heater() {
1857 1845
 
1858 1846
 #if HAS_TEMP_COOLER
1859 1847
   // For cooler temperature measurement.
1860
-  float Temperature::analog_to_celsius_cooler(const int raw) {
1848
+  celsius_t Temperature::analog_to_celsius_cooler(const int raw) {
1861 1849
     #if TEMP_SENSOR_COOLER_IS_CUSTOM
1862 1850
       return user_thermistor_to_deg_c(CTI_COOLER, raw);
1863 1851
     #elif TEMP_SENSOR_COOLER_IS_THERMISTOR
@@ -1875,7 +1863,7 @@ void Temperature::manage_heater() {
1875 1863
 
1876 1864
 #if HAS_TEMP_PROBE
1877 1865
   // For probe temperature measurement.
1878
-  float Temperature::analog_to_celsius_probe(const int raw) {
1866
+  celsius_t Temperature::analog_to_celsius_probe(const int raw) {
1879 1867
     #if TEMP_SENSOR_PROBE_IS_CUSTOM
1880 1868
       return user_thermistor_to_deg_c(CTI_PROBE, raw);
1881 1869
     #elif TEMP_SENSOR_PROBE_IS_THERMISTOR
@@ -2191,13 +2179,13 @@ void Temperature::init() {
2191 2179
   #if HAS_HOTEND
2192 2180
 
2193 2181
     #define _TEMP_MIN_E(NR) do{ \
2194
-      const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
2182
+      const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
2195 2183
       temp_range[NR].mintemp = tmin; \
2196 2184
       while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
2197 2185
         temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
2198 2186
     }while(0)
2199 2187
     #define _TEMP_MAX_E(NR) do{ \
2200
-      const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
2188
+      const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
2201 2189
       temp_range[NR].maxtemp = tmax; \
2202 2190
       while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
2203 2191
         temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
@@ -2257,30 +2245,18 @@ void Temperature::init() {
2257 2245
   #endif // HAS_HOTEND
2258 2246
 
2259 2247
   #if HAS_HEATED_BED
2260
-    #ifdef BED_MINTEMP
2261
-      while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR);
2262
-    #endif
2263
-    #ifdef BED_MAXTEMP
2264
-      while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
2265
-    #endif
2266
-  #endif // HAS_HEATED_BED
2248
+    while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR);
2249
+    while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
2250
+  #endif
2267 2251
 
2268 2252
   #if HAS_HEATED_CHAMBER
2269
-    #ifdef CHAMBER_MINTEMP
2270
-      while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR);
2271
-    #endif
2272
-    #ifdef CHAMBER_MAXTEMP
2273
-      while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
2274
-    #endif
2253
+    while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR);
2254
+    while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
2275 2255
   #endif
2276 2256
 
2277 2257
   #if HAS_COOLER
2278
-    #ifdef COOLER_MINTEMP
2279
-      while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
2280
-    #endif
2281
-    #ifdef COOLER_MAXTEMP
2282
-      while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
2283
-    #endif
2258
+    while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
2259
+    while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
2284 2260
   #endif
2285 2261
 
2286 2262
   TERN_(PROBING_HEATERS_OFF, paused = false);
@@ -2345,7 +2321,7 @@ void Temperature::init() {
2345 2321
    *
2346 2322
    * TODO: Embed the last 3 parameters during init, if not less optimal
2347 2323
    */
2348
-  void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
2324
+  void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
2349 2325
 
2350 2326
     #if HEATER_IDLE_HANDLER
2351 2327
       // Convert the given heater_id_t to an idle array index
@@ -2554,7 +2530,7 @@ void Temperature::disable_all_heaters() {
2554 2530
 
2555 2531
     #if HAS_MULTI_MAX_TC
2556 2532
       // Needed to return the correct temp when this is called between readings
2557
-      static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
2533
+      static celsius_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
2558 2534
       #define THERMO_TEMP(I) max_tc_temp_previous[I]
2559 2535
       #define THERMO_SEL(A,B) (hindex ? (B) : (A))
2560 2536
       #define MAX6675_WRITE(V)     do{ switch (hindex) { case 1:      WRITE(MAX6675_SS2_PIN, V); break; default:      WRITE(MAX6675_SS_PIN, V); } }while(0)

+ 45
- 73
Marlin/src/module/temperature.h Dosyayı Görüntüle

@@ -179,7 +179,7 @@ enum ADCSensorState : char {
179 179
 typedef struct TempInfo {
180 180
   uint16_t acc;
181 181
   int16_t raw;
182
-  float celsius;
182
+  celsius_t celsius;
183 183
   inline void reset() { acc = 0; }
184 184
   inline void sample(const uint16_t s) { acc += s; }
185 185
   inline void update() { raw = acc; }
@@ -187,7 +187,7 @@ typedef struct TempInfo {
187 187
 
188 188
 // A PWM heater with temperature sensor
189 189
 typedef struct HeaterInfo : public TempInfo {
190
-  int16_t target;
190
+  celsius_t target;
191 191
   uint8_t soft_pwm_amount;
192 192
 } heater_info_t;
193 193
 
@@ -228,14 +228,14 @@ struct PIDHeaterInfo : public HeaterInfo {
228 228
 // Heater watch handling
229 229
 template <int INCREASE, int HYSTERESIS, millis_t PERIOD>
230 230
 struct HeaterWatch {
231
-  uint16_t target;
231
+  celsius_t target;
232 232
   millis_t next_ms;
233 233
   inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); }
234 234
   inline bool elapsed() { return elapsed(millis()); }
235 235
 
236
-  inline void restart(const int16_t curr, const int16_t tgt) {
236
+  inline void restart(const celsius_t curr, const celsius_t tgt) {
237 237
     if (tgt) {
238
-      const int16_t newtarget = curr + INCREASE;
238
+      const celsius_t newtarget = curr + INCREASE;
239 239
       if (newtarget < tgt - HYSTERESIS - 1) {
240 240
         target = newtarget;
241 241
         next_ms = millis() + SEC_TO_MS(PERIOD);
@@ -261,8 +261,8 @@ struct HeaterWatch {
261 261
 
262 262
 // Temperature sensor read value ranges
263 263
 typedef struct { int16_t raw_min, raw_max; } raw_range_t;
264
-typedef struct { int16_t mintemp, maxtemp; } celsius_range_t;
265
-typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t;
264
+typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t;
265
+typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t;
266 266
 
267 267
 #define THERMISTOR_ABS_ZERO_C           -273.15f  // bbbbrrrrr cold !
268 268
 #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f     // mmmmm comfortable
@@ -323,8 +323,8 @@ class Temperature {
323 323
     #if HAS_HOTEND
324 324
       #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
325 325
       static hotend_info_t temp_hotend[HOTEND_TEMPS];
326
-      static const uint16_t hotend_maxtemp[HOTENDS];
327
-      FORCE_INLINE static uint16_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
326
+      static const celsius_t hotend_maxtemp[HOTENDS];
327
+      FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
328 328
     #endif
329 329
     TERN_(HAS_HEATED_BED, static bed_info_t temp_bed);
330 330
     TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe);
@@ -342,8 +342,8 @@ class Temperature {
342 342
 
343 343
     #if ENABLED(PREVENT_COLD_EXTRUSION)
344 344
       static bool allow_cold_extrude;
345
-      static int16_t extrude_min_temp;
346
-      FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
345
+      static celsius_t extrude_min_temp;
346
+      FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
347 347
       FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
348 348
         return tooCold(degHotend(HOTEND_INDEX));
349 349
       }
@@ -359,7 +359,7 @@ class Temperature {
359 359
     FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
360 360
 
361 361
     #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
362
-      static uint16_t singlenozzle_temp[EXTRUDERS];
362
+      static celsius_t singlenozzle_temp[EXTRUDERS];
363 363
       #if HAS_FAN
364 364
         static uint8_t singlenozzle_fan_speed[EXTRUDERS];
365 365
       #endif
@@ -411,7 +411,7 @@ class Temperature {
411 411
 
412 412
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
413 413
       static uint16_t redundant_temperature_raw;
414
-      static float redundant_temperature;
414
+      static celsius_t redundant_temperature;
415 415
     #endif
416 416
 
417 417
     #if ENABLED(PID_EXTRUSION_SCALING)
@@ -424,34 +424,19 @@ class Temperature {
424 424
     #if HAS_HEATED_BED
425 425
       TERN_(WATCH_BED, static bed_watch_t watch_bed);
426 426
       IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms);
427
-      #ifdef BED_MINTEMP
428
-        static int16_t mintemp_raw_BED;
429
-      #endif
430
-      #ifdef BED_MAXTEMP
431
-        static int16_t maxtemp_raw_BED;
432
-      #endif
427
+      static int16_t mintemp_raw_BED, maxtemp_raw_BED;
433 428
     #endif
434 429
 
435 430
     #if HAS_HEATED_CHAMBER
436 431
       TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber);
437 432
       TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms);
438
-      #ifdef CHAMBER_MINTEMP
439
-        static int16_t mintemp_raw_CHAMBER;
440
-      #endif
441
-      #ifdef CHAMBER_MAXTEMP
442
-        static int16_t maxtemp_raw_CHAMBER;
443
-      #endif
433
+      static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER;
444 434
     #endif
445 435
 
446 436
     #if HAS_COOLER
447 437
       TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler);
448 438
       static millis_t next_cooler_check_ms, cooler_fan_flush_ms;
449
-      #ifdef COOLER_MINTEMP
450
-        static int16_t mintemp_raw_COOLER;
451
-      #endif
452
-      #ifdef COOLER_MAXTEMP
453
-        static int16_t maxtemp_raw_COOLER;
454
-      #endif
439
+      static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER;
455 440
     #endif
456 441
 
457 442
     #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
@@ -488,7 +473,7 @@ class Temperature {
488 473
       static user_thermistor_t user_thermistor[USER_THERMISTORS];
489 474
       static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
490 475
       static void reset_user_thermistors();
491
-      static float user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
476
+      static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
492 477
       static bool set_pull_up_res(int8_t t_index, float value) {
493 478
         //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
494 479
         if (!WITHIN(value, 1, 1000000)) return false;
@@ -516,19 +501,19 @@ class Temperature {
516 501
     #endif
517 502
 
518 503
     #if HAS_HOTEND
519
-      static float analog_to_celsius_hotend(const int raw, const uint8_t e);
504
+      static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e);
520 505
     #endif
521 506
     #if HAS_HEATED_BED
522
-      static float analog_to_celsius_bed(const int raw);
507
+      static celsius_t analog_to_celsius_bed(const int raw);
523 508
     #endif
524 509
     #if HAS_TEMP_PROBE
525
-      static float analog_to_celsius_probe(const int raw);
510
+      static celsius_t analog_to_celsius_probe(const int raw);
526 511
     #endif
527 512
     #if HAS_TEMP_CHAMBER
528
-      static float analog_to_celsius_chamber(const int raw);
513
+      static celsius_t analog_to_celsius_chamber(const int raw);
529 514
     #endif
530 515
     #if HAS_TEMP_COOLER
531
-      static float analog_to_celsius_cooler(const int raw);
516
+      static celsius_t analog_to_celsius_cooler(const int raw);
532 517
     #endif
533 518
 
534 519
     #if HAS_FAN
@@ -620,7 +605,7 @@ class Temperature {
620 605
       }
621 606
     #endif
622 607
 
623
-    FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) {
608
+    FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) {
624 609
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
625 610
     }
626 611
 
@@ -632,7 +617,7 @@ class Temperature {
632 617
 
633 618
     #if HAS_HOTEND
634 619
 
635
-      static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) {
620
+      static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) {
636 621
         const uint8_t ee = HOTEND_INDEX;
637 622
         #ifdef MILLISECONDS_PREHEAT_TIME
638 623
           if (celsius == 0)
@@ -678,12 +663,12 @@ class Temperature {
678 663
     #if HAS_HEATED_BED
679 664
 
680 665
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
681
-        FORCE_INLINE static int16_t rawBedTemp()  { return temp_bed.raw; }
666
+        FORCE_INLINE static int16_t rawBedTemp()    { return temp_bed.raw; }
682 667
       #endif
683
-      FORCE_INLINE static float degBed()          { return temp_bed.celsius; }
684
-      FORCE_INLINE static int16_t degTargetBed()  { return temp_bed.target; }
685
-      FORCE_INLINE static bool isHeatingBed()     { return temp_bed.target > temp_bed.celsius; }
686
-      FORCE_INLINE static bool isCoolingBed()     { return temp_bed.target < temp_bed.celsius; }
668
+      FORCE_INLINE static celsius_t degBed()        { return temp_bed.celsius; }
669
+      FORCE_INLINE static celsius_t degTargetBed()  { return temp_bed.target; }
670
+      FORCE_INLINE static bool isHeatingBed()       { return temp_bed.target > temp_bed.celsius; }
671
+      FORCE_INLINE static bool isCoolingBed()       { return temp_bed.target < temp_bed.celsius; }
687 672
 
688 673
       #if WATCH_BED
689 674
         static void start_watching_bed();
@@ -691,15 +676,9 @@ class Temperature {
691 676
         static inline void start_watching_bed() {}
692 677
       #endif
693 678
 
694
-      static void setTargetBed(const int16_t celsius) {
679
+      static void setTargetBed(const celsius_t celsius) {
695 680
         TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
696
-        temp_bed.target =
697
-          #ifdef BED_MAX_TARGET
698
-            _MIN(celsius, BED_MAX_TARGET)
699
-          #else
700
-            celsius
701
-          #endif
702
-        ;
681
+        temp_bed.target = _MIN(celsius, BED_MAX_TARGET);
703 682
         start_watching_bed();
704 683
       }
705 684
 
@@ -735,14 +714,13 @@ class Temperature {
735 714
 
736 715
     #if HAS_TEMP_CHAMBER
737 716
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
738
-        FORCE_INLINE static int16_t rawChamberTemp()    { return temp_chamber.raw; }
717
+        FORCE_INLINE static int16_t rawChamberTemp()      { return temp_chamber.raw; }
739 718
       #endif
740
-      FORCE_INLINE static float degChamber()            { return temp_chamber.celsius; }
719
+      FORCE_INLINE static float degChamber()              { return temp_chamber.celsius; }
741 720
       #if HAS_HEATED_CHAMBER
742
-        FORCE_INLINE static int16_t degTargetChamber()  { return temp_chamber.target; }
743
-        FORCE_INLINE static bool isHeatingChamber()     { return temp_chamber.target > temp_chamber.celsius; }
744
-        FORCE_INLINE static bool isCoolingChamber()     { return temp_chamber.target < temp_chamber.celsius; }
745
-
721
+        FORCE_INLINE static celsius_t degTargetChamber()  { return temp_chamber.target; }
722
+        FORCE_INLINE static bool isHeatingChamber()       { return temp_chamber.target > temp_chamber.celsius; }
723
+        FORCE_INLINE static bool isCoolingChamber()       { return temp_chamber.target < temp_chamber.celsius; }
746 724
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
747 725
       #endif
748 726
     #endif
@@ -754,27 +732,21 @@ class Temperature {
754 732
     #endif
755 733
 
756 734
     #if HAS_HEATED_CHAMBER
757
-      static void setTargetChamber(const int16_t celsius) {
758
-        temp_chamber.target =
759
-          #ifdef CHAMBER_MAXTEMP
760
-            _MIN(celsius, CHAMBER_MAXTEMP - 10)
761
-          #else
762
-            celsius
763
-          #endif
764
-        ;
735
+      static void setTargetChamber(const celsius_t celsius) {
736
+        temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET);
765 737
         start_watching_chamber();
766 738
       }
767 739
     #endif
768 740
 
769 741
     #if HAS_TEMP_COOLER
770 742
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
771
-        FORCE_INLINE static int16_t rawCoolerTemp()    { return temp_cooler.raw; }
743
+        FORCE_INLINE static int16_t rawCoolerTemp()     { return temp_cooler.raw; }
772 744
       #endif
773
-      FORCE_INLINE static float degCooler()            { return temp_cooler.celsius; }
745
+      FORCE_INLINE static float degCooler()             { return temp_cooler.celsius; }
774 746
       #if HAS_COOLER
775
-        FORCE_INLINE static int16_t degTargetCooler()  { return temp_cooler.target; }
776
-        FORCE_INLINE static bool isLaserHeating()     { return temp_cooler.target > temp_cooler.celsius; }
777
-        FORCE_INLINE static bool isLaserCooling()     { return temp_cooler.target < temp_cooler.celsius; }
747
+        FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; }
748
+        FORCE_INLINE static bool isLaserHeating()       { return temp_cooler.target > temp_cooler.celsius; }
749
+        FORCE_INLINE static bool isLaserCooling()       { return temp_cooler.target < temp_cooler.celsius; }
778 750
         static bool wait_for_cooler(const bool no_wait_for_cooling=true);
779 751
       #endif
780 752
     #endif
@@ -786,7 +758,7 @@ class Temperature {
786 758
     #endif
787 759
 
788 760
     #if HAS_COOLER
789
-      static void setTargetCooler(const int16_t celsius) {
761
+      static void setTargetCooler(const celsius_t celsius) {
790 762
         temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
791 763
         start_watching_cooler();
792 764
       }
@@ -945,7 +917,7 @@ class Temperature {
945 917
         millis_t timer = 0;
946 918
         TRState state = TRInactive;
947 919
         float running_temp;
948
-        void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
920
+        void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
949 921
       } tr_state_machine_t;
950 922
 
951 923
       static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY];

+ 1
- 1
Marlin/src/module/thermistor/thermistors.h Dosyayı Görüntüle

@@ -44,7 +44,7 @@
44 44
 
45 45
 #define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
46 46
 
47
-typedef struct { int16_t value, celsius; } temp_entry_t;
47
+typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
48 48
 
49 49
 // Pt1000 and Pt100 handling
50 50
 //

Loading…
İptal
Kaydet