Fix pause/resume when using M25/M601
Remove the conflicting and mostly useless card.paused flag (the printing is either paused, or not) and switch to isPrintPaused only which accounts for both cases (SD/USB) correctly. Fix M27/getStatus to show the current real status of the SD print. Synchronize the queue on M601, as required to precisely pause the print at the correct instruction. Alias M25 to M601, which when combined with PR #1899 fixes issue #1614. Guard against incorrect usage in M601, M602 and M603.
This commit is contained in:
parent
18eaf21baf
commit
dbe2ed4150
@ -396,7 +396,7 @@ extern uint16_t gcode_in_progress;
|
||||
extern LongTimer safetyTimer;
|
||||
|
||||
#define PRINT_PERCENT_DONE_INIT 0xff
|
||||
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved)
|
||||
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || mmu_print_saved)
|
||||
|
||||
//! 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
|
||||
|
@ -5377,19 +5377,17 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
|
||||
card.openFile(strchr_pointer + 4,true);
|
||||
break;
|
||||
|
||||
//! ### M24 - Start SD print
|
||||
//! ### M24 - Start/resume SD print
|
||||
// ----------------------------------
|
||||
case 24:
|
||||
if (!card.paused)
|
||||
if (isPrintPaused)
|
||||
lcd_resume_print();
|
||||
else
|
||||
{
|
||||
failstats_reset_print();
|
||||
card.startFileprint();
|
||||
starttime=_millis();
|
||||
break;
|
||||
|
||||
//! ### M25 - Pause SD print
|
||||
// ----------------------------------
|
||||
case 25:
|
||||
card.pauseSDPrint();
|
||||
}
|
||||
break;
|
||||
|
||||
//! ### M26 S\<index\> - Set SD index
|
||||
@ -7246,18 +7244,26 @@ Sigma_Exit:
|
||||
break;
|
||||
#endif //FILAMENTCHANGEENABLE
|
||||
|
||||
//! ### M25 - Pause SD print
|
||||
//! ### M601 - Pause print
|
||||
//! ### M125 - Pause print (TODO: not implemented)
|
||||
// -------------------------------
|
||||
case 25:
|
||||
case 601:
|
||||
{
|
||||
if (!isPrintPaused)
|
||||
{
|
||||
st_synchronize();
|
||||
cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
||||
lcd_pause_print();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//! ### M602 - Resume print
|
||||
// -------------------------------
|
||||
case 602: {
|
||||
if (isPrintPaused)
|
||||
lcd_resume_print();
|
||||
}
|
||||
break;
|
||||
@ -7265,7 +7271,7 @@ Sigma_Exit:
|
||||
//! ### M603 - Stop print
|
||||
// -------------------------------
|
||||
case 603: {
|
||||
lcd_print_stop();
|
||||
Stop();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -25,7 +25,6 @@ CardReader::CardReader()
|
||||
sdpos = 0;
|
||||
sdprinting = false;
|
||||
cardOK = false;
|
||||
paused = false;
|
||||
saving = false;
|
||||
logging = false;
|
||||
autostart_atmillis=0;
|
||||
@ -242,7 +241,6 @@ void CardReader::startFileprint()
|
||||
if(cardOK)
|
||||
{
|
||||
sdprinting = true;
|
||||
paused = false;
|
||||
Stopped = false;
|
||||
#ifdef SDCARD_SORT_ALPHA
|
||||
//flush_presort();
|
||||
@ -250,16 +248,6 @@ void CardReader::startFileprint()
|
||||
}
|
||||
}
|
||||
|
||||
void CardReader::pauseSDPrint()
|
||||
{
|
||||
if(sdprinting)
|
||||
{
|
||||
sdprinting = false;
|
||||
paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CardReader::openLogFile(const char* name)
|
||||
{
|
||||
logging = true;
|
||||
@ -408,8 +396,6 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
|
||||
SERIAL_ECHOLN(name);
|
||||
}
|
||||
sdprinting = false;
|
||||
paused = false;
|
||||
|
||||
|
||||
SdFile myDir;
|
||||
const char *fname=name;
|
||||
@ -492,7 +478,15 @@ uint32_t CardReader::getFileSize()
|
||||
|
||||
void CardReader::getStatus()
|
||||
{
|
||||
if(sdprinting){
|
||||
if(sdprinting)
|
||||
{
|
||||
if (isPrintPaused) {
|
||||
SERIAL_PROTOCOLLNPGM("SD print paused");
|
||||
}
|
||||
else if (saved_printing) {
|
||||
SERIAL_PROTOCOLLNPGM("Print saved");
|
||||
}
|
||||
else {
|
||||
SERIAL_PROTOCOL(longFilename);
|
||||
SERIAL_PROTOCOLPGM("\n");
|
||||
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE
|
||||
@ -505,11 +499,6 @@ void CardReader::getStatus()
|
||||
SERIAL_PROTOCOL(itostr2(time%60));
|
||||
SERIAL_PROTOCOLPGM("\n");
|
||||
}
|
||||
else if (paused) {
|
||||
SERIAL_PROTOCOLLNPGM("SD print paused");
|
||||
}
|
||||
else if (saved_printing) {
|
||||
SERIAL_PROTOCOLLNPGM("Print saved");
|
||||
}
|
||||
else {
|
||||
SERIAL_PROTOCOLLNPGM("Not SD printing");
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
void closefile(bool store_location=false);
|
||||
void release();
|
||||
void startFileprint();
|
||||
void pauseSDPrint();
|
||||
uint32_t getFileSize();
|
||||
void getStatus();
|
||||
void printingHasFinished();
|
||||
@ -75,7 +74,6 @@ public:
|
||||
bool logging;
|
||||
bool sdprinting ;
|
||||
bool cardOK ;
|
||||
bool paused ;
|
||||
char filename[13];
|
||||
uint16_t modificationTime, modificationDate;
|
||||
uint32_t cluster, position;
|
||||
|
@ -4108,7 +4108,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
||||
{
|
||||
prusa_statistics_case0(15);
|
||||
}
|
||||
else if (isPrintPaused || card.paused)
|
||||
else if (isPrintPaused)
|
||||
{
|
||||
prusa_statistics_case0(14);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
||||
SERIAL_ECHOLN("}");
|
||||
status_number = 15;
|
||||
}
|
||||
else if (isPrintPaused || card.paused)
|
||||
else if (isPrintPaused)
|
||||
{
|
||||
SERIAL_ECHO("{");
|
||||
prusa_stat_printerstatus(14);
|
||||
@ -490,7 +490,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
||||
{
|
||||
prusa_statistics_case0(15);
|
||||
}
|
||||
else if (isPrintPaused || card.paused)
|
||||
else if (isPrintPaused)
|
||||
{
|
||||
prusa_statistics_case0(14);
|
||||
}
|
||||
@ -753,7 +753,6 @@ TEST_CASE("Prusa_statistics test", "[prusa_stats]")
|
||||
SERIALS_RESET();
|
||||
|
||||
isPrintPaused = 0;
|
||||
card.paused = 0;
|
||||
IS_SD_PRINTING = 1;
|
||||
old_code::prusa_statistics(test_codes[i],0);
|
||||
new_code::prusa_statistics(test_codes[i],0);
|
||||
|
Loading…
Reference in New Issue
Block a user