Merge pull request #4556 from gudnimg/usb-timer-fix

Restart USB timer during long moves
This commit is contained in:
3d-gussner 2024-01-12 14:41:51 +01:00 committed by GitHub
commit 339a10eb81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -69,6 +69,9 @@
// Keepalive period which is restarted with M79 // Keepalive period which is restarted with M79
#define M79_TIMEOUT 30 * 1000 // ms #define M79_TIMEOUT 30 * 1000 // ms
// A timer which is restarted everytime a G-command is added to the command queue.
#define USB_TIMER_TIMEOUT 10 * 1000 // ms
//=========================================================================== //===========================================================================
//=============================Mechanical Settings=========================== //=============================Mechanical Settings===========================
//=========================================================================== //===========================================================================

View File

@ -1733,7 +1733,7 @@ void loop()
if (printingIsPaused() && saved_printing_type == PowerPanic::PRINT_TYPE_USB) { //keep believing that usb is being printed. Prevents accessing dangerous menus while pausing. if (printingIsPaused() && saved_printing_type == PowerPanic::PRINT_TYPE_USB) { //keep believing that usb is being printed. Prevents accessing dangerous menus while pausing.
usb_timer.start(); usb_timer.start();
} }
else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done. else if (usb_timer.expired(USB_TIMER_TIMEOUT)) { //just need to check if it expired. Nothing else is needed to be done.
SetPrinterState(PrinterState::HostPrintingFinished); //set printer state to show LCD menu after finished SD print SetPrinterState(PrinterState::HostPrintingFinished); //set printer state to show LCD menu after finished SD print
} }
@ -9605,6 +9605,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
get_command(); get_command();
} }
if (blocks_queued() && GetPrinterState() == PrinterState::IsHostPrinting && usb_timer.expired((USB_TIMER_TIMEOUT) / 2))
{
// Handle the case where planned moves may take a longer time to execute than the USB timer period.
// An example is the toolchange unload sequence generated by PrusaSlicer with default settings.
usb_timer.start();
}
if(max_inactive_time && previous_millis_cmd.expired(max_inactive_time)) if(max_inactive_time && previous_millis_cmd.expired(max_inactive_time))
kill(PSTR("Inactivity Shutdown")); kill(PSTR("Inactivity Shutdown"));
if(stepper_inactive_time && previous_millis_cmd.expired(stepper_inactive_time)) { if(stepper_inactive_time && previous_millis_cmd.expired(stepper_inactive_time)) {