|
@@ -377,7 +377,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
377
|
377
|
* Needs sufficient heater power to make some overshoot at target
|
378
|
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
|
381
|
float current_temp = 0.0;
|
382
|
382
|
int cycles = 0;
|
383
|
383
|
bool heating = true;
|
|
@@ -389,11 +389,11 @@ volatile bool Temperature::raw_temps_ready = false;
|
389
|
389
|
PID_t tune_pid = { 0, 0, 0 };
|
390
|
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
|
394
|
#if HAS_PID_FOR_BOTH
|
395
|
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
|
397
|
#define ONHEATINGSTART() (isbed ? printerEventLEDs.onBedHeatingStart() : printerEventLEDs.onHotendHeatingStart())
|
398
|
398
|
#define ONHEATING(S,C,T) (isbed ? printerEventLEDs.onBedHeating(S,C,T) : printerEventLEDs.onHotendHeating(S,C,T))
|
399
|
399
|
#elif ENABLED(PIDTEMPBED)
|
|
@@ -403,7 +403,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
403
|
403
|
#define ONHEATING(S,C,T) printerEventLEDs.onBedHeating(S,C,T)
|
404
|
404
|
#else
|
405
|
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
|
407
|
#define ONHEATINGSTART() printerEventLEDs.onHotendHeatingStart()
|
408
|
408
|
#define ONHEATING(S,C,T) printerEventLEDs.onHotendHeating(S,C,T)
|
409
|
409
|
#endif
|
|
@@ -427,7 +427,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
427
|
427
|
|
428
|
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
|
431
|
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
|
432
|
432
|
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
|
433
|
433
|
return;
|
|
@@ -441,7 +441,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
441
|
441
|
SHV(bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
|
442
|
442
|
|
443
|
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
|
445
|
LEDColor color = ONHEATINGSTART();
|
446
|
446
|
#endif
|
447
|
447
|
|
|
@@ -457,7 +457,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
457
|
457
|
updateTemperaturesFromRawValues();
|
458
|
458
|
|
459
|
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
|
461
|
NOLESS(maxT, current_temp);
|
462
|
462
|
NOMORE(minT, current_temp);
|
463
|
463
|
|
|
@@ -549,7 +549,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
549
|
549
|
// Report heater states every 2 seconds
|
550
|
550
|
if (ELAPSED(ms, next_temp_ms)) {
|
551
|
551
|
#if HAS_TEMP_SENSOR
|
552
|
|
- print_heater_states(isbed ? active_extruder : heater);
|
|
552
|
+ print_heater_states(isbed ? active_extruder : heater_id);
|
553
|
553
|
SERIAL_EOL();
|
554
|
554
|
#endif
|
555
|
555
|
next_temp_ms = ms + 2000UL;
|
|
@@ -564,10 +564,10 @@ volatile bool Temperature::raw_temps_ready = false;
|
564
|
564
|
if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached
|
565
|
565
|
}
|
566
|
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
|
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
|
572
|
#endif
|
573
|
573
|
} // every 2 seconds
|
|
@@ -608,9 +608,9 @@ volatile bool Temperature::raw_temps_ready = false;
|
608
|
608
|
}while(0)
|
609
|
609
|
|
610
|
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
|
614
|
updatePID(); }while(0)
|
615
|
615
|
|
616
|
616
|
// Use the result? (As with "M303 U1")
|
|
@@ -651,7 +651,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
651
|
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
|
655
|
switch (heater_id) {
|
656
|
656
|
#if HAS_HEATED_BED
|
657
|
657
|
case H_BED: return temp_bed.soft_pwm_amount;
|
|
@@ -758,7 +758,7 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
|
758
|
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
|
762
|
marlin_state = MF_KILLED;
|
763
|
763
|
#if USE_BEEPER
|
764
|
764
|
for (uint8_t i = 20; i--;) {
|
|
@@ -767,10 +767,10 @@ inline void loud_kill(PGM_P const lcd_msg, const heater_ind_t heater) {
|
767
|
767
|
}
|
768
|
768
|
WRITE(BEEPER_PIN, HIGH);
|
769
|
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
|
775
|
static uint8_t killed = 0;
|
776
|
776
|
|
|
@@ -778,9 +778,9 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg,
|
778
|
778
|
SERIAL_ERROR_START();
|
779
|
779
|
serialprintPGM(serial_msg);
|
780
|
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
|
784
|
SERIAL_ECHOPGM(STR_HEATER_CHAMBER);
|
785
|
785
|
else
|
786
|
786
|
SERIAL_ECHOPGM(STR_HEATER_BED);
|
|
@@ -801,25 +801,25 @@ void Temperature::_temp_error(const heater_ind_t heater, PGM_P const serial_msg,
|
801
|
801
|
if (ELAPSED(ms, expire_ms)) ++killed;
|
802
|
802
|
break;
|
803
|
803
|
case 2:
|
804
|
|
- loud_kill(lcd_msg, heater);
|
|
804
|
+ loud_kill(lcd_msg, heater_id);
|
805
|
805
|
++killed;
|
806
|
806
|
break;
|
807
|
807
|
}
|
808
|
808
|
#elif defined(BOGUS_TEMPERATURE_GRACE_PERIOD)
|
809
|
809
|
UNUSED(killed);
|
810
|
810
|
#else
|
811
|
|
- if (!killed) { killed = 1; loud_kill(lcd_msg, heater); }
|
|
811
|
+ if (!killed) { killed = 1; loud_kill(lcd_msg, heater_id); }
|
812
|
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
|
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
|
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
|
825
|
#if HAS_HOTEND
|
|
@@ -1041,14 +1041,14 @@ void Temperature::manage_heater() {
|
1041
|
1041
|
HOTEND_LOOP() {
|
1042
|
1042
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
1043
|
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
|
1045
|
#endif
|
1046
|
1046
|
|
1047
|
1047
|
TERN_(HEATER_IDLE_HANDLER, hotend_idle[e].update(ms));
|
1048
|
1048
|
|
1049
|
1049
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
1050
|
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
|
1052
|
#endif
|
1053
|
1053
|
|
1054
|
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,7 +1058,7 @@ void Temperature::manage_heater() {
|
1058
|
1058
|
if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder?
|
1059
|
1059
|
if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough?
|
1060
|
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
|
1063
|
else // Start again if the target is still far off
|
1064
|
1064
|
start_watching_hotend(e);
|
|
@@ -1945,7 +1945,7 @@ void Temperature::init() {
|
1945
|
1945
|
Temperature::tr_state_machine_t Temperature::tr_state_machine_chamber; // = { TRInactive, 0 };
|
1946
|
1946
|
#endif
|
1947
|
1947
|
|
1948
|
|
- void Temperature::thermal_runaway_protection(Temperature::tr_state_machine_t &sm, const float ¤t, 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 ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
|
1949
|
1949
|
|
1950
|
1950
|
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
|
1951
|
1951
|
|
|
@@ -2311,12 +2311,12 @@ void Temperature::readings_ready() {
|
2311
|
2311
|
const bool heater_on = (temp_hotend[e].target > 0
|
2312
|
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
|
2315
|
if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) {
|
2316
|
2316
|
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
2317
|
2317
|
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
|
2318
|
2318
|
#endif
|
2319
|
|
- min_temp_error((heater_ind_t)e);
|
|
2319
|
+ min_temp_error((heater_id_t)e);
|
2320
|
2320
|
}
|
2321
|
2321
|
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
|
2322
|
2322
|
else
|
|
@@ -2883,7 +2883,7 @@ void Temperature::tick() {
|
2883
|
2883
|
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
2884
|
2884
|
, const float r
|
2885
|
2885
|
#endif
|
2886
|
|
- , const heater_ind_t e=INDEX_NONE
|
|
2886
|
+ , const heater_id_t e=INDEX_NONE
|
2887
|
2887
|
) {
|
2888
|
2888
|
char k;
|
2889
|
2889
|
switch (e) {
|
|
@@ -2974,10 +2974,10 @@ void Temperature::tick() {
|
2974
|
2974
|
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
2975
|
2975
|
, rawHotendTemp(e)
|
2976
|
2976
|
#endif
|
2977
|
|
- , (heater_ind_t)e
|
|
2977
|
+ , (heater_id_t)e
|
2978
|
2978
|
);
|
2979
|
2979
|
#endif
|
2980
|
|
- SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_ind_t)target_extruder));
|
|
2980
|
+ SERIAL_ECHOPAIR(" @:", getHeaterPower((heater_id_t)target_extruder));
|
2981
|
2981
|
#if HAS_HEATED_BED
|
2982
|
2982
|
SERIAL_ECHOPAIR(" B@:", getHeaterPower(H_BED));
|
2983
|
2983
|
#endif
|
|
@@ -2988,7 +2988,7 @@ void Temperature::tick() {
|
2988
|
2988
|
HOTEND_LOOP() {
|
2989
|
2989
|
SERIAL_ECHOPAIR(" @", e);
|
2990
|
2990
|
SERIAL_CHAR(':');
|
2991
|
|
- SERIAL_ECHO(getHeaterPower((heater_ind_t)e));
|
|
2991
|
+ SERIAL_ECHO(getHeaterPower((heater_id_t)e));
|
2992
|
2992
|
}
|
2993
|
2993
|
#endif
|
2994
|
2994
|
}
|