|
@@ -59,6 +59,24 @@
|
59
|
59
|
|
60
|
60
|
Temperature thermalManager;
|
61
|
61
|
|
|
62
|
+/**
|
|
63
|
+ * Macros to include the heater id in temp errors. The compiler's dead-code
|
|
64
|
+ * elimination should (hopefully) optimize out the unused strings.
|
|
65
|
+ */
|
|
66
|
+#if HAS_TEMP_BED
|
|
67
|
+ #define _BED_ERR_PSTR(MSG, E) (E) == -1 ? PSTR(MSG ## _BED) :
|
|
68
|
+#else
|
|
69
|
+ #define _BED_ERR_PSTR(MSG, E)
|
|
70
|
+#endif
|
|
71
|
+
|
|
72
|
+#define TEMP_ERR_PSTR(MSG, E) \
|
|
73
|
+ _BED_ERR_PSTR(MSG, E) \
|
|
74
|
+ (HOTENDS > 1 && (E) == 1) ? PSTR(MSG_E2 " " MSG) : \
|
|
75
|
+ (HOTENDS > 2 && (E) == 2) ? PSTR(MSG_E3 " " MSG) : \
|
|
76
|
+ (HOTENDS > 3 && (E) == 3) ? PSTR(MSG_E4 " " MSG) : \
|
|
77
|
+ (HOTENDS > 4 && (E) == 4) ? PSTR(MSG_E5 " " MSG) : \
|
|
78
|
+ PSTR(MSG_E1 " " MSG)
|
|
79
|
+
|
62
|
80
|
// public:
|
63
|
81
|
|
64
|
82
|
float Temperature::current_temperature[HOTENDS] = { 0.0 },
|
|
@@ -447,12 +465,10 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
447
|
465
|
if (current > watch_temp_target) heated = true; // - Flag if target temperature reached
|
448
|
466
|
}
|
449
|
467
|
else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired
|
450
|
|
- _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
|
468
|
+ _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, hotend));
|
451
|
469
|
}
|
452
|
470
|
else if (current < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
|
453
|
|
- _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY),
|
454
|
|
- hotend >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED)
|
455
|
|
- );
|
|
471
|
+ _temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, hotend));
|
456
|
472
|
}
|
457
|
473
|
#endif
|
458
|
474
|
} // every 2 seconds
|
|
@@ -591,24 +607,10 @@ void Temperature::_temp_error(const int8_t e, const char * const serial_msg, con
|
591
|
607
|
}
|
592
|
608
|
|
593
|
609
|
void Temperature::max_temp_error(const int8_t e) {
|
594
|
|
- #if HAS_TEMP_BED
|
595
|
|
- _temp_error(e, PSTR(MSG_T_MAXTEMP), e >= 0 ? PSTR(MSG_ERR_MAXTEMP) : PSTR(MSG_ERR_MAXTEMP_BED));
|
596
|
|
- #else
|
597
|
|
- _temp_error(HOTEND_INDEX, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP));
|
598
|
|
- #if HOTENDS == 1
|
599
|
|
- UNUSED(e);
|
600
|
|
- #endif
|
601
|
|
- #endif
|
|
610
|
+ _temp_error(e, PSTR(MSG_T_MAXTEMP), TEMP_ERR_PSTR(MSG_ERR_MAXTEMP, e));
|
602
|
611
|
}
|
603
|
612
|
void Temperature::min_temp_error(const int8_t e) {
|
604
|
|
- #if HAS_TEMP_BED
|
605
|
|
- _temp_error(e, PSTR(MSG_T_MINTEMP), e >= 0 ? PSTR(MSG_ERR_MINTEMP) : PSTR(MSG_ERR_MINTEMP_BED));
|
606
|
|
- #else
|
607
|
|
- _temp_error(HOTEND_INDEX, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP));
|
608
|
|
- #if HOTENDS == 1
|
609
|
|
- UNUSED(e);
|
610
|
|
- #endif
|
611
|
|
- #endif
|
|
613
|
+ _temp_error(e, PSTR(MSG_T_MINTEMP), TEMP_ERR_PSTR(MSG_ERR_MINTEMP, e));
|
612
|
614
|
}
|
613
|
615
|
|
614
|
616
|
float Temperature::get_pid_output(const int8_t e) {
|
|
@@ -812,7 +814,7 @@ void Temperature::manage_heater() {
|
812
|
814
|
// Make sure temperature is increasing
|
813
|
815
|
if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { // Time to check this extruder?
|
814
|
816
|
if (degHotend(e) < watch_target_temp[e]) // Failed to increase enough?
|
815
|
|
- _temp_error(e, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
|
817
|
+ _temp_error(e, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, e));
|
816
|
818
|
else // Start again if the target is still far off
|
817
|
819
|
start_watching_heater(e);
|
818
|
820
|
}
|
|
@@ -850,7 +852,7 @@ void Temperature::manage_heater() {
|
850
|
852
|
// Make sure temperature is increasing
|
851
|
853
|
if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) { // Time to check the bed?
|
852
|
854
|
if (degBed() < watch_target_bed_temp) // Failed to increase enough?
|
853
|
|
- _temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
|
855
|
+ _temp_error(-1, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, -1));
|
854
|
856
|
else // Start again if the target is still far off
|
855
|
857
|
start_watching_bed();
|
856
|
858
|
}
|
|
@@ -1453,9 +1455,7 @@ void Temperature::init() {
|
1453
|
1455
|
else if (PENDING(millis(), *timer)) break;
|
1454
|
1456
|
*state = TRRunaway;
|
1455
|
1457
|
case TRRunaway:
|
1456
|
|
- _temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY),
|
1457
|
|
- heater_id >= 0 ? PSTR(MSG_THERMAL_RUNAWAY) : PSTR(MSG_THERMAL_RUNAWAY_BED)
|
1458
|
|
- );
|
|
1458
|
+ _temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, heater_id));
|
1459
|
1459
|
}
|
1460
|
1460
|
}
|
1461
|
1461
|
|