Merge pull request #4560 from gudnimg/fix-print-paused
Fix pause indicator when print job timer is not used
This commit is contained in:
commit
98889cafbf
|
|
@ -279,6 +279,7 @@ extern int fan_speed[2];
|
|||
#define active_extruder 0
|
||||
|
||||
extern bool mesh_bed_leveling_flag;
|
||||
extern bool did_pause_print;
|
||||
|
||||
// save/restore printing
|
||||
extern bool saved_printing;
|
||||
|
|
@ -310,6 +311,9 @@ extern LongTimer safetyTimer;
|
|||
// the print is paused, that still counts as a "running" print.
|
||||
bool printJobOngoing();
|
||||
|
||||
// Printing is paused according to SD or host indicators
|
||||
bool printingIsPaused();
|
||||
|
||||
bool printer_active();
|
||||
|
||||
//! Beware - mcode_in_progress is set as soon as the command gets really processed,
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ int feedmultiply=100; //100->1 200->2
|
|||
int extrudemultiply=100; //100->1 200->2
|
||||
|
||||
bool homing_flag = false;
|
||||
bool did_pause_print;
|
||||
|
||||
LongTimer safetyTimer;
|
||||
static LongTimer crashDetTimer;
|
||||
|
|
@ -510,9 +511,13 @@ bool __attribute__((noinline)) printJobOngoing() {
|
|||
return (IS_SD_PRINTING || usb_timer.running() || print_job_timer.isRunning());
|
||||
}
|
||||
|
||||
bool printingIsPaused() {
|
||||
return did_pause_print || print_job_timer.isPaused();
|
||||
}
|
||||
|
||||
bool __attribute__((noinline)) printer_active() {
|
||||
return printJobOngoing()
|
||||
|| print_job_timer.isPaused()
|
||||
|| printingIsPaused()
|
||||
|| saved_printing
|
||||
|| (lcd_commands_type != LcdCommands::Idle)
|
||||
|| MMU2::mmu2.MMU_PRINT_SAVED()
|
||||
|
|
@ -533,7 +538,7 @@ bool check_fsensor() {
|
|||
bool __attribute__((noinline)) babystep_allowed() {
|
||||
return ( !homing_flag
|
||||
&& !mesh_bed_leveling_flag
|
||||
&& !print_job_timer.isPaused()
|
||||
&& !printingIsPaused()
|
||||
&& ((lcd_commands_type == LcdCommands::Layer1Cal && CHECK_ALL_HEATERS)
|
||||
|| printJobOngoing()
|
||||
|| lcd_commands_type == LcdCommands::Idle
|
||||
|
|
@ -631,7 +636,7 @@ void crashdet_detected(uint8_t mask)
|
|||
|
||||
void crashdet_recover()
|
||||
{
|
||||
if (!print_job_timer.isPaused()) crashdet_restore_print_and_continue();
|
||||
if (!printingIsPaused()) crashdet_restore_print_and_continue();
|
||||
crashdet_use_eeprom_setting();
|
||||
}
|
||||
|
||||
|
|
@ -1725,7 +1730,7 @@ void loop()
|
|||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
}
|
||||
|
||||
if (print_job_timer.isPaused() && 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();
|
||||
}
|
||||
else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done.
|
||||
|
|
@ -1822,7 +1827,7 @@ void loop()
|
|||
}
|
||||
//check heater every n milliseconds
|
||||
manage_heater();
|
||||
manage_inactivity(print_job_timer.isPaused());
|
||||
manage_inactivity(printingIsPaused());
|
||||
checkHitEndstops();
|
||||
lcd_update(0);
|
||||
#ifdef TMC2130
|
||||
|
|
@ -3411,7 +3416,7 @@ static void gcode_M600(const bool automatic, const float x_position, const float
|
|||
fanSpeed = 0;
|
||||
|
||||
// Retract E
|
||||
if (!print_job_timer.isPaused())
|
||||
if (!printingIsPaused())
|
||||
{
|
||||
current_position[E_AXIS] += e_shift;
|
||||
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
|
||||
|
|
@ -3479,7 +3484,7 @@ static void gcode_M600(const bool automatic, const float x_position, const float
|
|||
|
||||
// Feed a little of filament to stabilize pressure
|
||||
if (!automatic) {
|
||||
if (print_job_timer.isPaused())
|
||||
if (printingIsPaused())
|
||||
{
|
||||
// Return to retracted state during a pause
|
||||
// @todo is retraction really needed? E-position is reverted a few lines below
|
||||
|
|
@ -3515,7 +3520,7 @@ static void gcode_M600(const bool automatic, const float x_position, const float
|
|||
feedmultiply = saved_feedmultiply2;
|
||||
enquecommandf_P(MSG_M220, saved_feedmultiply2);
|
||||
|
||||
if (print_job_timer.isPaused()) lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
|
||||
if (printingIsPaused()) lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
|
||||
else lcd_setstatuspgm(MSG_WELCOME);
|
||||
custom_message_type = CustomMsg::Status;
|
||||
}
|
||||
|
|
@ -5271,7 +5276,7 @@ void process_commands()
|
|||
### M24 - Start SD print <a href="https://reprap.org/wiki/G-code#M24:_Start.2Fresume_SD_print">M24: Start/resume SD print</a>
|
||||
*/
|
||||
case 24:
|
||||
if (print_job_timer.isPaused())
|
||||
if (printingIsPaused())
|
||||
lcd_resume_print();
|
||||
else
|
||||
{
|
||||
|
|
@ -5993,7 +5998,7 @@ Sigma_Exit:
|
|||
}
|
||||
}
|
||||
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB && print_job_timer.isPaused()) {
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB && printingIsPaused()) {
|
||||
// The print is in a paused state. The print was recovered following a power panic
|
||||
// but up to this point the printer has been waiting for the M79 from the host
|
||||
// Send action to the host, so the host can resume the print. It is up to the host
|
||||
|
|
@ -7847,7 +7852,7 @@ Sigma_Exit:
|
|||
SERIAL_ECHOPGM("Z:");
|
||||
SERIAL_ECHOLN(pause_position[Z_AXIS]);
|
||||
*/
|
||||
if (!print_job_timer.isPaused()) {
|
||||
if (!printingIsPaused()) {
|
||||
st_synchronize();
|
||||
ClearToSend(); //send OK even before the command finishes executing because we want to make sure it is not skipped because of cmdqueue_pop_front();
|
||||
cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
||||
|
|
@ -7861,7 +7866,7 @@ Sigma_Exit:
|
|||
*/
|
||||
case 602:
|
||||
{
|
||||
if (print_job_timer.isPaused()) lcd_resume_print();
|
||||
if (printingIsPaused()) lcd_resume_print();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -9749,7 +9754,7 @@ void ThermalStop(bool allow_recovery)
|
|||
|
||||
// Either pause or stop the print
|
||||
if(allow_recovery && printJobOngoing()) {
|
||||
if (!print_job_timer.isPaused()) {
|
||||
if (!printingIsPaused()) {
|
||||
lcd_setalertstatuspgm(_T(MSG_PAUSED_THERMAL_ERROR), LCD_STATUS_CRITICAL);
|
||||
|
||||
// we cannot make a distinction for the host here, the pause must be instantaneous
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ void prusa_statistics(uint8_t _message) {
|
|||
if (busy_state == PAUSED_FOR_USER) {
|
||||
prusa_statistics_case0(15);
|
||||
}
|
||||
else if (print_job_timer.isPaused()) {
|
||||
else if (printingIsPaused()) {
|
||||
prusa_statistics_case0(14);
|
||||
}
|
||||
else if (IS_SD_PRINTING || (eFilamentAction != FilamentAction::None)) {
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ uint32_t CardReader::getFileSize()
|
|||
|
||||
void CardReader::getStatus(bool arg_P)
|
||||
{
|
||||
if (print_job_timer.isPaused())
|
||||
if (printingIsPaused())
|
||||
{
|
||||
if (saved_printing && (saved_printing_type == PowerPanic::PRINT_TYPE_SD))
|
||||
SERIAL_PROTOCOLLNPGM("SD print paused");
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ void get_command()
|
|||
}
|
||||
|
||||
// start of serial line processing loop
|
||||
while (((MYSERIAL.available() > 0 && !saved_printing) || (MYSERIAL.available() > 0 && print_job_timer.isPaused())) && !cmdqueue_serial_disabled) { //is print is saved (crash detection or filament detection), dont process data from serial line
|
||||
while (((MYSERIAL.available() > 0 && !saved_printing) || (MYSERIAL.available() > 0 && printingIsPaused())) && !cmdqueue_serial_disabled) { //is print is saved (crash detection or filament detection), dont process data from serial line
|
||||
|
||||
#ifdef ENABLE_MEATPACK
|
||||
// MeatPack Changes
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ void fanSpeedError(unsigned char _fan) {
|
|||
|
||||
if (printJobOngoing()) {
|
||||
// A print is ongoing, pause the print normally
|
||||
if(!print_job_timer.isPaused()) {
|
||||
if(!printingIsPaused()) {
|
||||
if (usb_timer.running())
|
||||
lcd_pause_usb_print();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1020,6 +1020,9 @@ void lcd_pause_print()
|
|||
|
||||
SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_PAUSED);
|
||||
|
||||
// Indicate that the printer is paused
|
||||
did_pause_print = true;
|
||||
|
||||
print_job_timer.pause();
|
||||
|
||||
// return to status is required to continue processing in the main loop!
|
||||
|
|
@ -1997,7 +2000,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
|
|||
if (!bFilamentPreheatState)
|
||||
{
|
||||
setTargetHotend(0);
|
||||
if (!print_job_timer.isPaused()) setTargetBed(0);
|
||||
if (!printingIsPaused()) setTargetBed(0);
|
||||
menu_back();
|
||||
}
|
||||
menu_back();
|
||||
|
|
@ -4434,7 +4437,7 @@ static void lcd_settings_menu()
|
|||
|
||||
MENU_ITEM_SUBMENU_P(_i("Temperature"), lcd_control_temperature_menu);////MSG_TEMPERATURE c=18
|
||||
|
||||
if (!printer_active() || print_job_timer.isPaused())
|
||||
if (!printer_active() || printingIsPaused())
|
||||
{
|
||||
MENU_ITEM_SUBMENU_P(_i("Move axis"), lcd_move_menu_axis);////MSG_MOVE_AXIS c=18
|
||||
MENU_ITEM_GCODE_P(_i("Disable steppers"), MSG_M84);////MSG_DISABLE_STEPPERS c=18
|
||||
|
|
@ -4478,7 +4481,7 @@ static void lcd_settings_menu()
|
|||
MENU_ITEM_TOGGLE_P(_T(MSG_RPI_PORT), (selectedSerialPort == 0) ? _T(MSG_OFF) : _T(MSG_ON), lcd_second_serial_set);
|
||||
#endif //HAS_SECOND_SERIAL
|
||||
|
||||
if (!print_job_timer.isPaused()) MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);
|
||||
if (!printingIsPaused()) MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);
|
||||
|
||||
#if (LANG_MODE != 0)
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_SELECT_LANGUAGE), lcd_language_menu);
|
||||
|
|
@ -5008,7 +5011,12 @@ void lcd_resume_print()
|
|||
Stopped = false;
|
||||
|
||||
restore_print_from_ram_and_continue(default_retraction);
|
||||
print_job_timer.start();
|
||||
|
||||
did_pause_print = false;
|
||||
|
||||
// Resume the print job timer if it was running
|
||||
if (print_job_timer.isPaused()) print_job_timer.start();
|
||||
|
||||
refresh_cmd_timeout();
|
||||
SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_RESUMED); //resume octoprint
|
||||
custom_message_type = CustomMsg::Status;
|
||||
|
|
@ -5231,14 +5239,14 @@ static void lcd_main_menu()
|
|||
MENU_ITEM_FUNCTION_P(_T(MSG_SET_READY), lcd_printer_ready_state_toggle);
|
||||
}
|
||||
}
|
||||
if (mesh_bed_leveling_flag == false && homing_flag == false && !print_job_timer.isPaused() && !processing_tcode) {
|
||||
if (mesh_bed_leveling_flag == false && homing_flag == false && !printingIsPaused() && !processing_tcode) {
|
||||
if (usb_timer.running()) {
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_PAUSE_PRINT), lcd_pause_usb_print);
|
||||
} else if (IS_SD_PRINTING) {
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_PAUSE_PRINT), lcd_pause_print);
|
||||
}
|
||||
}
|
||||
if(print_job_timer.isPaused())
|
||||
if(printingIsPaused())
|
||||
{
|
||||
// only allow resuming if hardware errors (temperature or fan) are cleared
|
||||
if(!get_temp_error()
|
||||
|
|
@ -5253,7 +5261,7 @@ static void lcd_main_menu()
|
|||
}
|
||||
}
|
||||
}
|
||||
if((printJobOngoing() || print_job_timer.isPaused()) && (custom_message_type != CustomMsg::MeshBedLeveling) && !processing_tcode) {
|
||||
if((printJobOngoing() || printingIsPaused()) && (custom_message_type != CustomMsg::MeshBedLeveling) && !processing_tcode) {
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_STOP_PRINT), lcd_sdcard_stop);
|
||||
}
|
||||
#ifdef THERMAL_MODEL
|
||||
|
|
@ -5326,7 +5334,7 @@ static void lcd_main_menu()
|
|||
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament);
|
||||
}
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu);
|
||||
if(!print_job_timer.isPaused()) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu);
|
||||
if(!printingIsPaused()) MENU_ITEM_SUBMENU_P(_T(MSG_CALIBRATION), lcd_calibration_menu);
|
||||
}
|
||||
|
||||
MENU_ITEM_SUBMENU_P(_i("Statistics"), lcd_menu_statistics);////MSG_STATISTICS c=18
|
||||
|
|
@ -5478,7 +5486,7 @@ static void lcd_tune_menu()
|
|||
if (!farm_mode)
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_FILAMENTCHANGE), lcd_colorprint_change);
|
||||
#endif
|
||||
if (print_job_timer.isPaused()) {// Don't allow rehome if actively printing. Maaaaybe it could work to insert on the fly, seems too risky.
|
||||
if (printingIsPaused()) {// Don't allow rehome if actively printing. Maaaaybe it could work to insert on the fly, seems too risky.
|
||||
MENU_ITEM_GCODE_P(_T(MSG_AUTO_HOME),PSTR("G28 XY"));
|
||||
}
|
||||
#ifdef FILAMENT_SENSOR
|
||||
|
|
@ -5656,7 +5664,7 @@ void lcd_print_stop_finish()
|
|||
|
||||
if (MMU2::mmu2.Enabled() && MMU2::mmu2.FindaDetectsFilament())
|
||||
{
|
||||
if (print_job_timer.isPaused())
|
||||
if (printingIsPaused())
|
||||
{
|
||||
// Restore temperature saved in ram after pausing print
|
||||
restore_extruder_temperature_from_ram();
|
||||
|
|
@ -5690,6 +5698,7 @@ void print_stop(bool interactive)
|
|||
#endif
|
||||
|
||||
// clear any pending paused state immediately
|
||||
did_pause_print = false;
|
||||
print_job_timer.stop();
|
||||
|
||||
if (interactive) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue