Procházet zdrojové kódy

Update temperature types

Scott Lahteine před 3 roky
rodič
revize
72e3d2492f

+ 11
- 9
Marlin/src/core/types.h Zobrazit soubor

@@ -77,6 +77,7 @@ typedef float feedRate_t;
77 77
 // For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100
78 78
 //
79 79
 typedef int16_t celsius_t;
80
+typedef float celsius_float_t;
80 81
 
81 82
 //
82 83
 // On AVR pointers are only 2 bytes so use 'const float &' for 'const float'
@@ -87,17 +88,18 @@ typedef int16_t celsius_t;
87 88
   typedef const float const_float_t;
88 89
 #endif
89 90
 typedef const_float_t const_feedRate_t;
91
+typedef const_float_t const_celsius_float_t;
90 92
 
91 93
 // Conversion macros
92
-#define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
93
-#define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)
94
+#define MMM_TO_MMS(MM_M) feedRate_t(static_cast<float>(MM_M) / 60.0f)
95
+#define MMS_TO_MMM(MM_S) (static_cast<float>(MM_S) * 60.0f)
94 96
 
95 97
 //
96 98
 // Coordinates structures for XY, XYZ, XYZE...
97 99
 //
98 100
 
99 101
 // Helpers
100
-#define _RECIP(N) ((N) ? 1.0f / float(N) : 0.0f)
102
+#define _RECIP(N) ((N) ? 1.0f / static_cast<float>(N) : 0.0f)
101 103
 #define _ABS(N) ((N) < 0 ? -(N) : (N))
102 104
 #define _LS(N)  (N = (T)(uint32_t(N) << v))
103 105
 #define _RS(N)  (N = (T)(uint32_t(N) >> v))
@@ -214,8 +216,8 @@ struct XYval {
214 216
   FI XYval<int32_t>   asLong()                    const { return { int32_t(x), int32_t(y) }; }
215 217
   FI XYval<int32_t>   ROUNDL()                          { return { int32_t(LROUND(x)), int32_t(LROUND(y)) }; }
216 218
   FI XYval<int32_t>   ROUNDL()                    const { return { int32_t(LROUND(x)), int32_t(LROUND(y)) }; }
217
-  FI XYval<float>    asFloat()                          { return {   float(x),   float(y) }; }
218
-  FI XYval<float>    asFloat()                    const { return {   float(x),   float(y) }; }
219
+  FI XYval<float>    asFloat()                          { return { static_cast<float>(x), static_cast<float>(y) }; }
220
+  FI XYval<float>    asFloat()                    const { return { static_cast<float>(x), static_cast<float>(y) }; }
219 221
   FI XYval<float> reciprocal()                    const { return {  _RECIP(x),  _RECIP(y) }; }
220 222
   FI XYval<float>  asLogical()                    const { XYval<float> o = asFloat(); toLogical(o); return o; }
221 223
   FI XYval<float>   asNative()                    const { XYval<float> o = asFloat(); toNative(o);  return o; }
@@ -325,8 +327,8 @@ struct XYZval {
325 327
   FI XYZval<int32_t>  asLong()                   const { return { int32_t(x), int32_t(y), int32_t(z) }; }
326 328
   FI XYZval<int32_t>  ROUNDL()                         { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; }
327 329
   FI XYZval<int32_t>  ROUNDL()                   const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; }
328
-  FI XYZval<float>   asFloat()                         { return {   float(x),   float(y),   float(z) }; }
329
-  FI XYZval<float>   asFloat()                   const { return {   float(x),   float(y),   float(z) }; }
330
+  FI XYZval<float>   asFloat()                         { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }; }
331
+  FI XYZval<float>   asFloat()                   const { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }; }
330 332
   FI XYZval<float> reciprocal()                  const { return {  _RECIP(x),  _RECIP(y),  _RECIP(z) }; }
331 333
   FI XYZval<float> asLogical()                   const { XYZval<float> o = asFloat(); toLogical(o); return o; }
332 334
   FI XYZval<float>  asNative()                   const { XYZval<float> o = asFloat(); toNative(o);  return o; }
@@ -436,8 +438,8 @@ struct XYZEval {
436 438
   FI XYZEval<int32_t>  asLong()                         const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; }
437 439
   FI XYZEval<int32_t>  ROUNDL()                               { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; }
438 440
   FI XYZEval<int32_t>  ROUNDL()                         const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; }
439
-  FI XYZEval<float>   asFloat()                               { return {   float(x),   float(y),   float(z),   float(e) }; }
440
-  FI XYZEval<float>   asFloat()                         const { return {   float(x),   float(y),   float(z),   float(e) }; }
441
+  FI XYZEval<float>   asFloat()                               { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(e) }; }
442
+  FI XYZEval<float>   asFloat()                         const { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(e) }; }
441 443
   FI XYZEval<float> reciprocal()                        const { return {  _RECIP(x),  _RECIP(y),  _RECIP(z),  _RECIP(e) }; }
442 444
   FI XYZEval<float> asLogical()                         const { XYZEval<float> o = asFloat(); toLogical(o); return o; }
443 445
   FI XYZEval<float>  asNative()                         const { XYZEval<float> o = asFloat(); toNative(o);  return o; }

+ 3
- 3
Marlin/src/feature/probe_temp_comp.cpp Zobrazit soubor

@@ -52,7 +52,7 @@ const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = {
52 52
 
53 53
 constexpr xyz_pos_t ProbeTempComp::park_point;
54 54
 constexpr xy_pos_t ProbeTempComp::measure_point;
55
-constexpr int ProbeTempComp::probe_calib_bed_temp;
55
+constexpr celsius_t ProbeTempComp::probe_calib_bed_temp;
56 56
 
57 57
 uint8_t ProbeTempComp::calib_idx; // = 0
58 58
 float ProbeTempComp::init_measurement; // = 0.0
@@ -126,7 +126,7 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) {
126 126
       SERIAL_ECHOPGM("Applying linear extrapolation");
127 127
       calib_idx--;
128 128
       for (; calib_idx < measurements; ++calib_idx) {
129
-        const float temp = start_temp + float(calib_idx) * res_temp;
129
+        const celsius_float_t temp = start_temp + float(calib_idx) * res_temp;
130 130
         data[calib_idx] = static_cast<int16_t>(k * temp + d);
131 131
       }
132 132
     }
@@ -174,7 +174,7 @@ float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_fl
174 174
     return xy_float_t({start_temp + i*res_temp, static_cast<float>(data[i])});
175 175
   };
176 176
 
177
-  auto linear_interp = [](float x, xy_float_t p1, xy_float_t p2) {
177
+  auto linear_interp = [](const_float_t x, xy_float_t p1, xy_float_t p2) {
178 178
     return (p2.y - p1.y) / (p2.x - p2.y) * (x - p1.x) + p1.y;
179 179
   };
180 180
 

+ 2
- 2
Marlin/src/feature/probe_temp_comp.h Zobrazit soubor

@@ -100,8 +100,8 @@ class ProbeTempComp {
100 100
     static constexpr xy_pos_t measure_point    = PTC_PROBE_POS;     // Coordinates to probe
101 101
                             //measure_point    = { 12.0f, 7.3f };   // Coordinates for the MK52 magnetic heatbed
102 102
 
103
-    static constexpr int  probe_calib_bed_temp = BED_MAX_TARGET,  // Bed temperature while calibrating probe
104
-                          bed_calib_probe_temp = BTC_PROBE_TEMP;  // Probe temperature while calibrating bed
103
+    static constexpr celsius_t probe_calib_bed_temp = BED_MAX_TARGET,  // Bed temperature while calibrating probe
104
+                               bed_calib_probe_temp = BTC_PROBE_TEMP;  // Probe temperature while calibrating bed
105 105
 
106 106
     static int16_t *sensor_z_offsets[TSI_COUNT],
107 107
                    z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // (µm)

+ 6
- 6
Marlin/src/gcode/calibrate/G76_M192_M871.cpp Zobrazit soubor

@@ -110,7 +110,7 @@ void GcodeSuite::G76() {
110 110
     return false;
111 111
   };
112 112
 
113
-  auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
113
+  auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) {
114 114
     do_z_clearance(5.0); // Raise nozzle before probing
115 115
     const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false);  // verbose=0, probe_relative=false
116 116
     if (isnan(measured_z))
@@ -170,14 +170,14 @@ void GcodeSuite::G76() {
170 170
   // Report temperatures every second and handle heating timeouts
171 171
   millis_t next_temp_report = millis() + 1000;
172 172
 
173
-  auto report_targets = [&](const uint16_t tb, const uint16_t tp) {
173
+  auto report_targets = [&](const celsius_t tb, const celsius_t tp) {
174 174
     SERIAL_ECHOLNPAIR("Target Bed:", tb, " Probe:", tp);
175 175
   };
176 176
 
177 177
   if (do_bed_cal) {
178 178
 
179
-    uint16_t target_bed = cali_info_init[TSI_BED].start_temp,
180
-             target_probe = temp_comp.bed_calib_probe_temp;
179
+    celsius_t target_bed = cali_info_init[TSI_BED].start_temp,
180
+            target_probe = temp_comp.bed_calib_probe_temp;
181 181
 
182 182
     say_waiting_for(); SERIAL_ECHOLNPGM(" cooling.");
183 183
     while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe)
@@ -236,10 +236,10 @@ void GcodeSuite::G76() {
236 236
     do_blocking_move_to(parkpos);
237 237
 
238 238
     // Initialize temperatures
239
-    const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
239
+    const celsius_t target_bed = temp_comp.probe_calib_bed_temp;
240 240
     thermalManager.setTargetBed(target_bed);
241 241
 
242
-    uint16_t target_probe = cali_info_init[TSI_PROBE].start_temp;
242
+    celsius_t target_probe = cali_info_init[TSI_PROBE].start_temp;
243 243
 
244 244
     report_targets(target_bed, target_probe);
245 245
 

+ 2
- 2
Marlin/src/gcode/temp/M303.cpp Zobrazit soubor

@@ -57,7 +57,7 @@ void GcodeSuite::M303() {
57 57
   #endif
58 58
 
59 59
   const heater_id_t hid = (heater_id_t)parser.intval('E');
60
-  int16_t default_temp;
60
+  celsius_t default_temp;
61 61
   switch (hid) {
62 62
     #if ENABLED(PIDTEMP)
63 63
       case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break;
@@ -74,7 +74,7 @@ void GcodeSuite::M303() {
74 74
       return;
75 75
   }
76 76
 
77
-  const int16_t temp = parser.celsiusval('S', default_temp);
77
+  const celsius_t temp = parser.celsiusval('S', default_temp);
78 78
   const int c = parser.intval('C', 5);
79 79
   const bool u = parser.boolval('U');
80 80
 

+ 1
- 2
Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp Zobrazit soubor

@@ -373,10 +373,9 @@ int8_t ChironTFT::FindToken(char c) {
373 373
 
374 374
 void ChironTFT::CheckHeaters() {
375 375
   uint8_t faultDuration = 0;
376
-  float temp = 0;
377 376
 
378 377
   // if the hotend temp is abnormal, confirm state before signalling panel
379
-  temp = getActualTemp_celsius(E0);
378
+  celsius_float_t temp = getActualTemp_celsius(E0);
380 379
   while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
381 380
     faultDuration++;
382 381
     if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {

+ 10
- 8
Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp Zobrazit soubor

@@ -534,6 +534,8 @@ void AnycubicTFTClass::OnPrintTimerStopped() {
534 534
   #endif
535 535
 }
536 536
 
537
+#define ROUND(val) int((val)+0.5f)
538
+
537 539
 void AnycubicTFTClass::GetCommandFromTFT() {
538 540
   char *starpos = nullptr;
539 541
   while (LCD_SERIAL.available() > 0  && TFTbuflen < TFTBUFSIZE) {
@@ -560,26 +562,26 @@ void AnycubicTFTClass::GetCommandFromTFT() {
560 562
 
561 563
         switch (a_command) {
562 564
           case 0: { // A0 GET HOTEND TEMP
563
-            const float hotendActualTemp = getActualTemp_celsius(E0);
564
-            SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
565
+            const celsius_float_t hotendActualTemp = getActualTemp_celsius(E0);
566
+            SEND_PGM_VAL("A0V ", ROUND(hotendActualTemp));
565 567
           }
566 568
           break;
567 569
 
568 570
           case 1: { // A1  GET HOTEND TARGET TEMP
569
-            const float hotendTargetTemp = getTargetTemp_celsius(E0);
570
-            SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
571
+            const celsius_float_t hotendTargetTemp = getTargetTemp_celsius(E0);
572
+            SEND_PGM_VAL("A1V ", ROUND(hotendTargetTemp));
571 573
           }
572 574
           break;
573 575
 
574 576
           case 2: { // A2 GET HOTBED TEMP
575
-            const float heatedBedActualTemp = getActualTemp_celsius(BED);
576
-            SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
577
+            const celsius_float_t heatedBedActualTemp = getActualTemp_celsius(BED);
578
+            SEND_PGM_VAL("A2V ", ROUND(heatedBedActualTemp));
577 579
           }
578 580
           break;
579 581
 
580 582
           case 3: { // A3 GET HOTBED TARGET TEMP
581
-            const float heatedBedTargetTemp = getTargetTemp_celsius(BED);
582
-            SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
583
+            const celsius_float_t heatedBedTargetTemp = getTargetTemp_celsius(BED);
584
+            SEND_PGM_VAL("A3V ", ROUND(heatedBedTargetTemp));
583 585
           } break;
584 586
 
585 587
           case 4: { // A4 GET FAN SPEED

+ 4
- 4
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp Zobrazit soubor

@@ -33,28 +33,28 @@
33 33
 /**
34 34
  * Formats a temperature string (e.g. "100°C")
35 35
  */
36
-void format_temp(char *str, float t1) {
36
+void format_temp(char *str, const_celsius_float_t t1) {
37 37
   sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
38 38
 }
39 39
 
40 40
 /**
41 41
  * Formats a temperature string for an idle heater (e.g. "100 °C / idle")
42 42
  */
43
-void format_temp_and_idle(char *str, float t1) {
43
+void format_temp_and_idle(char *str, const_celsius_float_t t1) {
44 44
   sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
45 45
 }
46 46
 
47 47
 /**
48 48
  * Formats a temperature string for an active heater (e.g. "100 / 200°C")
49 49
  */
50
-void format_temp_and_temp(char *str, float t1, float t2) {
50
+void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) {
51 51
   sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
52 52
 }
53 53
 
54 54
 /**
55 55
  * Formats a temperature string for a material (e.g. "100°C (PLA)")
56 56
  */
57
-void format_temp_and_material(char *str, float t1, const char *material) {
57
+void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) {
58 58
   sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
59 59
 }
60 60
 

+ 4
- 4
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h Zobrazit soubor

@@ -21,9 +21,9 @@
21 21
 
22 22
 #pragma once
23 23
 
24
-void format_temp(char *str, float t1);
25
-void format_temp_and_idle(char *str, float t1);
26
-void format_temp_and_temp(char *str, float t1, float t2);
27
-void format_temp_and_material(char *str, float t1, const char *material);
24
+void format_temp(char *str, const_celsius_float_t t1);
25
+void format_temp_and_idle(char *str, const_celsius_float_t t1);
26
+void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2);
27
+void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material);
28 28
 void format_position(char *str, float p, uint8_t decimals = 1);
29 29
 void format_position(char *str, float x, float y, float z);

+ 2
- 2
Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp Zobrazit soubor

@@ -595,8 +595,8 @@ void NextionTFT::PanelAction(uint8_t req) {
595 595
 void NextionTFT::UpdateOnChange() {
596 596
   const millis_t ms = millis();
597 597
   static millis_t next_event_ms = 0;
598
-  static float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999,
599
-               last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
598
+  static celsius_float_t last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999,
599
+                         last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
600 600
 
601 601
   // tmppage Temperature
602 602
   if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) {

+ 4
- 4
Marlin/src/lcd/extui/ui_api.cpp Zobrazit soubor

@@ -263,7 +263,7 @@ namespace ExtUI {
263 263
     #define GET_TEMP_ADJUSTMENT(A) A
264 264
   #endif
265 265
 
266
-  float getActualTemp_celsius(const heater_t heater) {
266
+  celsius_float_t getActualTemp_celsius(const heater_t heater) {
267 267
     switch (heater) {
268 268
       #if ENABLED(HAS_HEATED_BED)
269 269
         case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed());
@@ -275,11 +275,11 @@ namespace ExtUI {
275 275
     }
276 276
   }
277 277
 
278
-  float getActualTemp_celsius(const extruder_t extruder) {
278
+  celsius_float_t getActualTemp_celsius(const extruder_t extruder) {
279 279
     return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(extruder - E0));
280 280
   }
281 281
 
282
-  float getTargetTemp_celsius(const heater_t heater) {
282
+  celsius_float_t getTargetTemp_celsius(const heater_t heater) {
283 283
     switch (heater) {
284 284
       #if ENABLED(HAS_HEATED_BED)
285 285
         case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed());
@@ -291,7 +291,7 @@ namespace ExtUI {
291 291
     }
292 292
   }
293 293
 
294
-  float getTargetTemp_celsius(const extruder_t extruder) {
294
+  celsius_float_t getTargetTemp_celsius(const extruder_t extruder) {
295 295
     return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(extruder - E0));
296 296
   }
297 297
 

+ 4
- 4
Marlin/src/lcd/extui/ui_api.h Zobrazit soubor

@@ -109,10 +109,10 @@ namespace ExtUI {
109 109
     void setTMCBumpSensitivity(const_float_t , const axis_t);
110 110
   #endif
111 111
 
112
-  float getActualTemp_celsius(const heater_t);
113
-  float getActualTemp_celsius(const extruder_t);
114
-  float getTargetTemp_celsius(const heater_t);
115
-  float getTargetTemp_celsius(const extruder_t);
112
+  celsius_float_t getActualTemp_celsius(const heater_t);
113
+  celsius_float_t getActualTemp_celsius(const extruder_t);
114
+  celsius_float_t getTargetTemp_celsius(const heater_t);
115
+  celsius_float_t getTargetTemp_celsius(const extruder_t);
116 116
   float getTargetFan_percent(const fan_t);
117 117
   float getActualFan_percent(const fan_t);
118 118
   float getAxisPosition_mm(const axis_t);

+ 4
- 4
Marlin/src/module/probe.cpp Zobrazit soubor

@@ -352,7 +352,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
352 352
    *  - If a preheat input is higher than the current target, raise the target temperature.
353 353
    *  - If a preheat input is higher than the current temperature, wait for stabilization.
354 354
    */
355
-  void Probe::preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp) {
355
+  void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) {
356 356
     #if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
357 357
       #define WAIT_FOR_NOZZLE_HEAT
358 358
     #endif
@@ -363,17 +363,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
363 363
     DEBUG_ECHOPGM("Preheating ");
364 364
 
365 365
     #if ENABLED(WAIT_FOR_NOZZLE_HEAT)
366
-      const int16_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
366
+      const celsius_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
367 367
       if (hotendPreheat) {
368 368
         DEBUG_ECHOPAIR("hotend (", hotendPreheat, ")");
369 369
         thermalManager.setTargetHotend(hotendPreheat, 0);
370 370
       }
371 371
     #elif ENABLED(WAIT_FOR_BED_HEAT)
372
-      constexpr int16_t hotendPreheat = 0;
372
+      constexpr celsius_t hotendPreheat = 0;
373 373
     #endif
374 374
 
375 375
     #if ENABLED(WAIT_FOR_BED_HEAT)
376
-      const int16_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
376
+      const celsius_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
377 377
       if (bedPreheat) {
378 378
         if (hotendPreheat) DEBUG_ECHOPGM(" and ");
379 379
         DEBUG_ECHOPAIR("bed (", bedPreheat, ")");

+ 1
- 1
Marlin/src/module/probe.h Zobrazit soubor

@@ -61,7 +61,7 @@ public:
61 61
     static xyz_pos_t offset;
62 62
 
63 63
     #if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
64
-      static void preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp);
64
+      static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
65 65
     #endif
66 66
 
67 67
     static bool set_deployed(const bool deploy);

+ 29
- 20
Marlin/src/module/temperature.cpp Zobrazit soubor

@@ -382,7 +382,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
382 382
   chamber_info_t Temperature::temp_chamber; // = { 0 }
383 383
   #if HAS_HEATED_CHAMBER
384 384
     millis_t next_cool_check_ms_2 = 0;
385
-    float old_temp = 9999;
385
+    celsius_float_t old_temp = 9999;
386 386
     int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP,
387 387
             Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
388 388
     TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0});
@@ -395,7 +395,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
395 395
   #if HAS_COOLER
396 396
     bool flag_cooler_state;
397 397
     //bool flag_cooler_excess = false;
398
-    float previous_temp = 9999;
398
+    celsius_float_t previous_temp = 9999;
399 399
     int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP,
400 400
             Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
401 401
     #if WATCH_COOLER
@@ -421,8 +421,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
421 421
 #endif
422 422
 
423 423
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
424
-  celsius_t Temperature::redundant_temperature_raw = 0;
425
-  float Temperature::redundant_temperature = 0.0;
424
+  int16_t Temperature::redundant_temperature_raw = 0;
425
+  celsius_float_t Temperature::redundant_temperature = 0.0;
426 426
 #endif
427 427
 
428 428
 volatile bool Temperature::raw_temps_ready = false;
@@ -508,7 +508,7 @@ volatile bool Temperature::raw_temps_ready = false;
508 508
     long t_high = 0, t_low = 0;
509 509
 
510 510
     PID_t tune_pid = { 0, 0, 0 };
511
-    float maxT = 0, minT = 10000;
511
+    celsius_float_t maxT = 0, minT = 10000;
512 512
 
513 513
     const bool isbed = (heater_id == H_BED);
514 514
     const bool ischamber = (heater_id == H_CHAMBER);
@@ -544,9 +544,9 @@ volatile bool Temperature::raw_temps_ready = false;
544 544
       #define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H))
545 545
       const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD);
546 546
       const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE);
547
-      const float watch_temp_target = target - float(watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
547
+      const celsius_float_t watch_temp_target = celsius_float_t(target - watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
548 548
       millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period);
549
-      float next_watch_temp = 0.0;
549
+      celsius_float_t next_watch_temp = 0.0;
550 550
       bool heated = false;
551 551
     #endif
552 552
 
@@ -567,7 +567,7 @@ volatile bool Temperature::raw_temps_ready = false;
567 567
     SHV(bias);
568 568
 
569 569
     #if ENABLED(PRINTER_EVENT_LEDS)
570
-      const float start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius);
570
+      const celsius_float_t start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius);
571 571
       LEDColor color = ONHEATINGSTART();
572 572
     #endif
573 573
 
@@ -2338,7 +2338,7 @@ void Temperature::init() {
2338 2338
    *
2339 2339
    * TODO: Embed the last 3 parameters during init, if not less optimal
2340 2340
    */
2341
-  void Temperature::tr_state_machine_t::run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
2341
+  void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
2342 2342
 
2343 2343
     #if HEATER_IDLE_HANDLER
2344 2344
       // Convert the given heater_id_t to an idle array index
@@ -3373,7 +3373,16 @@ void Temperature::isr() {
3373 3373
 
3374 3374
   #include "../gcode/gcode.h"
3375 3375
 
3376
-  static void print_heater_state(const_float_t c, const_float_t t
3376
+  /**
3377
+   * Print a single heater state in the form:
3378
+   *        Bed: " B:nnn.nn /nnn.nn"
3379
+   *    Chamber: " C:nnn.nn /nnn.nn"
3380
+   *      Probe: " P:nnn.nn /nnn.nn"
3381
+   *     Cooler: " L:nnn.nn /nnn.nn"
3382
+   *   Extruder: " T0:nnn.nn /nnn.nn"
3383
+   *   With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
3384
+   */
3385
+  static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t
3377 3386
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
3378 3387
       , const float r
3379 3388
     #endif
@@ -3557,12 +3566,12 @@ void Temperature::isr() {
3557 3566
       #endif
3558 3567
 
3559 3568
       #if ENABLED(PRINTER_EVENT_LEDS)
3560
-        const float start_temp = degHotend(target_extruder);
3569
+        const celsius_float_t start_temp = degHotend(target_extruder);
3561 3570
         printerEventLEDs.onHotendHeatingStart();
3562 3571
       #endif
3563 3572
 
3564 3573
       bool wants_to_cool = false;
3565
-      float target_temp = -1.0, old_temp = 9999.0;
3574
+      celsius_float_t target_temp = -1.0, old_temp = 9999.0;
3566 3575
       millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
3567 3576
       wait_for_heatup = true;
3568 3577
       do {
@@ -3592,7 +3601,7 @@ void Temperature::isr() {
3592 3601
         idle();
3593 3602
         gcode.reset_stepper_timeout(); // Keep steppers powered
3594 3603
 
3595
-        const float temp = degHotend(target_extruder);
3604
+        const celsius_float_t temp = degHotend(target_extruder);
3596 3605
 
3597 3606
         #if ENABLED(PRINTER_EVENT_LEDS)
3598 3607
           // Gradually change LED strip from violet to red as nozzle heats up
@@ -3601,7 +3610,7 @@ void Temperature::isr() {
3601 3610
 
3602 3611
         #if TEMP_RESIDENCY_TIME > 0
3603 3612
 
3604
-          const float temp_diff = ABS(target_temp - temp);
3613
+          const celsius_float_t temp_diff = ABS(target_temp - temp);
3605 3614
 
3606 3615
           if (!residency_start_ms) {
3607 3616
             // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
@@ -3695,12 +3704,12 @@ void Temperature::isr() {
3695 3704
       #endif
3696 3705
 
3697 3706
       #if ENABLED(PRINTER_EVENT_LEDS)
3698
-        const float start_temp = degBed();
3707
+        const celsius_float_t start_temp = degBed();
3699 3708
         printerEventLEDs.onBedHeatingStart();
3700 3709
       #endif
3701 3710
 
3702 3711
       bool wants_to_cool = false;
3703
-      float target_temp = -1, old_temp = 9999;
3712
+      celsius_float_t target_temp = -1, old_temp = 9999;
3704 3713
       millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
3705 3714
       wait_for_heatup = true;
3706 3715
       do {
@@ -3730,7 +3739,7 @@ void Temperature::isr() {
3730 3739
         idle();
3731 3740
         gcode.reset_stepper_timeout(); // Keep steppers powered
3732 3741
 
3733
-        const float temp = degBed();
3742
+        const celsius_float_t temp = degBed();
3734 3743
 
3735 3744
         #if ENABLED(PRINTER_EVENT_LEDS)
3736 3745
           // Gradually change LED strip from blue to violet as bed heats up
@@ -3739,7 +3748,7 @@ void Temperature::isr() {
3739 3748
 
3740 3749
         #if TEMP_BED_RESIDENCY_TIME > 0
3741 3750
 
3742
-          const float temp_diff = ABS(target_temp - temp);
3751
+          const celsius_float_t temp_diff = ABS(target_temp - temp);
3743 3752
 
3744 3753
           if (!residency_start_ms) {
3745 3754
             // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
@@ -4021,11 +4030,11 @@ void Temperature::isr() {
4021 4030
         idle();
4022 4031
         gcode.reset_stepper_timeout(); // Keep steppers powered
4023 4032
 
4024
-        const float current_temp = degCooler();
4033
+        const celsius_float_t current_temp = degCooler();
4025 4034
 
4026 4035
         #if TEMP_COOLER_RESIDENCY_TIME > 0
4027 4036
 
4028
-          const float temp_diff = ABS(target_temp - temp);
4037
+          const celsius_float_t temp_diff = ABS(target_temp - temp);
4029 4038
 
4030 4039
           if (!residency_start_ms) {
4031 4040
             // Start the TEMP_COOLER_RESIDENCY_TIME timer when we reach target temp for the first time.

+ 1
- 1
Marlin/src/module/temperature.h Zobrazit soubor

@@ -961,7 +961,7 @@ class Temperature {
961 961
         millis_t timer = 0;
962 962
         TRState state = TRInactive;
963 963
         float running_temp;
964
-        void run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
964
+        void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
965 965
       } tr_state_machine_t;
966 966
 
967 967
       static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY];

Loading…
Zrušit
Uložit