Skip to content

Commit

Permalink
PFW-1351 Cooldown timeout (MarlinFirmware#33)
Browse files Browse the repository at this point in the history
* PFW-1351 WIP

* Fix bug with cooldown timing due to bad bitfield.

* Use default safety timer value for timeout
  • Loading branch information
vintagepc authored and D.R.racer committed Sep 16, 2022
1 parent d1b216d commit d7d6885
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
40 changes: 35 additions & 5 deletions Firmware/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,10 @@ void MMU2::SaveAndPark(bool move_axes, bool turn_off_nozzle) {
}

if (turn_off_nozzle){
mmu_print_saved |= SavedState::Cooldown;
LogEchoEvent("Heater off");
setAllTargetHotends(0);
mmu_print_saved |= SavedState::CooldownPending;
LogEchoEvent("Heater cooldown pending");
// This just sets the flag that we should timeout and shut off the nozzle in 30 minutes...
//setAllTargetHotends(0);
}
}
// keep the motors powered forever (until some other strategy is chosen)
Expand All @@ -513,21 +514,27 @@ void MMU2::SaveAndPark(bool move_axes, bool turn_off_nozzle) {
}

void MMU2::ResumeHotendTemp() {
if ((mmu_print_saved & SavedState::CooldownPending))
{
// Clear the "pending" flag if we haven't cooled yet.
mmu_print_saved &= ~(SavedState::CooldownPending);
LogEchoEvent("Cooldown flag cleared");
}
if ((mmu_print_saved & SavedState::Cooldown) && resume_hotend_temp) {
LogEchoEvent("Resuming Temp");
MMU2_ECHO_MSG("Restoring hotend temperature ");
SERIAL_ECHOLN(resume_hotend_temp);
mmu_print_saved &= ~(SavedState::Cooldown);
setTargetHotend(resume_hotend_temp, active_extruder);
lcd_display_message_fullscreen_P(_i("MMU Retry: Restoring temperature...")); // better report the event and let the GUI do its work somewhere else
ReportErrorHookSensorLineRender();
waitForHotendTargetTemp(1000, []{
ReportErrorHookDynamicRender();
manage_inactivity(true);
});
mmu_print_saved &= ~(SavedState::Cooldown);
lcd_update_enable(true); // temporary hack to stop this locking the printer...
LogEchoEvent("Hotend temperature reached");
lcd_clear();
lcd_update_enable(true); // temporary hack to stop this locking the printer...
}
}

Expand Down Expand Up @@ -591,6 +598,8 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {

KEEPALIVE_STATE(PAUSED_FOR_USER);

LongTimer nozzleTimeout;

for (;;) {
// in our new implementation, we know the exact state of the MMU at any moment, we do not have to wait for a timeout
// So in this case we shall decide if the operation is:
Expand All @@ -601,6 +610,27 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
manage_inactivity(true); // calls LogicStep() and remembers its return status
lcd_update(0);

if (mmu_print_saved & SavedState::CooldownPending)
{
if (!nozzleTimeout.running())
{
nozzleTimeout.start();
LogEchoEvent(" Cooling Timeout started");
}
else if (nozzleTimeout.expired(DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul)) // mins->msec. TODO: do we use the global or have our own independent timeout
{
mmu_print_saved &= ~(SavedState::CooldownPending);
mmu_print_saved |= SavedState::Cooldown;
setAllTargetHotends(0);
LogEchoEvent("Heater cooldown");
}
}
else if (nozzleTimeout.running())
{
nozzleTimeout.stop();
LogEchoEvent("Cooling timer stopped");
}

switch (logicStepLastStatus) {
case Finished:
// command/operation completed, let Marlin continue its work
Expand Down
1 change: 1 addition & 0 deletions Firmware/mmu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MMU2 {
None = 0, // No state saved.
ParkExtruder = 1, // The extruder was parked.
Cooldown = 2, // The extruder was allowed to cool.
CooldownPending = 4,
};

/// Perform a reset of the MMU
Expand Down

0 comments on commit d7d6885

Please sign in to comment.