✨ M20_TIMESTAMP_SUPPORT (#24679)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
ef1cf0d5a1
commit
e24d5f9315
@ -1578,6 +1578,7 @@
|
|||||||
|
|
||||||
//#define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 <dosname>' and list long filenames with 'M20 L'
|
//#define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 <dosname>' and list long filenames with 'M20 L'
|
||||||
//#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol
|
//#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol
|
||||||
|
//#define M20_TIMESTAMP_SUPPORT // Include timestamps by adding the 'T' flag to M20 commands
|
||||||
|
|
||||||
//#define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu
|
//#define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu
|
||||||
|
|
||||||
|
@ -28,18 +28,23 @@
|
|||||||
#include "../../sd/cardreader.h"
|
#include "../../sd/cardreader.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* M20: List SD card to serial output
|
* M20: List SD card to serial output in [name] [size] format.
|
||||||
|
*
|
||||||
|
* With CUSTOM_FIRMWARE_UPLOAD:
|
||||||
|
* F<bool> - List BIN files only, for use with firmware upload
|
||||||
|
*
|
||||||
|
* With LONG_FILENAME_HOST_SUPPORT:
|
||||||
|
* L<bool> - List long filenames (instead of DOS8.3 names)
|
||||||
|
*
|
||||||
|
* With M20_TIMESTAMP_SUPPORT:
|
||||||
|
* T<bool> - Include timestamps
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M20() {
|
void GcodeSuite::M20() {
|
||||||
if (card.flag.mounted) {
|
if (card.flag.mounted) {
|
||||||
SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
|
SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
|
||||||
card.ls(
|
card.ls(TERN0(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F') << LS_ONLY_BIN)
|
||||||
TERN_(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F'))
|
| TERN0(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L') << LS_LONG_FILENAME)
|
||||||
#if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT)
|
| TERN0(M20_TIMESTAMP_SUPPORT, parser.boolval('T') << LS_TIMESTAMP));
|
||||||
,
|
|
||||||
#endif
|
|
||||||
TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L'))
|
|
||||||
);
|
|
||||||
SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
|
SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1003,7 +1003,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flag whether hex_print.cpp is used
|
// Flag whether hex_print.cpp is used
|
||||||
#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER)
|
#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT)
|
||||||
#define NEED_HEX_PRINT 1
|
#define NEED_HEX_PRINT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "cardreader.h"
|
#include "cardreader.h"
|
||||||
|
|
||||||
#include "../MarlinCore.h"
|
#include "../MarlinCore.h"
|
||||||
|
#include "../libs/hex_print.h"
|
||||||
#include "../lcd/marlinui.h"
|
#include "../lcd/marlinui.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD)
|
#if ENABLED(DWIN_CREALITY_LCD)
|
||||||
@ -197,7 +198,7 @@ char *createFilename(char * const buffer, const dir_t &p) {
|
|||||||
//
|
//
|
||||||
// Return 'true' if the item is a folder, G-code file or Binary file
|
// Return 'true' if the item is a folder, G-code file or Binary file
|
||||||
//
|
//
|
||||||
bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) {
|
bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/)) {
|
||||||
//uint8_t pn0 = p.name[0];
|
//uint8_t pn0 = p.name[0];
|
||||||
|
|
||||||
#if DISABLED(CUSTOM_FIRMWARE_UPLOAD)
|
#if DISABLED(CUSTOM_FIRMWARE_UPLOAD)
|
||||||
@ -279,12 +280,17 @@ void CardReader::selectByName(SdFile dir, const char * const match) {
|
|||||||
* this can blow up the stack, so a 'depth' parameter would be a
|
* this can blow up the stack, so a 'depth' parameter would be a
|
||||||
* good addition.
|
* good addition.
|
||||||
*/
|
*/
|
||||||
void CardReader::printListing(
|
void CardReader::printListing(SdFile parent, const char * const prepend, const uint8_t lsflags
|
||||||
SdFile parent, const char * const prepend
|
|
||||||
OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)
|
|
||||||
OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/)
|
|
||||||
OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/)
|
OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/)
|
||||||
) {
|
) {
|
||||||
|
const bool includeTime = TERN0(M20_TIMESTAMP_SUPPORT, TEST(lsflags, LS_TIMESTAMP));
|
||||||
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
||||||
|
const bool includeLong = TEST(lsflags, LS_LONG_FILENAME);
|
||||||
|
#endif
|
||||||
|
#if ENABLED(CUSTOM_FIRMWARE_UPLOAD)
|
||||||
|
const bool onlyBin = TEST(lsflags, LS_ONLY_BIN);
|
||||||
|
#endif
|
||||||
|
UNUSED(lsflags);
|
||||||
dir_t p;
|
dir_t p;
|
||||||
while (parent.readDir(&p, longFilename) > 0) {
|
while (parent.readDir(&p, longFilename) > 0) {
|
||||||
if (DIR_IS_SUBDIR(&p)) {
|
if (DIR_IS_SUBDIR(&p)) {
|
||||||
@ -301,19 +307,17 @@ void CardReader::printListing(
|
|||||||
SdFile child; // child.close() in destructor
|
SdFile child; // child.close() in destructor
|
||||||
if (child.open(&parent, dosFilename, O_READ)) {
|
if (child.open(&parent, dosFilename, O_READ)) {
|
||||||
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
||||||
if (includeLongNames) {
|
if (includeLong) {
|
||||||
size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0;
|
const size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0;
|
||||||
// Allocate enough stack space for the full long path including / separator
|
// Allocate enough stack space for the full long path including / separator
|
||||||
char pathLong[lenPrependLong + strlen(longFilename) + 1];
|
char pathLong[lenPrependLong + strlen(longFilename) + 1];
|
||||||
if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; }
|
if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; }
|
||||||
strcpy(pathLong + lenPrependLong, longFilename);
|
strcpy(pathLong + lenPrependLong, longFilename);
|
||||||
printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong);
|
printListing(child, path, lsflags, pathLong);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin));
|
|
||||||
#else
|
|
||||||
printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin));
|
|
||||||
#endif
|
#endif
|
||||||
|
printListing(child, path, lsflags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename);
|
SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename);
|
||||||
@ -325,8 +329,18 @@ void CardReader::printListing(
|
|||||||
SERIAL_ECHO(createFilename(filename, p));
|
SERIAL_ECHO(createFilename(filename, p));
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHO(p.fileSize);
|
SERIAL_ECHO(p.fileSize);
|
||||||
|
if (includeTime) {
|
||||||
|
SERIAL_CHAR(' ');
|
||||||
|
uint16_t crmodDate = p.lastWriteDate, crmodTime = p.lastWriteTime;
|
||||||
|
if (crmodDate < p.creationDate || (crmodDate == p.creationDate && crmodTime < p.creationTime)) {
|
||||||
|
crmodDate = p.creationDate;
|
||||||
|
crmodTime = p.creationTime;
|
||||||
|
}
|
||||||
|
SERIAL_ECHOPGM("0x", hex_word(crmodDate));
|
||||||
|
print_hex_word(crmodTime);
|
||||||
|
}
|
||||||
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
||||||
if (includeLongNames) {
|
if (includeLong) {
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); }
|
if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); }
|
||||||
SERIAL_ECHO(longFilename[0] ? longFilename : filename);
|
SERIAL_ECHO(longFilename[0] ? longFilename : filename);
|
||||||
@ -340,16 +354,10 @@ void CardReader::printListing(
|
|||||||
//
|
//
|
||||||
// List all files on the SD card
|
// List all files on the SD card
|
||||||
//
|
//
|
||||||
void CardReader::ls(
|
void CardReader::ls(const uint8_t lsflags) {
|
||||||
TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/)
|
|
||||||
#if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT)
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/)
|
|
||||||
) {
|
|
||||||
if (flag.mounted) {
|
if (flag.mounted) {
|
||||||
root.rewind();
|
root.rewind();
|
||||||
printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames));
|
printListing(root, nullptr, lsflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,8 @@ typedef struct {
|
|||||||
;
|
;
|
||||||
} card_flags_t;
|
} card_flags_t;
|
||||||
|
|
||||||
|
enum ListingFlags : uint8_t { LS_LONG_FILENAME, LS_ONLY_BIN, LS_TIMESTAMP };
|
||||||
|
|
||||||
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
||||||
#include "../libs/autoreport.h"
|
#include "../libs/autoreport.h"
|
||||||
#endif
|
#endif
|
||||||
@ -207,13 +209,7 @@ public:
|
|||||||
FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); }
|
FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ls(
|
static void ls(const uint8_t lsflags);
|
||||||
TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false)
|
|
||||||
#if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT)
|
|
||||||
,
|
|
||||||
#endif
|
|
||||||
TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false)
|
|
||||||
);
|
|
||||||
|
|
||||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
static bool jobRecoverFileExists();
|
static bool jobRecoverFileExists();
|
||||||
@ -348,10 +344,7 @@ private:
|
|||||||
static int countItems(SdFile dir);
|
static int countItems(SdFile dir);
|
||||||
static void selectByIndex(SdFile dir, const uint8_t index);
|
static void selectByIndex(SdFile dir, const uint8_t index);
|
||||||
static void selectByName(SdFile dir, const char * const match);
|
static void selectByName(SdFile dir, const char * const match);
|
||||||
static void printListing(
|
static void printListing(SdFile parent, const char * const prepend, const uint8_t lsflags
|
||||||
SdFile parent, const char * const prepend
|
|
||||||
OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false)
|
|
||||||
OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false)
|
|
||||||
OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr)
|
OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_R
|
|||||||
EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \
|
EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \
|
||||||
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER Z_STEPPER_AUTO_ALIGN ADAPTIVE_STEP_SMOOTHING \
|
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER Z_STEPPER_AUTO_ALIGN ADAPTIVE_STEP_SMOOTHING \
|
||||||
STATUS_MESSAGE_SCROLLING LCD_SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME USE_M73_REMAINING_TIME \
|
STATUS_MESSAGE_SCROLLING LCD_SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME USE_M73_REMAINING_TIME \
|
||||||
LONG_FILENAME_HOST_SUPPORT SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \
|
LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \
|
||||||
|
SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \
|
||||||
MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
|
MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
|
||||||
LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \
|
LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \
|
||||||
SQUARE_WAVE_STEPPING TMC_DEBUG EXPERIMENTAL_SCURVE
|
SQUARE_WAVE_STEPPING TMC_DEBUG EXPERIMENTAL_SCURVE
|
||||||
|
Loading…
Reference in New Issue
Block a user