Skip to content

Commit

Permalink
add a check() method
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 30, 2021
1 parent 0ff5498 commit dffac5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,13 +1253,13 @@ void Temperature::manage_heater() {

#if WATCH_HOTENDS
// Make sure temperature is increasing
if (watch_hotend[e].elapsed(ms)) { // Time to check this extruder?
if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough?
if (watch_hotend[e].elapsed(ms)) { // Enabled and time to check?
if (watch_hotend[e].check(degHotend(e))) // Increased enough?
start_watching_hotend(e); // If temp reached, turn off elapsed check
else {
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
}
else // Start again if the target is still far off
start_watching_hotend(e);
}
#endif

Expand Down Expand Up @@ -1296,13 +1296,13 @@ void Temperature::manage_heater() {

#if WATCH_BED
// Make sure temperature is increasing
if (watch_bed.elapsed(ms)) { // Time to check the bed?
if (degBed() < watch_bed.target) { // Failed to increase enough?
if (watch_bed.elapsed(ms)) { // Time to check the bed?
if (watch_bed.check(degBed())) // Increased enough?
start_watching_bed(); // If temp reached, turn off elapsed check
else {
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
_temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
}
else // Start again if the target is still far off
start_watching_bed();
}
#endif // WATCH_BED

Expand Down Expand Up @@ -1377,11 +1377,11 @@ void Temperature::manage_heater() {

#if WATCH_CHAMBER
// Make sure temperature is increasing
if (watch_chamber.elapsed(ms)) { // Time to check the chamber?
if (degChamber() < watch_chamber.target) // Failed to increase enough?
_temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
if (watch_chamber.elapsed(ms)) { // Time to check the chamber?
if (watch_chamber.check(degChamber())) // Increased enough? Error below.
start_watching_chamber(); // If temp reached, turn off elapsed check.
else
start_watching_chamber(); // Start again if the target is still far off
_temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ struct HeaterWatch {
inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); }
inline bool elapsed() { return elapsed(millis()); }

inline bool check(const celsius_t curr) { return curr >= watch_hotend[e].target; }

inline void restart(const celsius_t curr, const celsius_t tgt) {
if (tgt) {
const celsius_t newtarget = curr + INCREASE;
Expand Down

0 comments on commit dffac5e

Please sign in to comment.