Improve menu pause / resume (#12876)

This commit is contained in:
InsanityAutomation
2019-01-11 21:42:11 -05:00
committed by Scott Lahteine
parent 432c21456f
commit a403d9a50c
11 changed files with 108 additions and 88 deletions

View File

@ -578,7 +578,7 @@ namespace ExtUI {
}
bool isPrintingFromMedia() {
return IFSD(card.flag.cardOK && card.isFileOpen(), false);
return IFSD(card.isFileOpen(), false);
}
bool isPrinting() {
@ -586,7 +586,7 @@ namespace ExtUI {
}
bool isMediaInserted() {
return IFSD(IS_SD_INSERTED() && card.flag.cardOK, false);
return IFSD(IS_SD_INSERTED() && card.isDetected(), false);
}
void pausePrint() {
@ -703,13 +703,13 @@ void MarlinUI::update() {
last_sd_status = sd_status;
if (sd_status) {
card.initsd();
if (card.flag.cardOK)
if (card.isDetected())
ExtUI::onMediaInserted();
else
ExtUI::onMediaError();
}
else {
const bool ok = card.flag.cardOK;
const bool ok = card.isDetected();
card.release();
if (ok) ExtUI::onMediaRemoved();
}

View File

@ -330,7 +330,7 @@ void process_lcd_s_command(const char* command) {
case 'L': {
#if ENABLED(SDSUPPORT)
if (!card.flag.cardOK) card.initsd();
if (!card.isDetected()) card.initsd();
// A more efficient way to do this would be to
// implement a callback in the ls_SerialPrint code, but

View File

@ -30,33 +30,38 @@
#include "menu.h"
#include "../../module/temperature.h"
#include "../../gcode/queue.h"
#include "../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../feature/power_loss_recovery.h"
#endif
void lcd_pause() {
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
#if ENABLED(PARK_HEAD_ON_PAUSE)
pause_print(PAUSE_PARK_RETRACT_LENGTH, NOZZLE_PARK_POINT, 0, true);
#elif ENABLED(SDSUPPORT)
enqueue_and_echo_commands_P(PSTR("M25"));
#elif defined(ACTION_ON_PAUSE)
SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE);
#endif
}
void lcd_resume() {
#if ENABLED(SDSUPPORT)
if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
#elif ENABLED(ACTION_ON_RESUME)
SERIAL_ECHOLNPGM("//action:" ACTION_ON_RESUME);
#endif
}
#if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h"
#include "../../gcode/queue.h"
#include "../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../feature/power_loss_recovery.h"
#endif
void lcd_sdcard_pause() {
#if ENABLED(POWER_LOSS_RECOVERY)
if (recovery.enabled) recovery.save(true, false);
#endif
enqueue_and_echo_commands_P(PSTR("M25"));
}
void lcd_sdcard_resume() {
#if ENABLED(PARK_HEAD_ON_PAUSE)
enqueue_and_echo_commands_P(PSTR("M24"));
#else
card.startFileprint();
print_job_timer.start();
ui.reset_status();
#endif
}
void lcd_sdcard_stop() {
wait_for_heatup = wait_for_user = false;
@ -88,35 +93,18 @@ void menu_main() {
START_MENU();
MENU_BACK(MSG_WATCH);
#if ENABLED(SDSUPPORT)
if (card.flag.cardOK) {
if (card.isFileOpen()) {
if (IS_SD_PRINTING())
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
else
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
MENU_ITEM(submenu, MSG_STOP_PRINT, menu_sdcard_abort_confirm);
}
else {
MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
#if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21")); // SD-card changed by user
#endif
}
}
else {
MENU_ITEM(function, MSG_NO_CARD, NULL);
#if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
#endif
}
#endif // SDSUPPORT
const bool busy = printer_busy();
if (busy)
if (busy) {
MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause);
MENU_ITEM(submenu, MSG_TUNE, menu_tune);
}
else {
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
#if ENABLED(SDSUPPORT)
if (card.isFileOpen())
MENU_ITEM(submenu, MSG_STOP_PRINT, menu_sdcard_abort_confirm);
#endif
MENU_ITEM(submenu, MSG_MOTION, menu_motion);
MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
}
@ -164,6 +152,20 @@ void menu_main() {
MENU_ITEM(function, MSG_AUTOSTART, card.beginautostart);
#endif
#if ENABLED(SDSUPPORT)
if (card.isDetected() && !card.isFileOpen()) {
MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
#if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21")); // SD-card changed by user
#endif
}
else {
MENU_ITEM(function, MSG_NO_CARD, NULL);
#if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
#endif
}
#endif
END_MENU();
}

View File

@ -111,7 +111,7 @@ void menu_sdcard() {
MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
#endif
}
else if (card.flag.cardOK)
else if (card.isDetected())
MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {