Signal SD completion later (#21840)
This commit is contained in:
committed by
Scott Lahteine
parent
83309c1ac8
commit
c5c8ef436c
@ -755,7 +755,7 @@ inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink)
|
||||
char buffer[14];
|
||||
|
||||
#if ENABLED(SHOW_REMAINING_TIME)
|
||||
const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && (printingIsActive() || marlin_state == MF_SD_COMPLETE);
|
||||
const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && printingIsActive();
|
||||
if (show_remain) {
|
||||
#if ENABLED(USE_M73_REMAINING_TIME)
|
||||
duration_t remaining = ui.get_remaining_time();
|
||||
@ -889,7 +889,7 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
#else // !HAS_DUAL_MIXING
|
||||
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
|
||||
|
||||
if (show_e_total) {
|
||||
#if ENABLED(LCD_SHOW_E_TOTAL)
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "../../gcode/parser.h" // for units (and volumetric)
|
||||
|
||||
#if ENABLED(LCD_SHOW_E_TOTAL)
|
||||
#include "../../MarlinCore.h" // for printingIsActive(), marlin_state and MF_SD_COMPLETE
|
||||
#include "../../MarlinCore.h" // for printingIsActive()
|
||||
#endif
|
||||
|
||||
#if ENABLED(FILAMENT_LCD_DISPLAY)
|
||||
@ -464,7 +464,7 @@ void MarlinUI::draw_status_screen() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
|
||||
const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
|
||||
|
||||
// At the first page, generate new display values
|
||||
if (first_page) {
|
||||
|
@ -1891,7 +1891,7 @@ void HMI_SDCardUpdate() {
|
||||
else if (checkkey == PrintProcess || checkkey == Tune || printingIsActive()) {
|
||||
// TODO: Move card removed abort handling
|
||||
// to CardReader::manage_media.
|
||||
card.flag.abort_sd_printing = true;
|
||||
card.abortFilePrintSoon();
|
||||
wait_for_heatup = wait_for_user = false;
|
||||
dwin_abort_flag = true; // Reset feedrate, return to Home
|
||||
}
|
||||
@ -2311,7 +2311,7 @@ void HMI_PauseOrStop() {
|
||||
checkkey = Back_Main;
|
||||
if (HMI_flag.home_flag) planner.synchronize(); // Wait for planner moves to finish!
|
||||
wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user
|
||||
card.flag.abort_sd_printing = true; // Let the main loop handle SD abort
|
||||
card.abortFilePrintSoon(); // Let the main loop handle SD abort
|
||||
dwin_abort_flag = true; // Reset feedrate, return to Home
|
||||
#ifdef ACTION_ON_CANCEL
|
||||
host_action_cancel();
|
||||
|
@ -289,7 +289,7 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
// if robin nano is printing. when it is, dgus will enter the printing
|
||||
// page to continue print;
|
||||
//
|
||||
//if (print_job_timer.isRunning() || print_job_timer.isPaused()) {
|
||||
//if (printJobOngoing() || printingIsPaused()) {
|
||||
// if (target == MKSLCD_PAUSE_SETTING_MOVE || target == MKSLCD_PAUSE_SETTING_EX
|
||||
// || target == MKSLCD_SCREEN_PRINT || target == MKSLCD_SCREEN_PAUSE
|
||||
// ) {
|
||||
@ -324,7 +324,7 @@ void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
|
||||
void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
|
||||
settings.save();
|
||||
if (print_job_timer.isRunning())
|
||||
if (printJobOngoing())
|
||||
GotoScreen(MKSLCD_SCREEN_PRINT);
|
||||
else if (print_job_timer.isPaused)
|
||||
GotoScreen(MKSLCD_SCREEN_PAUSE);
|
||||
@ -1442,8 +1442,7 @@ bool DGUSScreenHandler::loop() {
|
||||
}
|
||||
|
||||
#if ENABLED(DGUS_MKS_RUNOUT_SENSOR)
|
||||
if (booted && (IS_SD_PRINTING() || IS_SD_PAUSED()))
|
||||
DGUS_Runout_Idle();
|
||||
if (booted && printingIsActive()) DGUS_Runout_Idle();
|
||||
#endif
|
||||
#endif // SHOW_BOOTSCREEN
|
||||
|
||||
|
@ -91,8 +91,8 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
|
||||
cur_name = strrchr(list_file.file_name[sel_id], '/');
|
||||
|
||||
SdFile file, *curDir;
|
||||
card.endFilePrint();
|
||||
const char * const fname = card.diveToFile(true, curDir, cur_name);
|
||||
card.abortFilePrintNow();
|
||||
const char * const fname = card.diveToFile(false, curDir, cur_name);
|
||||
if (!fname) return;
|
||||
if (file.open(curDir, fname, O_READ)) {
|
||||
gCfgItems.curFilesize = file.fileSize();
|
||||
@ -108,7 +108,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
|
||||
planner.flow_percentage[1] = 100;
|
||||
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
|
||||
#endif
|
||||
card.startFileprint();
|
||||
card.startOrResumeFilePrinting();
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
recovery.prepare();
|
||||
#endif
|
||||
@ -124,8 +124,8 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
|
||||
lv_draw_ready_print();
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uiCfg.print_state = IDLE;
|
||||
card.flag.abort_sd_printing = true;
|
||||
uiCfg.print_state = IDLE;
|
||||
card.abortFilePrintSoon();
|
||||
#endif
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
|
||||
|
@ -638,19 +638,18 @@ char *creat_title_text() {
|
||||
W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
|
||||
#endif
|
||||
row++;
|
||||
card.abortFilePrintNow();
|
||||
if (row >= 200) {
|
||||
size = 809;
|
||||
row = 0;
|
||||
|
||||
gcode_preview_over = false;
|
||||
|
||||
card.closefile();
|
||||
char *cur_name = strrchr(list_file.file_name[sel_id], '/');
|
||||
|
||||
SdFile file;
|
||||
SdFile *curDir;
|
||||
card.endFilePrint();
|
||||
const char * const fname = card.diveToFile(true, curDir, cur_name);
|
||||
const char * const fname = card.diveToFile(false, curDir, cur_name);
|
||||
if (!fname) return;
|
||||
if (file.open(curDir, fname, O_READ)) {
|
||||
gCfgItems.curFilesize = file.fileSize();
|
||||
@ -667,13 +666,12 @@ char *creat_title_text() {
|
||||
planner.flow_percentage[1] = 100;
|
||||
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
|
||||
#endif
|
||||
card.startFileprint();
|
||||
card.startOrResumeFilePrinting();
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
|
||||
once_flag = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
card.closefile();
|
||||
#endif // SDSUPPORT
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ int write_to_file(char *buf, int len) {
|
||||
|
||||
if (res == -1) {
|
||||
upload_file.close();
|
||||
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
|
||||
const char * const fname = card.diveToFile(false, upload_curDir, saveFilePath);
|
||||
|
||||
if (upload_file.open(upload_curDir, fname, O_WRITE)) {
|
||||
upload_file.setpos(&pos);
|
||||
@ -732,12 +732,10 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
|
||||
if (!gcode_preview_over) {
|
||||
char *cur_name = strrchr(list_file.file_name[sel_id], '/');
|
||||
|
||||
card.endFilePrint();
|
||||
|
||||
SdFile file;
|
||||
SdFile *curDir;
|
||||
card.endFilePrint();
|
||||
const char * const fname = card.diveToFile(true, curDir, cur_name);
|
||||
card.abortFilePrintNow();
|
||||
const char * const fname = card.diveToFile(false, curDir, cur_name);
|
||||
if (!fname) return;
|
||||
if (file.open(curDir, fname, O_READ)) {
|
||||
gCfgItems.curFilesize = file.fileSize();
|
||||
@ -754,7 +752,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
|
||||
planner.flow_percentage[1] = 100;
|
||||
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
|
||||
#endif
|
||||
card.startFileprint();
|
||||
card.startOrResumeFilePrinting();
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
|
||||
once_flag = false;
|
||||
}
|
||||
@ -814,7 +812,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
|
||||
clear_cur_ui();
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uiCfg.print_state = IDLE;
|
||||
card.flag.abort_sd_printing = true;
|
||||
card.abortFilePrintSoon();
|
||||
#endif
|
||||
|
||||
lv_draw_ready_print();
|
||||
@ -1317,7 +1315,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
|
||||
|
||||
card.cdroot();
|
||||
upload_file.close();
|
||||
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
|
||||
const char * const fname = card.diveToFile(false, upload_curDir, saveFilePath);
|
||||
|
||||
if (!upload_file.open(upload_curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
|
||||
clear_cur_ui();
|
||||
@ -1370,7 +1368,7 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
|
||||
int res = upload_file.write(public_buf, file_writer.write_index);
|
||||
if (res == -1) {
|
||||
upload_file.close();
|
||||
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
|
||||
const char * const fname = card.diveToFile(false, upload_curDir, saveFilePath);
|
||||
if (upload_file.open(upload_curDir, fname, O_WRITE)) {
|
||||
upload_file.setpos(&pos);
|
||||
res = upload_file.write(public_buf, file_writer.write_index);
|
||||
@ -1378,7 +1376,7 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
|
||||
}
|
||||
upload_file.close();
|
||||
SdFile file, *curDir;
|
||||
const char * const fname = card.diveToFile(true, curDir, saveFilePath);
|
||||
const char * const fname = card.diveToFile(false, curDir, saveFilePath);
|
||||
if (file.open(curDir, fname, O_RDWR)) {
|
||||
gCfgItems.curFilesize = file.fileSize();
|
||||
file.close();
|
||||
@ -1744,7 +1742,7 @@ void mks_wifi_firmware_update() {
|
||||
if (wifi_upload(0) >= 0) {
|
||||
card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME);
|
||||
SdFile file, *curDir;
|
||||
const char * const fname = card.diveToFile(true, curDir, ESP_FIRMWARE_FILE);
|
||||
const char * const fname = card.diveToFile(false, curDir, ESP_FIRMWARE_FILE);
|
||||
if (file.open(curDir, fname, O_READ)) {
|
||||
file.rename(curDir, (char *)ESP_FIRMWARE_FILE_RENAME);
|
||||
file.close();
|
||||
|
@ -625,7 +625,7 @@ void upload_spin() {
|
||||
|
||||
// Try to upload the given file at the given address
|
||||
void SendUpdateFile(const char *file, uint32_t address) {
|
||||
const char * const fname = card.diveToFile(true, update_curDir, ESP_FIRMWARE_FILE);
|
||||
const char * const fname = card.diveToFile(false, update_curDir, ESP_FIRMWARE_FILE);
|
||||
if (!update_file.open(update_curDir, fname, O_READ)) return;
|
||||
|
||||
esp_upload.fileSize = update_file.fileSize();
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../libs/duration_t.h"
|
||||
#include "../../HAL/shared/Delay.h"
|
||||
#include "../../MarlinCore.h"
|
||||
#include "../../sd/cardreader.h"
|
||||
|
||||
#if ENABLED(PRINTCOUNTER)
|
||||
@ -106,9 +107,6 @@ namespace ExtUI {
|
||||
#if ENABLED(JOYSTICK)
|
||||
uint8_t jogging : 1;
|
||||
#endif
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uint8_t was_sd_printing : 1;
|
||||
#endif
|
||||
} flags;
|
||||
|
||||
#ifdef __SAM3X8E__
|
||||
@ -1017,27 +1015,17 @@ namespace ExtUI {
|
||||
void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); }
|
||||
|
||||
void printFile(const char *filename) {
|
||||
UNUSED(filename);
|
||||
TERN_(SDSUPPORT, card.openAndPrintFile(filename));
|
||||
TERN(SDSUPPORT, card.openAndPrintFile(filename), UNUSED(filename));
|
||||
}
|
||||
|
||||
bool isPrintingFromMediaPaused() {
|
||||
return TERN0(SDSUPPORT, isPrintingFromMedia() && !IS_SD_PRINTING());
|
||||
return TERN0(SDSUPPORT, isPrintingFromMedia() && printingIsPaused());
|
||||
}
|
||||
|
||||
bool isPrintingFromMedia() {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// Account for when IS_SD_PRINTING() reports the end of the
|
||||
// print when there is still SD card data in the planner.
|
||||
flags.was_sd_printing = card.isFileOpen() || (flags.was_sd_printing && commandsInQueue());
|
||||
return flags.was_sd_printing;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool isPrintingFromMedia() { return IS_SD_PRINTING(); }
|
||||
|
||||
bool isPrinting() {
|
||||
return (commandsInQueue() || isPrintingFromMedia() || TERN0(SDSUPPORT, IS_SD_PRINTING())) || print_job_timer.isRunning() || print_job_timer.isPaused();
|
||||
return commandsInQueue() || isPrintingFromMedia() || printJobOngoing() || printingIsPaused();
|
||||
}
|
||||
|
||||
bool isPrintingPaused() {
|
||||
|
@ -1487,7 +1487,7 @@ void MarlinUI::update() {
|
||||
void MarlinUI::abort_print() {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
wait_for_heatup = wait_for_user = false;
|
||||
card.flag.abort_sd_printing = true;
|
||||
card.abortFilePrintSoon();
|
||||
#endif
|
||||
#ifdef ACTION_ON_CANCEL
|
||||
host_action_cancel();
|
||||
|
Reference in New Issue
Block a user