Add heater timeouts to ExtUI (#13970)

- Add local UI methods to get heater timeout state.
- Add methods to resume timed-out heaters.
- Re-enable heaters on UI temperature request.
- Make `ExtUI` show a dialog box if pause needs a button press after reheat.
This commit is contained in:
Marcio Teixeira 2019-05-10 14:56:13 -06:00 committed by Scott Lahteine
parent fa3739aa23
commit 227f29090d
3 changed files with 69 additions and 34 deletions

View file

@ -49,6 +49,10 @@
#include "host_actions.h" #include "host_actions.h"
#endif #endif
#if ENABLED(EXTENSIBLE_UI)
#include "../lcd/extensible_ui/ui_api.h"
#endif
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../libs/buzzer.h" #include "../libs/buzzer.h"
#include "../libs/nozzle.h" #include "../libs/nozzle.h"
@ -538,6 +542,9 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
#if ENABLED(HOST_PROMPT_SUPPORT) #if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating")); host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating"));
#endif #endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onStatusChanged(PSTR("Reheating..."));
#endif
// Re-enable the heaters if they timed out // Re-enable the heaters if they timed out
HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
@ -555,6 +562,9 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
#if ENABLED(HOST_PROMPT_SUPPORT) #if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue")); host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue"));
#endif #endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired("Reheat finished.");
#endif
wait_for_user = true; wait_for_user = true;
nozzle_timed_out = false; nozzle_timed_out = false;

View file

@ -148,9 +148,7 @@ namespace ExtUI {
} }
#endif // __SAM3X8E__ #endif // __SAM3X8E__
void delay_us(unsigned long us) { void delay_us(unsigned long us) { DELAY_US(us); }
DELAY_US(us);
}
void delay_ms(unsigned long ms) { void delay_ms(unsigned long ms) {
if (flags.printer_killed) if (flags.printer_killed)
@ -164,14 +162,49 @@ namespace ExtUI {
thermalManager.manage_heater(); thermalManager.manage_heater();
} }
float getActualTemp_celsius(const heater_t heater) { void enableHeater(const extruder_t extruder) {
return heater == BED ? #if HEATER_IDLE_HANDLER
#if HAS_HEATED_BED thermalManager.reset_heater_idle_timer(extruder - E0);
thermalManager.degBed()
#else
0
#endif #endif
: thermalManager.degHotend(heater - H0); }
void enableHeater(const heater_t heater) {
#if HEATER_IDLE_HANDLER
#if HAS_HEATED_BED
if (heater == BED)
thermalManager.reset_bed_idle_timer();
else
#endif
thermalManager.reset_heater_idle_timer(heater - H0);
#endif
}
bool isHeaterIdle(const extruder_t extruder) {
return false
#if HEATER_IDLE_HANDLER
|| thermalManager.hotend_idle[extruder - E0].timed_out
#endif
;
}
bool isHeaterIdle(const heater_t heater) {
return (false
#if HEATER_IDLE_HANDLER
|| (heater == BED ? (false
#if HAS_HEATED_BED
|| thermalManager.bed_idle.timed_out
#endif
) : thermalManager.hotend_idle[heater - H0].timed_out)
#endif
);
}
float getActualTemp_celsius(const heater_t heater) {
return heater == BED ? (0
#if HAS_HEATED_BED
+ thermalManager.degBed()
#endif
) : thermalManager.degHotend(heater - H0);
} }
float getActualTemp_celsius(const extruder_t extruder) { float getActualTemp_celsius(const extruder_t extruder) {
@ -179,13 +212,11 @@ namespace ExtUI {
} }
float getTargetTemp_celsius(const heater_t heater) { float getTargetTemp_celsius(const heater_t heater) {
return heater == BED ? return heater == BED ? (0
#if HAS_HEATED_BED #if HAS_HEATED_BED
thermalManager.degTargetBed() + thermalManager.degTargetBed()
#else
0
#endif #endif
: thermalManager.degTargetHotend(heater - H0); ) : thermalManager.degTargetHotend(heater - H0);
} }
float getTargetTemp_celsius(const extruder_t extruder) { float getTargetTemp_celsius(const extruder_t extruder) {
@ -252,8 +283,7 @@ namespace ExtUI {
} }
#endif #endif
if (!flags.manual_motion) if (!flags.manual_motion) set_destination_from_current();
set_destination_from_current();
destination[axis] = clamp(position, min, max); destination[axis] = clamp(position, min, max);
flags.manual_motion = true; flags.manual_motion = true;
} }
@ -261,8 +291,7 @@ namespace ExtUI {
void setAxisPosition_mm(const float position, const extruder_t extruder) { void setAxisPosition_mm(const float position, const extruder_t extruder) {
setActiveTool(extruder, true); setActiveTool(extruder, true);
if (!flags.manual_motion) if (!flags.manual_motion) set_destination_from_current();
set_destination_from_current();
destination[E_AXIS] = position; destination[E_AXIS] = position;
flags.manual_motion = true; flags.manual_motion = true;
} }
@ -303,8 +332,7 @@ namespace ExtUI {
#if EXTRUDERS > 1 #if EXTRUDERS > 1
const uint8_t e = extruder - E0; const uint8_t e = extruder - E0;
#if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER) #if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER)
if (e != active_extruder) if (e != active_extruder) tool_change(e, 0, no_move);
tool_change(e, 0, no_move);
#endif #endif
active_extruder = e; active_extruder = e;
#endif #endif
@ -341,13 +369,8 @@ namespace ExtUI {
} }
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
bool getSoftEndstopState() { bool getSoftEndstopState() { return soft_endstops_enabled; }
return soft_endstops_enabled; void setSoftEndstopState(const bool value) { soft_endstops_enabled = value; }
}
void setSoftEndstopState(const bool value) {
soft_endstops_enabled = value;
}
#endif #endif
#if HAS_TRINAMIC #if HAS_TRINAMIC
@ -513,13 +536,8 @@ namespace ExtUI {
void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; } void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
#ifdef FILAMENT_RUNOUT_DISTANCE_MM #ifdef FILAMENT_RUNOUT_DISTANCE_MM
float getFilamentRunoutDistance_mm() { float getFilamentRunoutDistance_mm() { return runout.runout_distance(); }
return runout.runout_distance(); void setFilamentRunoutDistance_mm(const float value) { runout.set_runout_distance(clamp(value, 0, 999)); }
}
void setFilamentRunoutDistance_mm(const float value) {
runout.set_runout_distance(clamp(value, 0, 999));
}
#endif #endif
#endif #endif
@ -761,6 +779,7 @@ namespace ExtUI {
void setTargetTemp_celsius(float value, const heater_t heater) { void setTargetTemp_celsius(float value, const heater_t heater) {
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP); constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
const int16_t e = heater - H0; const int16_t e = heater - H0;
enableHeater(heater);
#if HAS_HEATED_BED #if HAS_HEATED_BED
if (heater == BED) if (heater == BED)
thermalManager.setTargetBed(clamp(value, 0, BED_MAXTEMP - 10)); thermalManager.setTargetBed(clamp(value, 0, BED_MAXTEMP - 10));
@ -772,6 +791,7 @@ namespace ExtUI {
void setTargetTemp_celsius(float value, const extruder_t extruder) { void setTargetTemp_celsius(float value, const extruder_t extruder) {
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP); constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
const int16_t e = extruder - E0; const int16_t e = extruder - E0;
enableHeater(extruder);
thermalManager.setTargetHotend(clamp(value, 0, heater_maxtemp[e] - 15), e); thermalManager.setTargetHotend(clamp(value, 0, heater_maxtemp[e] - 15), e);
} }

View file

@ -70,6 +70,11 @@ namespace ExtUI {
void enqueueCommands_P(PGM_P const); void enqueueCommands_P(PGM_P const);
bool commandsInQueue(); bool commandsInQueue();
bool isHeaterIdle(const heater_t);
bool isHeaterIdle(const extruder_t);
void enableHeater(const heater_t);
void enableHeater(const extruder_t);
/** /**
* Getters and setters * Getters and setters
* Should be used by the EXTENSIBLE_UI to query or change Marlin's state. * Should be used by the EXTENSIBLE_UI to query or change Marlin's state.