Revert "Add printer_state.cpp/.h"

This reverts commit 6fceff28a9.
This commit is contained in:
Juan Francisco Estrada 2023-11-22 22:38:01 +01:00
parent ccca22040a
commit b49930d250
7 changed files with 33 additions and 88 deletions

View File

@ -22,7 +22,6 @@
#include "pins.h"
#include "Timer.h"
#include "mmu2.h"
#include "printer_state.h"
#ifndef AT90USB
#define HardwareSerial_h // trick to disable the standard HWserial
@ -312,6 +311,19 @@ bool printJobOngoing();
bool printer_active();
enum class PrinterStatus : uint8_t
{
NotReady = 0,
IsReady = 1,
Idle = 2,
SDPrintingFinished = 3,
HostPrintingFinished = 4,
IsSDPrinting = 5,
IsHostPrinting = 6,
};
extern PrinterStatus printer_status;
//! 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

View File

@ -520,6 +520,8 @@ bool __attribute__((noinline)) printer_active() {
|| mesh_bed_leveling_flag;
}
PrinterStatus printer_status;
// Currently only used in one place, allowed to be inlined
bool check_fsensor() {
return printJobOngoing()
@ -1733,7 +1735,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.
SetPrinterState(PrinterState::HostPrintingFinished); //set printer state to show LCD menu after finished SD print and report correctly M862.7 Q when USB times out
printer_status = PrinterStatus::HostPrintingFinished; //set printer state to show LCD menu after finished SD print and report correctly M862.7 Q when USB times out
}
#ifdef PRUSA_M28
@ -5838,40 +5840,17 @@ Sigma_Exit:
#endif // ENABLE_AUTO_BED_LEVELING
/*!
### M72 - Set/get Printer State <a href="https://reprap.org/wiki/G-code#M72:_Set.2FGet_Printer_State">M72: Set/get Printer State</a>
Without any parameter get printer state
- 0 = NotReady Used by PrusaConnect
- 1 = IsReady Used by PrusaConnect
- 2 = Idle
- 3 = SD printing finished
- 4 = Host printing finished
- 5 = SD printing
- 6 = Host printing
### M72 - Set Ready <a href="https://reprap.org/wiki/G-code#M73:_Set_Ready">M72: Set Ready</a>
#### Usage
M72 [ S ]
#### Parameters
- `Snnn` - Set printer state 0 = not_ready, 1 = ready
- `S` - Set printer ready
*/
case 72:
{
if(code_seen('S')){
switch (code_value_uint8()){
case 0:
SetPrinterState(PrinterState::NotReady);
break;
case 1:
SetPrinterState(PrinterState::IsReady);
break;
default:
break;
}
} else {
printf_P(_N("PrinterState: %d\n"),uint8_t(GetPrinterState()));
break;
}
if(code_seen('S')) printer_status = PrinterStatus(code_value_uint8());
break;
}
@ -8079,7 +8058,8 @@ Sigma_Exit:
- M862.3 { P"<model_name>" | Q }
- M862.4 { P<fw_version> | Q }
- M862.5 { P<gcode_level> | Q }
- M862.6 Not used but reserved by 32-bit
- M862.6 Not used but reserved
- M862.7 { Q }
When run with P<> argument, the check is performed against the input value.
When run with Q argument, the current value is shown.
@ -8162,9 +8142,10 @@ Sigma_Exit:
else if(code_seen('Q'))
SERIAL_PROTOCOLLN(GCODE_LEVEL);
break;
case ClPrintChecking::_Features: // ~ .6 used by 32-bit
case ClPrintChecking::_Features: // ~ .6
break;
default:
case ClPrintChecking::_PrinterState: // ~.7
SERIAL_PROTOCOLLN((int)printer_status);
break;
}
break;

View File

@ -274,7 +274,7 @@ void CardReader::startFileprint()
if(cardOK)
{
sdprinting = true;
SetPrinterState(PrinterState::IsSDPrinting); //set printer state to hide LCD menu and report correctly M862.7 Q while SD printing
printer_status = PrinterStatus::IsSDPrinting; //set printer state to hide LCD menu and report correctly M862.7 Q while SD printing
#ifdef SDCARD_SORT_ALPHA
//flush_presort();
#endif
@ -1020,7 +1020,7 @@ void CardReader::printingHasFinished()
else
{
sdprinting = false;
SetPrinterState(PrinterState::SDPrintingFinished); //set printer state to show LCD menu after finished SD print
printer_status = PrinterStatus::SDPrintingFinished; //set printer state to show LCD menu after finished SD print
if(SD_FINISHED_STEPPERRELEASE)
{
finishAndDisableSteppers();

View File

@ -482,7 +482,7 @@ void get_command()
// Handle the USB timer
if ((*cmd_start == 'G') && !(IS_SD_PRINTING)) {
usb_timer.start();
SetPrinterState(PrinterState::IsHostPrinting); //set printer state busy printing to hide LCD menu and report correctly M862.7 Q while USB printing
printer_status = PrinterStatus::IsHostPrinting; //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

View File

@ -1,16 +0,0 @@
//! @file
//! @brief Printer State
//! @param GetPrinterState get current printer state
//! @param SetPrinterState set printer state
#include "printer_state.h"
static PrinterState printer_state;
PrinterState GetPrinterState() {
return printer_state;
}
PrinterState SetPrinterState(PrinterState status) {
return printer_state = status;
}

View File

@ -1,27 +0,0 @@
//! @file
//! @brief Printer States
//! @param NotReady
//! @param IsReady
//! @param Idle
//! @param SDPrintingFinished
//! @param HostPrintingFinished
//! @param IsSDPrinting
//! @param IsHostPrinting
//! @todo Pause/Resume states, Heating states and more
#pragma once
#include "macros.h"
enum class PrinterState : uint8_t
{
NotReady = 0, //Lowest state to simplify queries
IsReady = 1, //
Idle = 2,
SDPrintingFinished = 3,
HostPrintingFinished = 4,
IsSDPrinting = 5,
IsHostPrinting = 6,
};
PrinterState GetPrinterState();
PrinterState SetPrinterState(PrinterState status);

View File

@ -912,7 +912,6 @@ void lcd_commands()
pid_temp = DEFAULT_PID_TEMP;
lcd_commands_step = 0;
lcd_commands_type = LcdCommands::Idle;
SetPrinterState(PrinterState::Idle);
}
}
@ -5137,9 +5136,9 @@ static void lcd_sheet_menu()
//! @endcode
static void lcd_printer_status_toggle()
{
if (GetPrinterState() == PrinterState::IsReady) SetPrinterState(PrinterState::NotReady);
else SetPrinterState(PrinterState::IsReady);
enquecommandf_P(PSTR("M118 A1 action:%s"), (GetPrinterState() == PrinterState::IsReady) ? "ready" : "not_ready");
if (printer_status == PrinterStatus::NotReady) printer_status = PrinterStatus::IsReady;
else printer_status = PrinterStatus::NotReady;
enquecommandf_P(PSTR("M118 A1 action:%s"), (printer_status == PrinterStatus::NotReady) ? "not_ready" : "ready");
}
//! @brief Show Main Menu
@ -5226,12 +5225,8 @@ static void lcd_main_menu()
} else if (!Stopped) {
MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT c=18
}
if (GetPrinterState() < PrinterState::IsSDPrinting) {
if(GetPrinterState() == PrinterState::IsReady) {
MENU_ITEM_TOGGLE_P(_T(MSG_SET_READY), _T(MSG_NO), lcd_printer_status_toggle);
} else {
MENU_ITEM_TOGGLE_P(_T(MSG_SET_READY), _T(MSG_YES), lcd_printer_status_toggle);
}
if (printer_status < PrinterStatus::IsSDPrinting) {
MENU_ITEM_TOGGLE_P(_T(MSG_SET_READY), (printer_status == PrinterStatus::IsReady) ? _T(MSG_YES) : _T(MSG_NO), lcd_printer_status_toggle);
}
if (mesh_bed_leveling_flag == false && homing_flag == false && !print_job_timer.isPaused() && !processing_tcode) {
if (usb_timer.running()) {
@ -5685,7 +5680,7 @@ void print_stop(bool interactive)
// return to status is required to continue processing in the main loop!
lcd_commands_type = LcdCommands::StopPrint;
SetPrinterState(PrinterState::NotReady); //set printer state to show LCD menu after print has been stopped and report correctly M862.7 Q
printer_status = PrinterStatus::NotReady; //set printer state to show LCD menu after print has been stopped and report correctly M862.7 Q
lcd_return_to_status();
}