@@ -512,13 +512,13 @@ void CardReader::mount() {
512
512
ui.refresh ();
513
513
}
514
514
515
- /* *
516
- * Handle SD card events
517
- */
518
515
#if MB(FYSETC_CHEETAH, FYSETC_AIO_II)
519
516
#include " ../module/stepper.h"
520
517
#endif
521
518
519
+ /* *
520
+ * Handle SD card events
521
+ */
522
522
void CardReader::manage_media () {
523
523
static uint8_t prev_stat = 2 ; // At boot we don't know if media is present or not
524
524
uint8_t stat = uint8_t (IS_SD_INSERTED ());
@@ -639,6 +639,10 @@ void CardReader::abortFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/
639
639
endFilePrintNow (TERN_ (SD_RESORT, re_sort));
640
640
}
641
641
642
+ /* *
643
+ * Open a log file for writing, if possible.
644
+ * Used by G-code M928 <path>.
645
+ */
642
646
void CardReader::openLogFile (const char * const path) {
643
647
flag.logging = DISABLED (SDCARD_READONLY);
644
648
IF_DISABLED (SDCARD_READONLY, openFileWrite (path));
@@ -667,10 +671,16 @@ void CardReader::getAbsFilenameInCWD(char *dst) {
667
671
*dst = ' \0 ' ;
668
672
}
669
673
674
+ //
675
+ // Print "open failed, File: : <filename>.\n" to serial
676
+ //
670
677
void openFailed (const char * const fname) {
671
678
SERIAL_ECHOLNPGM (STR_SD_OPEN_FILE_FAIL, fname, " ." );
672
679
}
673
680
681
+ //
682
+ // Print "echo: Now doing/fresh file: <filepath>\n" to all serial ports
683
+ //
674
684
void announceOpen (const uint8_t doing, const char * const path) {
675
685
if (doing) {
676
686
PORT_REDIRECT (SerialMask::All);
@@ -679,14 +689,14 @@ void announceOpen(const uint8_t doing, const char * const path) {
679
689
}
680
690
}
681
691
682
- //
683
- // Open a file by DOS path for read
684
- // The 'subcall_type' flag indicates...
685
- // - 0 : Standard open from host or user interface.
686
- // - 1 : (file open) Opening a new sub-procedure.
687
- // - 1 : (no file open) Opening a macro (M98).
688
- // - 2 : Resuming from a sub-procedure
689
- / /
692
+ /* *
693
+ * Open a file by DOS path for read
694
+ * The 'subcall_type' flag indicates...
695
+ * - 0 : Standard open from host or user interface.
696
+ * - 1 : (file open) Opening a new sub-procedure.
697
+ * - 1 : (no file open) Opening a macro (M98).
698
+ * - 2 : Resuming from a sub-procedure
699
+ * /
690
700
void CardReader::openFileRead (const char * const path, const uint8_t subcall_type/* =0*/ ) {
691
701
if (!isMounted ()) return openFailed (path);
692
702
@@ -749,6 +759,9 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ
749
759
openFailed (fname);
750
760
}
751
761
762
+ //
763
+ // Print "Writing to file: <filename>\n" to serial
764
+ //
752
765
inline void echo_write_to_file (const char * const fname) {
753
766
SERIAL_ECHOLNPGM (STR_SD_WRITE_TO_FILE, fname);
754
767
}
@@ -782,10 +795,10 @@ void CardReader::openFileWrite(const char * const path) {
782
795
openFailed (fname);
783
796
}
784
797
785
- //
786
- // Check if a file exists by absolute or workDir-relative path
787
- // If the file exists, the long name can also be fetched.
788
- / /
798
+ /* *
799
+ * Check if a file exists by absolute or workDir-relative path
800
+ * If the file exists, the long name can also be fetched.
801
+ * /
789
802
bool CardReader::fileExists (const char * const path) {
790
803
if (!isMounted ()) return false ;
791
804
@@ -852,6 +865,9 @@ void CardReader::report_status(TERN_(QUIETER_AUTO_REPORT_SD_STATUS, const bool i
852
865
SERIAL_ECHOLNPGM (STR_SD_NOT_PRINTING);
853
866
}
854
867
868
+ //
869
+ // Write a command to the log file
870
+ //
855
871
void CardReader::write_command (char * const buf) {
856
872
char *begin = buf,
857
873
*npos = nullptr ,
@@ -988,16 +1004,20 @@ void CardReader::write_command(char * const buf) {
988
1004
989
1005
#endif // ONE_CLICK_PRINT
990
1006
1007
+ //
1008
+ // Close the working file.
1009
+ //
991
1010
void CardReader::closefile (const bool store_location/* =false*/ ) {
992
1011
file.sync ();
993
1012
file.close ();
994
1013
flag.saving = flag.logging = false ;
995
1014
sdpos = 0 ;
1015
+
996
1016
TERN_ (EMERGENCY_PARSER, emergency_parser.enable ());
997
1017
998
1018
if (store_location) {
999
- // future: store printer state, filename and position for continuing a stopped print
1000
- // so one can unplug the printer and continue printing the next day .
1019
+ // TODO: Store printer state, filename, position
1020
+ // for continuing a stopped print .
1001
1021
}
1002
1022
}
1003
1023
@@ -1139,6 +1159,9 @@ const char* CardReader::diveToFile(const bool update_cwd, MediaFile* &inDirPtr,
1139
1159
return atom_ptr;
1140
1160
}
1141
1161
1162
+ //
1163
+ // Change the working directory to the given sub-path
1164
+ //
1142
1165
void CardReader::cd (const char * relpath) {
1143
1166
MediaFile newDir, *parent = &getWorkDir ();
1144
1167
@@ -1154,6 +1177,9 @@ void CardReader::cd(const char * relpath) {
1154
1177
SERIAL_ECHO_MSG (STR_SD_CANT_ENTER_SUBDIR, relpath);
1155
1178
}
1156
1179
1180
+ //
1181
+ // Change the working directory to its parent
1182
+ //
1157
1183
int8_t CardReader::cdup () {
1158
1184
if (workDirDepth > 0 ) { // At least 1 dir has been saved
1159
1185
nrItems = -1 ;
@@ -1164,6 +1190,9 @@ int8_t CardReader::cdup() {
1164
1190
return workDirDepth;
1165
1191
}
1166
1192
1193
+ //
1194
+ // Change the working directory to the volume root
1195
+ //
1167
1196
void CardReader::cdroot () {
1168
1197
workDir = root;
1169
1198
flag.workDirIsRoot = true ;
@@ -1406,17 +1435,21 @@ void CardReader::cdroot() {
1406
1435
1407
1436
#endif // SDCARD_SORT_ALPHA
1408
1437
1438
+ //
1439
+ // Return the count of visible items in the working directory.
1440
+ //
1409
1441
int16_t CardReader::get_num_items () {
1410
1442
if (!isMounted ()) return 0 ;
1411
1443
if (nrItems < 0 ) nrItems = countVisibleItems (workDir);
1412
1444
return nrItems;
1413
1445
}
1414
1446
1415
1447
//
1416
- // Return from procedure or close out the Print Job
1448
+ // Return from procedure or close out the Print Job.
1417
1449
//
1418
1450
void CardReader::fileHasFinished () {
1419
1451
file.close ();
1452
+
1420
1453
#if HAS_MEDIA_SUBCALLS
1421
1454
if (file_subcall_ctr > 0 ) { // Resume calling file after closing procedure
1422
1455
file_subcall_ctr--;
0 commit comments