Merge 984083757e into 37b56e09a3
This commit is contained in:
commit
62488ece77
8 changed files with 68 additions and 53 deletions
|
|
@ -1187,6 +1187,7 @@
|
||||||
|
|
||||||
#define SD_MENU_CONFIRM_START // Confirm the selected SD file before printing
|
#define SD_MENU_CONFIRM_START // Confirm the selected SD file before printing
|
||||||
|
|
||||||
|
//#define NO_SD_AUTOSTART // Remove auto#.g file support completely to save some Flash, SRAM
|
||||||
//#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files
|
//#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files
|
||||||
|
|
||||||
#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
|
#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,7 @@ void startOrResumeJob() {
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
inline void abortSDPrinting() {
|
inline void abortSDPrinting() {
|
||||||
|
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
|
||||||
card.endFilePrint(TERN_(SD_RESORT, true));
|
card.endFilePrint(TERN_(SD_RESORT, true));
|
||||||
queue.clear();
|
queue.clear();
|
||||||
quickstop_stepper();
|
quickstop_stepper();
|
||||||
|
|
@ -469,6 +470,12 @@ void startOrResumeJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void finishSDPrinting() {
|
inline void finishSDPrinting() {
|
||||||
|
// Purge the recovery file...
|
||||||
|
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
||||||
|
|
||||||
|
// If there's another auto#.g file to run...
|
||||||
|
if (TERN(NO_SD_AUTOSTART, false, card.autofile_check())) return;
|
||||||
|
|
||||||
if (queue.enqueue_one_P(PSTR("M1001"))) {
|
if (queue.enqueue_one_P(PSTR("M1001"))) {
|
||||||
marlin_state = MF_RUNNING;
|
marlin_state = MF_RUNNING;
|
||||||
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
||||||
|
|
@ -1309,6 +1316,8 @@ void setup() {
|
||||||
|
|
||||||
marlin_state = MF_RUNNING;
|
marlin_state = MF_RUNNING;
|
||||||
|
|
||||||
|
TERN_(SDSUPPORT, IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()));
|
||||||
|
|
||||||
SETUP_LOG("setup() completed.");
|
SETUP_LOG("setup() completed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1330,7 +1339,6 @@ void loop() {
|
||||||
idle();
|
idle();
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
card.checkautostart();
|
|
||||||
if (card.flag.abort_sd_printing) abortSDPrinting();
|
if (card.flag.abort_sd_printing) abortSDPrinting();
|
||||||
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
|
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ class PrintJobRecovery {
|
||||||
static void resume();
|
static void resume();
|
||||||
static void purge();
|
static void purge();
|
||||||
|
|
||||||
static inline void cancel() { purge(); card.autostart_index = 0; }
|
static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
|
||||||
|
|
||||||
static void load();
|
static void load();
|
||||||
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=0);
|
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=0);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@
|
||||||
* M1001: Execute actions for SD print completion
|
* M1001: Execute actions for SD print completion
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M1001() {
|
void GcodeSuite::M1001() {
|
||||||
|
|
||||||
// Report total print time
|
// Report total print time
|
||||||
const bool long_print = print_job_timer.duration() > 60;
|
const bool long_print = print_job_timer.duration() > 60;
|
||||||
if (long_print) gcode.process_subcommands_now_P(PSTR("M31"));
|
if (long_print) gcode.process_subcommands_now_P(PSTR("M31"));
|
||||||
|
|
@ -71,9 +70,6 @@ void GcodeSuite::M1001() {
|
||||||
// Set the progress bar "done" state
|
// Set the progress bar "done" state
|
||||||
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
|
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
|
||||||
|
|
||||||
// Purge the recovery file
|
|
||||||
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
|
||||||
|
|
||||||
// Announce SD file completion
|
// Announce SD file completion
|
||||||
{
|
{
|
||||||
PORT_REDIRECT(SERIAL_BOTH);
|
PORT_REDIRECT(SERIAL_BOTH);
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,8 @@ void menu_main() {
|
||||||
//
|
//
|
||||||
// Run Auto Files
|
// Run Auto Files
|
||||||
//
|
//
|
||||||
#if ENABLED(MENU_ADDAUTOSTART)
|
#if ENABLED(MENU_ADDAUTOSTART) && DISABLED(NO_SD_AUTOSTART)
|
||||||
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.beginautostart);
|
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (card_detected) {
|
if (card_detected) {
|
||||||
|
|
@ -237,8 +237,8 @@ void menu_main() {
|
||||||
//
|
//
|
||||||
// Autostart
|
// Autostart
|
||||||
//
|
//
|
||||||
#if ENABLED(MENU_ADDAUTOSTART)
|
#if ENABLED(MENU_ADDAUTOSTART) && DISABLED(NO_SD_AUTOSTART)
|
||||||
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.beginautostart);
|
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (card_detected) {
|
if (card_detected) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@
|
||||||
|
|
||||||
card_flags_t CardReader::flag;
|
card_flags_t CardReader::flag;
|
||||||
char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
|
char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
|
||||||
int8_t CardReader::autostart_index;
|
|
||||||
|
IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0
|
||||||
|
|
||||||
#if BOTH(HAS_MULTI_SERIAL, BINARY_FILE_TRANSFER)
|
#if BOTH(HAS_MULTI_SERIAL, BINARY_FILE_TRANSFER)
|
||||||
int8_t CardReader::transfer_port_index;
|
int8_t CardReader::transfer_port_index;
|
||||||
|
|
@ -135,17 +136,17 @@ CardReader::CardReader() {
|
||||||
//sort_reverse = false;
|
//sort_reverse = false;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
|
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
|
||||||
filesize = sdpos = 0;
|
filesize = sdpos = 0;
|
||||||
|
|
||||||
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
||||||
|
|
||||||
|
IF_DISABLED(NO_SD_AUTOSTART, autofile_cancel());
|
||||||
|
|
||||||
workDirDepth = 0;
|
workDirDepth = 0;
|
||||||
ZERO(workDirParents);
|
ZERO(workDirParents);
|
||||||
|
|
||||||
// Disable autostart until card is initialized
|
|
||||||
autostart_index = -1;
|
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
||||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -444,10 +445,11 @@ void CardReader::manage_media() {
|
||||||
TERN_(SDCARD_EEPROM_EMULATION, settings.first_load());
|
TERN_(SDCARD_EEPROM_EMULATION, settings.first_load());
|
||||||
if (old_stat == 2) // First mount?
|
if (old_stat == 2) // First mount?
|
||||||
DEBUG_ECHOLNPGM("First mount.");
|
DEBUG_ECHOLNPGM("First mount.");
|
||||||
TERN(POWER_LOSS_RECOVERY,
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
recovery.check(), // Check for PLR file. (If not there it will beginautostart)
|
recovery.check(); // Check for PLR file. (If not there then call autofile_begin)
|
||||||
beginautostart() // Look for auto0.g on the next loop
|
#elif DISABLED(NO_SD_AUTOSTART)
|
||||||
);
|
autofile_begin(); // Look for auto0.g on the next loop
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -489,7 +491,7 @@ void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) {
|
||||||
|
|
||||||
void CardReader::openLogFile(char * const path) {
|
void CardReader::openLogFile(char * const path) {
|
||||||
flag.logging = DISABLED(SDCARD_READONLY);
|
flag.logging = DISABLED(SDCARD_READONLY);
|
||||||
TERN(SDCARD_READONLY,,openFileWrite(path));
|
IF_DISABLED(SDCARD_READONLY, openFileWrite(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -704,42 +706,48 @@ void CardReader::write_command(char * const buf) {
|
||||||
if (file.writeError) SERIAL_ERROR_MSG(STR_SD_ERR_WRITE_TO_FILE);
|
if (file.writeError) SERIAL_ERROR_MSG(STR_SD_ERR_WRITE_TO_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
#if DISABLED(NO_SD_AUTOSTART)
|
||||||
// Run the next autostart file. Called:
|
/**
|
||||||
// - On boot after successful card init
|
* Run all the auto#.g files. Called:
|
||||||
// - After finishing the previous autostart file
|
* - On boot after successful card init.
|
||||||
// - From the LCD command to run the autostart file
|
* - From the LCD command to Run Auto Files
|
||||||
//
|
*/
|
||||||
|
void CardReader::autofile_begin() {
|
||||||
|
autofile_index = 1;
|
||||||
|
(void)autofile_check();
|
||||||
|
}
|
||||||
|
|
||||||
void CardReader::checkautostart() {
|
/**
|
||||||
|
* Run the next auto#.g file. Called:
|
||||||
|
* - On boot after successful card init
|
||||||
|
* - After finishing the previous auto#.g file
|
||||||
|
* - From the LCD command to run the auto#.g file
|
||||||
|
*
|
||||||
|
* Return 'true' if there was nothing to do
|
||||||
|
*/
|
||||||
|
bool CardReader::autofile_check() {
|
||||||
|
if (!autofile_index) return true;
|
||||||
|
|
||||||
if (autostart_index < 0 || flag.sdprinting) return;
|
if (!isMounted())
|
||||||
|
mount();
|
||||||
|
else if (ENABLED(SDCARD_EEPROM_EMULATION))
|
||||||
|
settings.first_load();
|
||||||
|
|
||||||
if (!isMounted()) mount();
|
// Don't run auto#.g when a PLR file exists
|
||||||
TERN_(SDCARD_EEPROM_EMULATION, else settings.first_load());
|
if (isMounted() && TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) {
|
||||||
|
char autoname[10];
|
||||||
// Don't run auto#.g when a PLR file exists
|
sprintf_P(autoname, PSTR("/auto%c.g"), '0' + autofile_index - 1);
|
||||||
if (isMounted() && TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) {
|
if (fileExists(autoname)) {
|
||||||
char autoname[8];
|
cdroot();
|
||||||
sprintf_P(autoname, PSTR("auto%c.g"), autostart_index + '0');
|
|
||||||
dir_t p;
|
|
||||||
root.rewind();
|
|
||||||
while (root.readDir(&p, nullptr) > 0) {
|
|
||||||
for (int8_t i = (int8_t)strlen((char*)p.name); i--;) p.name[i] = tolower(p.name[i]);
|
|
||||||
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
|
|
||||||
openAndPrintFile(autoname);
|
openAndPrintFile(autoname);
|
||||||
autostart_index++;
|
autofile_index++;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
autofile_cancel();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
autostart_index = -1;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
void CardReader::beginautostart() {
|
|
||||||
autostart_index = 0;
|
|
||||||
cdroot();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CardReader::closefile(const bool store_location/*=false*/) {
|
void CardReader::closefile(const bool store_location/*=false*/) {
|
||||||
file.sync();
|
file.sync();
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,12 @@ public:
|
||||||
static void openLogFile(char * const path);
|
static void openLogFile(char * const path);
|
||||||
static void write_command(char * const buf);
|
static void write_command(char * const buf);
|
||||||
|
|
||||||
// Auto-Start files
|
#if DISABLED(NO_SD_AUTOSTART) // Auto-Start auto#.g file handling
|
||||||
static int8_t autostart_index; // Index of autoX.g files
|
static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero.
|
||||||
static void beginautostart();
|
static void autofile_begin(); // Begin check. Called automatically after boot-up.
|
||||||
static void checkautostart();
|
static bool autofile_check(); // Check for the next auto-start file and run it.
|
||||||
|
static inline void autofile_cancel() { autofile_index = 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
// Basic file ops
|
// Basic file ops
|
||||||
static void openFileRead(char * const path, const uint8_t subcall=0);
|
static void openFileRead(char * const path, const uint8_t subcall=0);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ opt_set TEMP_SENSOR_4 1000
|
||||||
opt_set TEMP_SENSOR_BED 1
|
opt_set TEMP_SENSOR_BED 1
|
||||||
opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
|
opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
|
||||||
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \
|
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \
|
||||||
SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS \
|
SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS NO_SD_AUTOSTART \
|
||||||
EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
|
EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
|
||||||
MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \
|
MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \
|
||||||
LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
|
LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue