Bläddra i källkod

heater_ind_t => heater_id_t

Scott Lahteine 4 år sedan
förälder
incheckning
49ca16c3fb

+ 1
- 1
Marlin/src/gcode/temp/M303.cpp Visa fil

62
 
62
 
63
   #define SI TERN(PIDTEMPBED, H_BED, H_E0)
63
   #define SI TERN(PIDTEMPBED, H_BED, H_E0)
64
   #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
64
   #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
65
-  const heater_ind_t e = (heater_ind_t)parser.intval('E');
65
+  const heater_id_t e = (heater_id_t)parser.intval('E');
66
   if (!WITHIN(e, SI, EI)) {
66
   if (!WITHIN(e, SI, EI)) {
67
     SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
67
     SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
68
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
68
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));

+ 7
- 7
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp Visa fil

519
   }
519
   }
520
 }
520
 }
521
 
521
 
522
-FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const char prefix, const bool blink) {
522
+FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
523
   #if HAS_HEATED_BED
523
   #if HAS_HEATED_BED
524
-    const bool isBed = heater < 0;
525
-    const float t1 = (isBed ? thermalManager.degBed()       : thermalManager.degHotend(heater)),
526
-                t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater));
524
+    const bool isBed = heater_id < 0;
525
+    const float t1 = (isBed ? thermalManager.degBed()       : thermalManager.degHotend(heater_id)),
526
+                t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
527
   #else
527
   #else
528
-    const float t1 = thermalManager.degHotend(heater), t2 = thermalManager.degTargetHotend(heater);
528
+    const float t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
529
   #endif
529
   #endif
530
 
530
 
531
   if (prefix >= 0) lcd_put_wchar(prefix);
531
   if (prefix >= 0) lcd_put_wchar(prefix);
540
       #if HAS_HEATED_BED
540
       #if HAS_HEATED_BED
541
         isBed ? thermalManager.bed_idle.timed_out :
541
         isBed ? thermalManager.bed_idle.timed_out :
542
       #endif
542
       #endif
543
-      thermalManager.hotend_idle[heater].timed_out
543
+      thermalManager.hotend_idle[heater_id].timed_out
544
     );
544
     );
545
 
545
 
546
     if (!blink && is_idle) {
546
     if (!blink && is_idle) {
990
     void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
990
     void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
991
       if (row < LCD_HEIGHT) {
991
       if (row < LCD_HEIGHT) {
992
         lcd_moveto(LCD_WIDTH - 9, row);
992
         lcd_moveto(LCD_WIDTH - 9, row);
993
-        _draw_heater_status((heater_ind_t)extruder, LCD_STR_THERMOMETER[0], get_blink());
993
+        _draw_heater_status((heater_id_t)extruder, LCD_STR_THERMOMETER[0], get_blink());
994
       }
994
       }
995
     }
995
     }
996
 
996
 

+ 12
- 12
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Visa fil

178
 #if DO_DRAW_HOTENDS
178
 #if DO_DRAW_HOTENDS
179
 
179
 
180
   // Draw hotend bitmap with current and target temperatures
180
   // Draw hotend bitmap with current and target temperatures
181
-  FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
181
+  FORCE_INLINE void _draw_hotend_status(const heater_id_t heater_id, const bool blink) {
182
     #if !HEATER_IDLE_HANDLER
182
     #if !HEATER_IDLE_HANDLER
183
       UNUSED(blink);
183
       UNUSED(blink);
184
     #endif
184
     #endif
185
 
185
 
186
-    const bool isHeat = HOTEND_ALT(heater);
186
+    const bool isHeat = HOTEND_ALT(heater_id);
187
 
187
 
188
-    const uint8_t tx = STATUS_HOTEND_TEXT_X(heater);
188
+    const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id);
189
 
189
 
190
-    const float temp = thermalManager.degHotend(heater),
191
-              target = thermalManager.degTargetHotend(heater);
190
+    const float temp = thermalManager.degHotend(heater_id),
191
+              target = thermalManager.degTargetHotend(heater_id);
192
 
192
 
193
     #if DISABLED(STATUS_HOTEND_ANIM)
193
     #if DISABLED(STATUS_HOTEND_ANIM)
194
       #define STATIC_HOTEND true
194
       #define STATIC_HOTEND true
237
 
237
 
238
       #if ANIM_HOTEND
238
       #if ANIM_HOTEND
239
         // Draw hotend bitmap, either whole or split by the heating percent
239
         // Draw hotend bitmap, either whole or split by the heating percent
240
-        const uint8_t hx = STATUS_HOTEND_X(heater),
241
-                      bw = STATUS_HOTEND_BYTEWIDTH(heater);
240
+        const uint8_t hx = STATUS_HOTEND_X(heater_id),
241
+                      bw = STATUS_HOTEND_BYTEWIDTH(heater_id);
242
         #if ENABLED(STATUS_HEAT_PERCENT)
242
         #if ENABLED(STATUS_HEAT_PERCENT)
243
           if (isHeat && tall <= BAR_TALL) {
243
           if (isHeat && tall <= BAR_TALL) {
244
             const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
244
             const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
245
-            u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater, false));
246
-            u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater, true) + ph * bw);
245
+            u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater_id, false));
246
+            u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater_id, true) + ph * bw);
247
           }
247
           }
248
           else
248
           else
249
         #endif
249
         #endif
250
-            u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat));
250
+            u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater_id, isHeat));
251
       #endif
251
       #endif
252
 
252
 
253
     } // PAGE_CONTAINS
253
     } // PAGE_CONTAINS
254
 
254
 
255
     if (PAGE_UNDER(7)) {
255
     if (PAGE_UNDER(7)) {
256
       #if HEATER_IDLE_HANDLER
256
       #if HEATER_IDLE_HANDLER
257
-        const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out);
257
+        const bool dodraw = (blink || !thermalManager.hotend_idle[heater_id].timed_out);
258
       #else
258
       #else
259
         constexpr bool dodraw = true;
259
         constexpr bool dodraw = true;
260
       #endif
260
       #endif
597
     // Extruders
597
     // Extruders
598
     #if DO_DRAW_HOTENDS
598
     #if DO_DRAW_HOTENDS
599
       LOOP_L_N(e, MAX_HOTEND_DRAW)
599
       LOOP_L_N(e, MAX_HOTEND_DRAW)
600
-        _draw_hotend_status((heater_ind_t)e, blink);
600
+        _draw_hotend_status((heater_id_t)e, blink);
601
     #endif
601
     #endif
602
 
602
 
603
     // Laser / Spindle
603
     // Laser / Spindle

+ 1
- 1
Marlin/src/lcd/extui/ui_api.cpp Visa fil

868
     }
868
     }
869
 
869
 
870
     void startPIDTune(const float temp, extruder_t tool) {
870
     void startPIDTune(const float temp, extruder_t tool) {
871
-      thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true);
871
+      thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true);
872
     }
872
     }
873
   #endif
873
   #endif
874
 
874
 

+ 36
- 36
Marlin/src/module/temperature.cpp Visa fil

377
    * Needs sufficient heater power to make some overshoot at target
377
    * Needs sufficient heater power to make some overshoot at target
378
    * temperature to succeed.
378
    * temperature to succeed.
379
    */
379
    */
380
-  void Temperature::PID_autotune(const float &target, const heater_ind_t heater, const int8_t ncycles, const bool set_result/*=false*/) {
380
+  void Temperature::PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) {
381
     float current_temp = 0.0;
381
     float current_temp = 0.0;
382
     int cycles = 0;
382
     int cycles = 0;
383
     bool heating = true;
383
     bool heating = true;
389
     PID_t tune_pid = { 0, 0, 0 };
389
     PID_t tune_pid = { 0, 0, 0 };
390
     float maxT = 0, minT = 10000;
390
     float maxT = 0, minT = 10000;
391
 
391
 
392
-    const bool isbed = (heater == H_BED);
392
+    const bool isbed = (heater_id == H_BED);
393
 
393
 
394
     #if HAS_PID_FOR_BOTH
394
     #if HAS_PID_FOR_BOTH
395
       #define GHV(B,H) (isbed ? (B) : (H))
395
       #define GHV(B,H) (isbed ? (B) : (H))
396
-      #define SHV(B,H) do{ if (isbed) temp_bed.soft_pwm_amount = B; else temp_hotend[heater].soft_pwm_amount = H; }while(0)
396
+      #define SHV(B,H) do{ if (isbed) temp_bed.soft_pwm_amount = B; else temp_hotend[heater_id].soft_pwm_amount = H; }while(0)
397
       #define ONHEATINGSTART() (isbed ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart())
397
       #define ONHEATINGSTART() (isbed ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart())
398
       #define ONHEATING(S,C,T) (isbed ? printerEventLEDs.onBedHeating(S,C,T) : printerEventLEDs.onHotendHeating(S,C,T))
398
       #define ONHEATING(S,C,T) (isbed ? printerEventLEDs.onBedHeating(S,C,T) : printerEventLEDs.onHotendHeating(S,C,T))
399
     #elif ENABLED(PIDTEMPBED)
399
     #elif ENABLED(PIDTEMPBED)
403
       #define ONHEATING(S,C,T) printerEventLEDs.onBedHeating(S,C,T)
403
       #define ONHEATING(S,C,T) printerEventLEDs.onBedHeating(S,C,T)
404
     #else
404
     #else
405
       #define GHV(B,H) H
405
       #define GHV(B,H) H
406
-      #define SHV(B,H) (temp_hotend[heater].soft_pwm_amount = H)
406
+      #define SHV(B,H) (temp_hotend[heater_id].soft_pwm_amount = H)
407
       #define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart()
407
       #define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart()
408
       #define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T)
408
       #define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T)
409
     #endif
409
     #endif
427
 
427
 
428
     TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL);
428
     TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL);
429
 
429
 
430
-    if (target > GHV(BED_MAX_TARGET, temp_range[heater].maxtemp - HOTEND_OVERSHOOT)) {
430
+    if (target > GHV(BED_MAX_TARGET, temp_range[heater_id].maxtemp - HOTEND_OVERSHOOT)) {
431
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
431
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
432
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
432
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
433
       return;
433
       return;
441
     SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
441
     SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
442
 
442
 
443
     #if ENABLED(PRINTER_EVENT_LEDS)
443
     #if ENABLED(PRINTER_EVENT_LEDS)
444
-      const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
444
+      const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater_id].celsius);
445
       LEDColor color = ONHEATINGSTART();
445
       LEDColor color = ONHEATINGSTART();
446
     #endif
446
     #endif
447
 
447
 
457
         updateTemperaturesFromRawValues();
457
         updateTemperaturesFromRawValues();
458
 
458
 
459
         // Get the current temperature and constrain it
459
         // Get the current temperature and constrain it
460
-        current_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
460
+        current_temp = GHV(temp_bed.celsius, temp_hotend[heater_id].celsius);
461
         NOLESS(maxT, current_temp);
461
         NOLESS(maxT, current_temp);
462
         NOMORE(minT, current_temp);
462
         NOMORE(minT, current_temp);
463
 
463
 
549
       // Report heater states every 2 seconds
549
       // Report heater states every 2 seconds
550
       if (ELAPSED(ms, next_temp_ms)) {
550
       if (ELAPSED(ms, next_temp_ms)) {
551
         #if HAS_TEMP_SENSOR
551
         #if HAS_TEMP_SENSOR
552
-          print_heater_states(isbed ? active_extruder : heater);
552
+          print_heater_states(isbed ? active_extruder : heater_id);
553
           SERIAL_EOL();
553
           SERIAL_EOL();
554
         #endif
554
         #endif
555
         next_temp_ms = ms + 2000UL;
555
         next_temp_ms = ms + 2000UL;
564
                 if (current_temp > watch_temp_target) heated = true;  // - Flag if target temperature reached
564
                 if (current_temp > watch_temp_target) heated = true;  // - Flag if target temperature reached
565
               }
565
               }
566
               else if (ELAPSED(ms, temp_change_ms))                   // Watch timer expired
566
               else if (ELAPSED(ms, temp_change_ms))                   // Watch timer expired
567
-                _temp_error(heater, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
567
+                _temp_error(heater_id, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
568
             }
568
             }
569
             else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
569
             else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
570
-              _temp_error(heater, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
570
+              _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
571
           }
571
           }
572
         #endif
572
         #endif
573
       } // every 2 seconds
573
       } // every 2 seconds
608
         }while(0)
608
         }while(0)
609
 
609
 
610
         #define _SET_EXTRUDER_PID() do { \
610
         #define _SET_EXTRUDER_PID() do { \
611
-          PID_PARAM(Kp, heater) = tune_pid.Kp; \
612
-          PID_PARAM(Ki, heater) = scalePID_i(tune_pid.Ki); \
613
-          PID_PARAM(Kd, heater) = scalePID_d(tune_pid.Kd); \
611
+          PID_PARAM(Kp, heater_id) = tune_pid.Kp; \
612
+          PID_PARAM(Ki, heater_id) = scalePID_i(tune_pid.Ki); \
613
+          PID_PARAM(Kd, heater_id) = scalePID_d(tune_pid.Kd); \
614
           updatePID(); }while(0)
614
           updatePID(); }while(0)
615
 
615
 
616
         // Use the result? (As with "M303 U1")
616
         // Use the result? (As with "M303 U1")
651
  * Class and Instance Methods
651
  * Class and Instance Methods
652
  */
652
  */
653
 
653
 
654
-int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
654
+int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
655
   switch (heater_id) {
655
   switch (heater_id) {
656
     #if HAS_HEATED_BED
656
     #if HAS_HEATED_BED
657
       case H_BED: return temp_bed.soft_pwm_amount;
657
       case H_BED: return temp_bed.soft_pwm_amount;
758
 // Temperature Error Handlers
758
 // Temperature Error Handlers
759
 //
759
 //
760
 
760
 
761
-inline void loud_kill(PGM_P const lcd_msg, const heater_ind_t heater) {
761
+inline void loud_kill(PGM_P const lcd_msg, const heater_id_t heater_id) {
762
   marlin_state = MF_KILLED;
762
   marlin_state = MF_KILLED;
763
   #if USE_BEEPER
763
   #if USE_BEEPER
764
     for (uint8_t i = 20; i--;) {
764
     for (uint8_t i = 20; i--;) {
767
     }
767
     }
768
     WRITE(BEEPER_PIN, HIGH);
768
     WRITE(BEEPER_PIN, HIGH);
769
   #endif
769
   #endif
770
-  kill(lcd_msg, HEATER_PSTR(heater));
770
+  kill(lcd_msg, HEATER_PSTR(heater_id));
771
 }
771
 }
772
 
772
 
773
-void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg, PGM_P const lcd_msg) {
773
+void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_msg, PGM_P const lcd_msg) {
774
 
774
 
775
   static uint8_t killed = 0;
775
   static uint8_t killed = 0;
776
 
776
 
778
     SERIAL_ERROR_START();
778
     SERIAL_ERROR_START();
779
     serialprintPGM(serial_msg);
779
     serialprintPGM(serial_msg);
780
     SERIAL_ECHOPGM(STR_STOPPED_HEATER);
780
     SERIAL_ECHOPGM(STR_STOPPED_HEATER);
781
-    if (heater >= 0)
782
-      SERIAL_ECHO((int)heater);
783
-    else if (TERN0(HAS_HEATED_CHAMBER, heater == H_CHAMBER))
781
+    if (heater_id >= 0)
782
+      SERIAL_ECHO((int)heater_id);
783
+    else if (TERN0(HAS_HEATED_CHAMBER, heater_id == H_CHAMBER))
784
       SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
784
       SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
785
     else
785
     else
786
       SERIAL_ECHOPGM(STR_HEATER_BED);
786
       SERIAL_ECHOPGM(STR_HEATER_BED);
801
         if (ELAPSED(ms, expire_ms)) ++killed;
801
         if (ELAPSED(ms, expire_ms)) ++killed;
802
         break;
802
         break;
803
       case 2:
803
       case 2:
804
-        loud_kill(lcd_msg, heater);
804
+        loud_kill(lcd_msg, heater_id);
805
         ++killed;
805
         ++killed;
806
         break;
806
         break;
807
     }
807
     }
808
   #elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD)
808
   #elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD)
809
     UNUSED(killed);
809
     UNUSED(killed);
810
   #else
810
   #else
811
-    if (!killed) { killed = 1; loud_kill(lcd_msg, heater); }
811
+    if (!killed) { killed = 1; loud_kill(lcd_msg, heater_id); }
812
   #endif
812
   #endif
813
 }
813
 }
814
 
814
 
815
-void Temperature::max_temp_error(const heater_ind_t heater) {
815
+void Temperature::max_temp_error(const heater_id_t heater_id) {
816
   TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1));
816
   TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1));
817
-  _temp_error(heater, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP));
817
+  _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP));
818
 }
818
 }
819
 
819
 
820
-void Temperature::min_temp_error(const heater_ind_t heater) {
820
+void Temperature::min_temp_error(const heater_id_t heater_id) {
821
   TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
821
   TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
822
-  _temp_error(heater, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP));
822
+  _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP));
823
 }
823
 }
824
 
824
 
825
 #if HAS_HOTEND
825
 #if HAS_HOTEND
1041
     HOTEND_LOOP() {
1041
     HOTEND_LOOP() {
1042
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1042
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1043
         if (degHotend(e) > temp_range[e].maxtemp)
1043
         if (degHotend(e) > temp_range[e].maxtemp)
1044
-          _temp_error((heater_ind_t)e, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
1044
+          _temp_error((heater_id_t)e, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
1045
       #endif
1045
       #endif
1046
 
1046
 
1047
       TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms));
1047
       TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms));
1048
 
1048
 
1049
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1049
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1050
         // Check for thermal runaway
1050
         // Check for thermal runaway
1051
-        thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
1051
+        thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_id_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
1052
       #endif
1052
       #endif
1053
 
1053
 
1054
       temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
1054
       temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
1058
         if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) {  // Time to check this extruder?
1058
         if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) {  // Time to check this extruder?
1059
           if (degHotend(e) < watch_hotend[e].target) {                          // Failed to increase enough?
1059
           if (degHotend(e) < watch_hotend[e].target) {                          // Failed to increase enough?
1060
             TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
1060
             TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0));
1061
-            _temp_error((heater_ind_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1061
+            _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1062
           }
1062
           }
1063
           else                                                                  // Start again if the target is still far off
1063
           else                                                                  // Start again if the target is still far off
1064
             start_watching_hotend(e);
1064
             start_watching_hotend(e);
1945
     Temperature::tr_state_machine_t Temperature::tr_state_machine_chamber; // = { TRInactive, 0 };
1945
     Temperature::tr_state_machine_t Temperature::tr_state_machine_chamber; // = { TRInactive, 0 };
1946
   #endif
1946
   #endif
1947
 
1947
 
1948
-  void Temperature::thermal_runaway_protection(Temperature::tr_state_machine_t &sm, const float &current, const float &target, const heater_ind_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
1948
+  void Temperature::thermal_runaway_protection(Temperature::tr_state_machine_t &sm, const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
1949
 
1949
 
1950
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1950
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1951
 
1951
 
2311
         const bool heater_on = (temp_hotend[e].target > 0
2311
         const bool heater_on = (temp_hotend[e].target > 0
2312
           || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0
2312
           || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0
2313
         );
2313
         );
2314
-        if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_ind_t)e);
2314
+        if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e);
2315
         if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
2315
         if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
2316
           #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2316
           #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2317
             if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
2317
             if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
2318
           #endif
2318
           #endif
2319
-              min_temp_error((heater_ind_t)e);
2319
+              min_temp_error((heater_id_t)e);
2320
         }
2320
         }
2321
         #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2321
         #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
2322
           else
2322
           else
2883
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2883
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2884
       , const float r
2884
       , const float r
2885
     #endif
2885
     #endif
2886
-    , const heater_ind_t e=INDEX_NONE
2886
+    , const heater_id_t e=INDEX_NONE
2887
   ) {
2887
   ) {
2888
     char k;
2888
     char k;
2889
     switch (e) {
2889
     switch (e) {
2974
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2974
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2975
           , rawHotendTemp(e)
2975
           , rawHotendTemp(e)
2976
         #endif
2976
         #endif
2977
-        , (heater_ind_t)e
2977
+        , (heater_id_t)e
2978
       );
2978
       );
2979
     #endif
2979
     #endif
2980
-    SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_ind_t)target_extruder));
2980
+    SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
2981
     #if HAS_HEATED_BED
2981
     #if HAS_HEATED_BED
2982
       SERIAL_ECHOPAIR(" B@:", getHeaterPower(H_BED));
2982
       SERIAL_ECHOPAIR(" B@:", getHeaterPower(H_BED));
2983
     #endif
2983
     #endif
2988
       HOTEND_LOOP() {
2988
       HOTEND_LOOP() {
2989
         SERIAL_ECHOPAIR(" @", e);
2989
         SERIAL_ECHOPAIR(" @", e);
2990
         SERIAL_CHAR(':');
2990
         SERIAL_CHAR(':');
2991
-        SERIAL_ECHO(getHeaterPower((heater_ind_t)e));
2991
+        SERIAL_ECHO(getHeaterPower((heater_id_t)e));
2992
       }
2992
       }
2993
     #endif
2993
     #endif
2994
   }
2994
   }

+ 7
- 7
Marlin/src/module/temperature.h Visa fil

45
   INDEX_NONE = -5,
45
   INDEX_NONE = -5,
46
   H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
46
   H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED,
47
   H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
47
   H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7
48
-} heater_ind_t;
48
+} heater_id_t;
49
 
49
 
50
 // PID storage
50
 // PID storage
51
 typedef struct { float Kp, Ki, Kd;     } PID_t;
51
 typedef struct { float Kp, Ki, Kd;     } PID_t;
701
     /**
701
     /**
702
      * The software PWM power for a heater
702
      * The software PWM power for a heater
703
      */
703
      */
704
-    static int16_t getHeaterPower(const heater_ind_t heater);
704
+    static int16_t getHeaterPower(const heater_id_t heater_id);
705
 
705
 
706
     /**
706
     /**
707
      * Switch off all heaters, set all target temperatures to 0
707
      * Switch off all heaters, set all target temperatures to 0
720
      * Perform auto-tuning for hotend or bed in response to M303
720
      * Perform auto-tuning for hotend or bed in response to M303
721
      */
721
      */
722
     #if HAS_PID_HEATING
722
     #if HAS_PID_HEATING
723
-      static void PID_autotune(const float &target, const heater_ind_t hotend, const int8_t ncycles, const bool set_result=false);
723
+      static void PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false);
724
 
724
 
725
       #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
725
       #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
726
         static bool adaptive_fan_slowing;
726
         static bool adaptive_fan_slowing;
811
 
811
 
812
     TERN_(HAS_HEATED_CHAMBER, static float get_pid_output_chamber());
812
     TERN_(HAS_HEATED_CHAMBER, static float get_pid_output_chamber());
813
 
813
 
814
-    static void _temp_error(const heater_ind_t e, PGM_P const serial_msg, PGM_P const lcd_msg);
815
-    static void min_temp_error(const heater_ind_t e);
816
-    static void max_temp_error(const heater_ind_t e);
814
+    static void _temp_error(const heater_id_t e, PGM_P const serial_msg, PGM_P const lcd_msg);
815
+    static void min_temp_error(const heater_id_t e);
816
+    static void max_temp_error(const heater_id_t e);
817
 
817
 
818
     #define HAS_THERMAL_PROTECTION (EITHER(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER) || HAS_THERMALLY_PROTECTED_BED)
818
     #define HAS_THERMAL_PROTECTION (EITHER(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER) || HAS_THERMALLY_PROTECTED_BED)
819
 
819
 
830
       TERN_(HAS_THERMALLY_PROTECTED_BED, static tr_state_machine_t tr_state_machine_bed);
830
       TERN_(HAS_THERMALLY_PROTECTED_BED, static tr_state_machine_t tr_state_machine_bed);
831
       TERN_(THERMAL_PROTECTION_CHAMBER, static tr_state_machine_t tr_state_machine_chamber);
831
       TERN_(THERMAL_PROTECTION_CHAMBER, static tr_state_machine_t tr_state_machine_chamber);
832
 
832
 
833
-      static void thermal_runaway_protection(tr_state_machine_t &state, const float &current, const float &target, const heater_ind_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
833
+      static void thermal_runaway_protection(tr_state_machine_t &state, const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc);
834
 
834
 
835
     #endif // HAS_THERMAL_PROTECTION
835
     #endif // HAS_THERMAL_PROTECTION
836
 };
836
 };

Laddar…
Avbryt
Spara