diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 3c97901b7c..5cac43605e 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -319,6 +319,8 @@ bool printJobOngoing(); bool printer_active(); +extern uint8_t printer_state; + //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9996db0b4e..1c164426ba 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -519,6 +519,15 @@ bool __attribute__((noinline)) printer_active() { || mesh_bed_leveling_flag; } +//!@brief printer_state +//!printer state state +//!0 = unknown or finished print +//!1 = printer ready for next print +//!2 = printer SD printing +//!3 = printer USB printing +//!@endcode +uint8_t printer_state=0; + // Currently only used in one place, allowed to be inlined bool check_fsensor() { return printJobOngoing() @@ -1731,7 +1740,7 @@ void loop() usb_timer.start(); } else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done. - ; + printer_state = 0; //set printer state to show LCD menu after finished SD print and report correctly M862.7 Q when USB times out } #ifdef PRUSA_M28 @@ -7875,6 +7884,8 @@ SERIAL_PROTOCOLPGM("\n\n"); - M862.3 { P"" | Q } - M862.4 { P | Q } - M862.5 { P | Q } + - M862.6 Not used but reserved + - M862.7 { P<0|1> | Q } 0 = Printer not ready for next print (default), 1 = Printer is ready for next print , 2 = Printer busy printing When run with P<> argument, the check is performed against the input value. When run with Q argument, the current value is shown. @@ -7957,6 +7968,14 @@ SERIAL_PROTOCOLPGM("\n\n"); else if(code_seen('Q')) SERIAL_PROTOCOLLN(GCODE_LEVEL); break; + case ClPrintChecking::_Features: // ~ .6 + break; + case ClPrintChecking::_PrinterState: // ~.7 + if(code_seen('P')) + printer_state=code_value_uint8(); + else if(code_seen('Q')) + SERIAL_PROTOCOLLN((int)printer_state); + break; } break; } diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 3f437af1fd..34a4dc13a9 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -272,6 +272,7 @@ void CardReader::startFileprint() if(cardOK) { sdprinting = true; + printer_state = 2; //set printer state to hide LCD menu and report correctly M862.7 Q while SD printing #ifdef SDCARD_SORT_ALPHA //flush_presort(); #endif @@ -1017,6 +1018,7 @@ void CardReader::printingHasFinished() else { sdprinting = false; + printer_state = 0; //set printer state to show LCD menu after finished SD print if(SD_FINISHED_STEPPERRELEASE) { finishAndDisableSteppers(); diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 39030cb106..5ab79bd63d 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -479,9 +479,10 @@ void get_command() allow_when_stopped = true; // Handle the USB timer - if ((*cmd_start == 'G') && !(IS_SD_PRINTING)) + if ((*cmd_start == 'G') && !(IS_SD_PRINTING)) { usb_timer.start(); - + printer_state = 3; //set printer state busy printing to hide LCD menu and report correctly M862.7 Q while USB printing + } if (allow_when_stopped == false && Stopped == true) { // Stopped can be set either during error states (thermal error: cannot continue), or // when a printer-initiated action is processed. In such case the printer will send to diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index afdda7d0d0..9468da99b3 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -101,6 +101,7 @@ const char MSG_SELFTEST_MOTOR[] PROGMEM_I1 = ISTR("Motor"); ////MSG_SELFTEST_MOT const char MSG_SELFTEST_FILAMENT_SENSOR[] PROGMEM_I1 = ISTR("Filament sensor"); ////MSG_SELFTEST_FILAMENT_SENSOR c=17 const char MSG_SELFTEST_WIRINGERROR[] PROGMEM_I1 = ISTR("Wiring error"); ////MSG_SELFTEST_WIRINGERROR c=18 const char MSG_SETTINGS[] PROGMEM_I1 = ISTR("Settings"); ////MSG_SETTINGS c=18 +const char MSG_SET_READY[] PROGMEM_I1 = ISTR("Set Ready"); ////MSG_SET_READY c=18 const char MSG_SELECT_LANGUAGE[] PROGMEM_I1 = ISTR("Select language"); ////MSG_SELECT_LANGUAGE c=18 const char MSG_SORTING_FILES[] PROGMEM_I1 = ISTR("Sorting files"); ////MSG_SORTING_FILES c=20 const char MSG_TOTAL[] PROGMEM_I1 = ISTR("Total"); ////MSG_TOTAL c=6 diff --git a/Firmware/messages.h b/Firmware/messages.h index 3b5511a16c..6b58679c7e 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -103,6 +103,7 @@ extern const char MSG_SELFTEST_MOTOR[]; extern const char MSG_SELFTEST_FILAMENT_SENSOR[]; extern const char MSG_SELFTEST_WIRINGERROR[]; extern const char MSG_SETTINGS[]; +extern const char MSG_SET_READY[]; extern const char MSG_SELECT_LANGUAGE[]; extern const char MSG_SORTING_FILES[]; extern const char MSG_TOTAL[]; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 9d3a3bd5ab..8c3c97f0f9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5119,6 +5119,15 @@ static void lcd_sheet_menu() MENU_END(); } +//! @brief Set printer state +//! Sets the printer state for next print via LCD menu +//! @endcode +static void lcd_printer_state() +{ + enquecommand_P(PSTR("M118 A1 action:printer_state")); + printer_state=1; +} + //! @brief Show Main Menu //! //! @code{.unparsed} @@ -5191,7 +5200,9 @@ static void lcd_main_menu() } else if (!Stopped) { MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT c=18 } - + if (printer_state == 0) { + MENU_ITEM_FUNCTION_P(_T(MSG_SET_READY), lcd_printer_state); + } if (mesh_bed_leveling_flag == false && homing_flag == false && !isPrintPaused && !processing_tcode) { if (usb_timer.running()) { MENU_ITEM_FUNCTION_P(_T(MSG_PAUSE_PRINT), lcd_pause_usb_print); @@ -5637,6 +5648,7 @@ void print_stop(bool interactive) // return to status is required to continue processing in the main loop! lcd_commands_type = LcdCommands::StopPrint; + printer_state = 0; //set printer state to show LCD menu after print has been stopped and report correctly M862.7 Q lcd_return_to_status(); } diff --git a/Firmware/util.h b/Firmware/util.h index 0fcf768242..4945259811 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -29,7 +29,9 @@ enum class ClPrintChecking:uint_least8_t _Model=2, _Smodel=3, _Version=4, - _Gcode=5 + _Gcode=5, + _Features=6, + _PrinterState=7 }; enum class ClNozzleDiameter:uint_least8_t