@@ -839,10 +839,10 @@ volatile bool Temperature::raw_temps_ready = false;
839
839
if (current_temp > watch_temp_target) heated = true ; // - Flag if target temperature reached
840
840
}
841
841
else if (ELAPSED (ms, temp_change_ms)) // Watch timer expired
842
- _temp_error (heater_id, FPSTR (str_t_heating_failed), GET_TEXT_F ( MSG_HEATING_FAILED_LCD) );
842
+ _TEMP_ERROR (heater_id, FPSTR (str_t_heating_failed), MSG_HEATING_FAILED_LCD, current_temp );
843
843
}
844
844
else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
845
- _temp_error (heater_id, FPSTR (str_t_thermal_runaway), GET_TEXT_F ( MSG_THERMAL_RUNAWAY) );
845
+ _TEMP_ERROR (heater_id, FPSTR (str_t_thermal_runaway), MSG_THERMAL_RUNAWAY, current_temp );
846
846
}
847
847
#endif
848
848
} // every 2 seconds
@@ -1467,8 +1467,10 @@ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
1467
1467
kill (lcd_msg, HEATER_FSTR (heater_id));
1468
1468
}
1469
1469
1470
- void Temperature::_temp_error (const heater_id_t heater_id, FSTR_P const serial_msg, FSTR_P const lcd_msg) {
1471
-
1470
+ void Temperature::_temp_error (
1471
+ const heater_id_t heater_id, FSTR_P const serial_msg, FSTR_P const lcd_msg
1472
+ OPTARG (ERR_INCLUDE_TEMP, const celsius_float_t deg)
1473
+ ) {
1472
1474
static uint8_t killed = 0 ;
1473
1475
1474
1476
if (IsRunning () && TERN1 (BOGUS_TEMPERATURE_GRACE_PERIOD, killed == 2 )) {
@@ -1493,10 +1495,13 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m
1493
1495
OPTCODE (HAS_TEMP_CHAMBER, case H_CHAMBER: SERIAL_ECHOPGM (STR_HEATER_CHAMBER); break )
1494
1496
OPTCODE (HAS_TEMP_BED, case H_BED: SERIAL_ECHOPGM (STR_HEATER_BED); break )
1495
1497
default :
1496
- if (real_heater_id >= 0 )
1497
- SERIAL_ECHOLNPGM (" E" , real_heater_id);
1498
+ if (real_heater_id >= 0 ) SERIAL_ECHO (' E' , real_heater_id);
1498
1499
}
1499
- SERIAL_EOL ();
1500
+ #if ENABLED(ERR_INCLUDE_TEMP)
1501
+ SERIAL_ECHOLNPGM (STR_DETECTED_TEMP_B, deg, STR_DETECTED_TEMP_E);
1502
+ #else
1503
+ SERIAL_EOL ();
1504
+ #endif
1500
1505
}
1501
1506
1502
1507
disable_all_heaters (); // always disable (even for bogus temp)
@@ -1525,18 +1530,18 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m
1525
1530
#endif
1526
1531
}
1527
1532
1528
- void Temperature::maxtemp_error (const heater_id_t heater_id) {
1533
+ void Temperature::maxtemp_error (const heater_id_t heater_id OPTARG (ERR_INCLUDE_TEMP, const celsius_float_t deg) ) {
1529
1534
#if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED)
1530
1535
dwinPopupTemperature (1 );
1531
1536
#endif
1532
- _temp_error (heater_id, F (STR_T_MAXTEMP), GET_TEXT_F ( MSG_ERR_MAXTEMP) );
1537
+ _TEMP_ERROR (heater_id, F (STR_T_MAXTEMP), MSG_ERR_MAXTEMP, deg );
1533
1538
}
1534
1539
1535
- void Temperature::mintemp_error (const heater_id_t heater_id) {
1540
+ void Temperature::mintemp_error (const heater_id_t heater_id OPTARG (ERR_INCLUDE_TEMP, const celsius_float_t deg) ) {
1536
1541
#if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED)
1537
1542
dwinPopupTemperature (0 );
1538
1543
#endif
1539
- _temp_error (heater_id, F (STR_T_MINTEMP), GET_TEXT_F ( MSG_ERR_MINTEMP) );
1544
+ _TEMP_ERROR (heater_id, F (STR_T_MINTEMP), MSG_ERR_MINTEMP, deg );
1540
1545
}
1541
1546
1542
1547
#if HAS_PID_DEBUG
@@ -1736,7 +1741,10 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
1736
1741
void Temperature::manage_hotends (const millis_t &ms) {
1737
1742
HOTEND_LOOP () {
1738
1743
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
1739
- if (degHotend (e) > temp_range[e].maxtemp ) maxtemp_error ((heater_id_t )e);
1744
+ {
1745
+ const auto deg = degHotend (e);
1746
+ if (deg > temp_range[e].maxtemp ) MAXTEMP_ERROR (e, deg);
1747
+ }
1740
1748
#endif
1741
1749
1742
1750
TERN_ (HEATER_IDLE_HANDLER, heater_idle[e].update (ms));
@@ -1746,16 +1754,18 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
1746
1754
tr_state_machine[e].run (temp_hotend[e].celsius , temp_hotend[e].target , (heater_id_t )e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
1747
1755
#endif
1748
1756
1749
- temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_hotend_preheating (e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int )get_pid_output_hotend (e) >> 1 : 0 ;
1757
+ temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_hotend_preheating (e))
1758
+ && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int )get_pid_output_hotend (e) >> 1 : 0 ;
1750
1759
1751
1760
#if WATCH_HOTENDS
1752
1761
// Make sure temperature is increasing
1753
1762
if (watch_hotend[e].elapsed (ms)) { // Enabled and time to check?
1754
- if (watch_hotend[e].check (degHotend (e))) // Increased enough?
1763
+ auto temp = degHotend (e);
1764
+ if (watch_hotend[e].check (temp)) // Increased enough?
1755
1765
start_watching_hotend (e); // If temp reached, turn off elapsed check
1756
1766
else {
1757
1767
TERN_ (HAS_DWIN_E3V2_BASIC, dwinPopupTemperature (0 ));
1758
- _temp_error (( heater_id_t ) e, FPSTR (str_t_heating_failed), GET_TEXT_F ( MSG_HEATING_FAILED_LCD) );
1768
+ _TEMP_ERROR ( e, FPSTR (str_t_heating_failed), MSG_HEATING_FAILED_LCD, temp );
1759
1769
}
1760
1770
}
1761
1771
#endif
@@ -1770,19 +1780,25 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
1770
1780
void Temperature::manage_heated_bed (const millis_t &ms) {
1771
1781
1772
1782
#if ENABLED(THERMAL_PROTECTION_BED)
1773
- if (degBed () > BED_MAXTEMP) maxtemp_error (H_BED);
1783
+ {
1784
+ const auto deg = degBed ();
1785
+ if (deg > BED_MAXTEMP) MAXTEMP_ERROR (H_BED, deg);
1786
+ }
1774
1787
#endif
1775
1788
1776
1789
#if WATCH_BED
1790
+ {
1777
1791
// Make sure temperature is increasing
1778
1792
if (watch_bed.elapsed (ms)) { // Time to check the bed?
1779
- if (watch_bed.check (degBed ())) // Increased enough?
1793
+ const auto deg = degBed ();
1794
+ if (watch_bed.check (deg)) // Increased enough?
1780
1795
start_watching_bed (); // If temp reached, turn off elapsed check
1781
1796
else {
1782
1797
TERN_ (HAS_DWIN_E3V2_BASIC, dwinPopupTemperature (0 ));
1783
- _temp_error (H_BED, FPSTR (str_t_heating_failed), GET_TEXT_F ( MSG_HEATING_FAILED_LCD) );
1798
+ _TEMP_ERROR (H_BED, FPSTR (str_t_heating_failed), MSG_HEATING_FAILED_LCD, deg );
1784
1799
}
1785
1800
}
1801
+ }
1786
1802
#endif // WATCH_BED
1787
1803
1788
1804
#if ALL(PROBING_HEATERS_OFF, BED_LIMIT_SWITCHING)
@@ -1860,17 +1876,23 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
1860
1876
#endif
1861
1877
1862
1878
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
1863
- if (degChamber () > (CHAMBER_MAXTEMP)) maxtemp_error (H_CHAMBER);
1879
+ {
1880
+ const auto deg = degChamber ();
1881
+ if (deg > CHAMBER_MAXTEMP) MAXTEMP_ERROR (H_CHAMBER, deg);
1882
+ }
1864
1883
#endif
1865
1884
1866
1885
#if WATCH_CHAMBER
1886
+ {
1867
1887
// Make sure temperature is increasing
1868
1888
if (watch_chamber.elapsed (ms)) { // Time to check the chamber?
1869
- if (watch_chamber.check (degChamber ())) // Increased enough? Error below.
1889
+ const auto deg = degChamber ();
1890
+ if (watch_chamber.check (deg)) // Increased enough? Error below.
1870
1891
start_watching_chamber (); // If temp reached, turn off elapsed check.
1871
1892
else
1872
- _temp_error (H_CHAMBER, FPSTR (str_t_heating_failed), GET_TEXT_F ( MSG_HEATING_FAILED_LCD) );
1893
+ _TEMP_ERROR (H_CHAMBER, FPSTR (str_t_heating_failed), MSG_HEATING_FAILED_LCD, deg );
1873
1894
}
1895
+ }
1874
1896
#endif
1875
1897
1876
1898
#if ANY(CHAMBER_FAN, CHAMBER_VENT) || DISABLED(PIDTEMPCHAMBER)
@@ -1986,16 +2008,20 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
1986
2008
#endif
1987
2009
1988
2010
#if ENABLED(THERMAL_PROTECTION_COOLER)
1989
- if (degCooler () > COOLER_MAXTEMP) maxtemp_error (H_COOLER);
2011
+ {
2012
+ const auto deg = degCooler ();
2013
+ if (deg > COOLER_MAXTEMP) MAXTEMP_ERROR (H_COOLER, deg);
2014
+ }
1990
2015
#endif
1991
2016
1992
2017
#if WATCH_COOLER
1993
2018
// Make sure temperature is decreasing
1994
2019
if (watch_cooler.elapsed (ms)) { // Time to check the cooler?
1995
- if (degCooler () > watch_cooler.target ) // Failed to decrease enough?
1996
- _temp_error (H_COOLER, GET_TEXT_F (MSG_COOLING_FAILED), GET_TEXT_F (MSG_COOLING_FAILED));
2020
+ const auto deg = degCooler ();
2021
+ if (deg > watch_cooler.target ) // Failed to decrease enough?
2022
+ _TEMP_ERROR (H_COOLER, GET_TEXT_F (MSG_COOLING_FAILED), MSG_COOLING_FAILED, deg);
1997
2023
else
1998
- start_watching_cooler (); // Start again if the target is still far off
2024
+ start_watching_cooler (); // Start again if the target is still far off
1999
2025
}
2000
2026
#endif
2001
2027
@@ -2076,20 +2102,32 @@ void Temperature::task() {
2076
2102
2077
2103
#if DISABLED(IGNORE_THERMOCOUPLE_ERRORS)
2078
2104
#if TEMP_SENSOR_IS_MAX_TC(0)
2079
- if (degHotend (0 ) > _MIN (HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0 )) maxtemp_error (H_E0);
2080
- if (degHotend (0 ) < _MAX (HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01 )) mintemp_error (H_E0);
2105
+ {
2106
+ const auto deg = degHotend (0 );
2107
+ if (deg > _MIN (HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0 )) MAXTEMP_ERROR (H_E0, deg);
2108
+ if (deg < _MAX (HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01 )) MINTEMP_ERROR (H_E0, deg);
2109
+ }
2081
2110
#endif
2082
2111
#if TEMP_SENSOR_IS_MAX_TC(1)
2083
- if (degHotend (1 ) > _MIN (HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0 )) maxtemp_error (H_E1);
2084
- if (degHotend (1 ) < _MAX (HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01 )) mintemp_error (H_E1);
2112
+ {
2113
+ const auto deg = degHotend (1 );
2114
+ if (deg > _MIN (HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0 )) MAXTEMP_ERROR (H_E1, deg);
2115
+ if (deg < _MAX (HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01 )) MINTEMP_ERROR (H_E1, deg);
2116
+ }
2085
2117
#endif
2086
2118
#if TEMP_SENSOR_IS_MAX_TC(2)
2087
- if (degHotend (2 ) > _MIN (HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.0 )) maxtemp_error (H_E2);
2088
- if (degHotend (2 ) < _MAX (HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01 )) mintemp_error (H_E2);
2119
+ {
2120
+ const auto deg = degHotend (2 );
2121
+ if (deg > _MIN (HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.0 )) MAXTEMP_ERROR (H_E2, deg);
2122
+ if (deg < _MAX (HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01 )) MINTEMP_ERROR (H_E2, deg);
2123
+ }
2089
2124
#endif
2090
2125
#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
2091
- if (degRedundant () > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0 ) maxtemp_error (H_REDUNDANT);
2092
- if (degRedundant () < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01 ) mintemp_error (H_REDUNDANT);
2126
+ {
2127
+ const auto deg = degRedundant ();
2128
+ if (deg > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0 ) MAXTEMP_ERROR (H_REDUNDANT, deg);
2129
+ if (deg < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01 ) MINTEMP_ERROR (H_REDUNDANT, deg);
2130
+ }
2093
2131
#endif
2094
2132
#else
2095
2133
#warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!"
@@ -2101,9 +2139,12 @@ void Temperature::task() {
2101
2139
TERN_ (HAS_HOTEND, manage_hotends (ms));
2102
2140
2103
2141
#if HAS_TEMP_REDUNDANT
2142
+ {
2143
+ const auto deg = degRedundant ();
2104
2144
// Make sure measured temperatures are close together
2105
- if (ABS (degRedundantTarget () - degRedundant ()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF)
2106
- _temp_error ((heater_id_t )HEATER_ID (TEMP_SENSOR_REDUNDANT_TARGET), F (STR_REDUNDANCY), GET_TEXT_F (MSG_ERR_REDUNDANT_TEMP));
2145
+ if (ABS (degRedundantTarget () - deg) > TEMP_SENSOR_REDUNDANT_MAX_DIFF)
2146
+ _TEMP_ERROR (HEATER_ID (TEMP_SENSOR_REDUNDANT_TARGET), F (STR_REDUNDANCY), MSG_ERR_REDUNDANT_TEMP, deg);
2147
+ }
2107
2148
#endif
2108
2149
2109
2150
// Manage extruder auto fans and/or read fan tachometers
@@ -2616,7 +2657,7 @@ void Temperature::updateTemperaturesFromRawValues() {
2616
2657
const raw_adc_t r = temp_hotend[e].getraw ();
2617
2658
const bool neg = temp_dir[e] < 0 , pos = temp_dir[e] > 0 ;
2618
2659
if ((neg && r < temp_range[e].raw_max ) || (pos && r > temp_range[e].raw_max ))
2619
- maxtemp_error (( heater_id_t )e );
2660
+ MAXTEMP_ERROR (e, temp_hotend[e]. celsius );
2620
2661
2621
2662
/* *
2622
2663
// DEBUG PREHEATING TIME
@@ -2628,7 +2669,7 @@ void Temperature::updateTemperaturesFromRawValues() {
2628
2669
const bool heater_on = temp_hotend[e].target > 0 ;
2629
2670
if (heater_on && !is_hotend_preheating (e) && ((neg && r > temp_range[e].raw_min ) || (pos && r < temp_range[e].raw_min ))) {
2630
2671
if (TERN1 (MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED))
2631
- mintemp_error (( heater_id_t )e );
2672
+ MINTEMP_ERROR (e, temp_hotend[e]. celsius );
2632
2673
}
2633
2674
else {
2634
2675
TERN_ (MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, consecutive_low_temperature_error[e] = 0 );
@@ -2639,27 +2680,27 @@ void Temperature::updateTemperaturesFromRawValues() {
2639
2680
2640
2681
#define TP_CMP (S,A,B ) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B)))
2641
2682
#if ENABLED(THERMAL_PROTECTION_BED)
2642
- if (TP_CMP (BED, temp_bed.getraw (), maxtemp_raw_BED)) maxtemp_error (H_BED);
2643
- if (temp_bed.target > 0 && !is_bed_preheating () && TP_CMP (BED, mintemp_raw_BED, temp_bed.getraw ())) mintemp_error (H_BED);
2683
+ if (TP_CMP (BED, temp_bed.getraw (), maxtemp_raw_BED)) MAXTEMP_ERROR (H_BED, temp_bed. celsius );
2684
+ if (temp_bed.target > 0 && !is_bed_preheating () && TP_CMP (BED, mintemp_raw_BED, temp_bed.getraw ())) MINTEMP_ERROR (H_BED, temp_bed. celsius );
2644
2685
#endif
2645
2686
2646
2687
#if ALL(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER)
2647
- if (TP_CMP (CHAMBER, temp_chamber.getraw (), maxtemp_raw_CHAMBER)) maxtemp_error (H_CHAMBER);
2648
- if (temp_chamber.target > 0 && TP_CMP (CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw ())) mintemp_error (H_CHAMBER);
2688
+ if (TP_CMP (CHAMBER, temp_chamber.getraw (), maxtemp_raw_CHAMBER)) MAXTEMP_ERROR (H_CHAMBER, temp_chamber. celsius );
2689
+ if (temp_chamber.target > 0 && TP_CMP (CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw ())) MINTEMP_ERROR (H_CHAMBER, temp_chamber. celsius );
2649
2690
#endif
2650
2691
2651
2692
#if ALL(HAS_COOLER, THERMAL_PROTECTION_COOLER)
2652
- if (cutter.unitPower > 0 && TP_CMP (COOLER, temp_cooler.getraw (), maxtemp_raw_COOLER)) maxtemp_error (H_COOLER);
2653
- if (TP_CMP (COOLER, mintemp_raw_COOLER, temp_cooler.getraw ())) mintemp_error (H_COOLER);
2693
+ if (cutter.unitPower > 0 && TP_CMP (COOLER, temp_cooler.getraw (), maxtemp_raw_COOLER)) MAXTEMP_ERROR (H_COOLER, temp_cooler. celsius );
2694
+ if (TP_CMP (COOLER, mintemp_raw_COOLER, temp_cooler.getraw ())) MINTEMP_ERROR (H_COOLER, temp_cooler. celsius );
2654
2695
#endif
2655
2696
2656
2697
#if ALL(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD)
2657
- if (TP_CMP (BOARD, temp_board.getraw (), maxtemp_raw_BOARD)) maxtemp_error (H_BOARD);
2658
- if (TP_CMP (BOARD, mintemp_raw_BOARD, temp_board.getraw ())) mintemp_error (H_BOARD);
2698
+ if (TP_CMP (BOARD, temp_board.getraw (), maxtemp_raw_BOARD)) MAXTEMP_ERROR (H_BOARD, temp_board. celsius );
2699
+ if (TP_CMP (BOARD, mintemp_raw_BOARD, temp_board.getraw ())) MINTEMP_ERROR (H_BOARD, temp_board. celsius );
2659
2700
#endif
2660
2701
2661
2702
#if ALL(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC)
2662
- if (TP_CMP (SOC, temp_soc.getraw (), maxtemp_raw_SOC)) maxtemp_error (H_SOC);
2703
+ if (TP_CMP (SOC, temp_soc.getraw (), maxtemp_raw_SOC)) MAXTEMP_ERROR (H_SOC, temp_soc. celsius );
2663
2704
#endif
2664
2705
#undef TP_CMP
2665
2706
@@ -3178,12 +3219,12 @@ void Temperature::init() {
3178
3219
3179
3220
case TRRunaway:
3180
3221
TERN_ (HAS_DWIN_E3V2_BASIC, dwinPopupTemperature (0 ));
3181
- _temp_error (heater_id, FPSTR (str_t_thermal_runaway), GET_TEXT_F ( MSG_THERMAL_RUNAWAY) );
3222
+ _TEMP_ERROR (heater_id, FPSTR (str_t_thermal_runaway), MSG_THERMAL_RUNAWAY, current );
3182
3223
3183
3224
#if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR)
3184
3225
case TRMalfunction:
3185
3226
TERN_ (HAS_DWIN_E3V2_BASIC, dwinPopupTemperature (0 ));
3186
- _temp_error (heater_id, FPSTR (str_t_temp_malfunction), GET_TEXT_F ( MSG_TEMP_MALFUNCTION) );
3227
+ _TEMP_ERROR (heater_id, FPSTR (str_t_temp_malfunction), MSG_TEMP_MALFUNCTION, current );
3187
3228
#endif
3188
3229
}
3189
3230
}
0 commit comments