🎨 Fewer serial macros

This commit is contained in:
Scott Lahteine
2021-09-09 04:57:05 -05:00
committed by Scott Lahteine
parent 6d96c221bd
commit b661795ae5
159 changed files with 1002 additions and 1014 deletions

View File

@ -379,7 +379,7 @@ void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=fa
// Go to the next segment
while (path[++i]) { }
//SERIAL_ECHOLNPAIR("Looking for segment: ", segment);
//SERIAL_ECHOLNPGM("Looking for segment: ", segment);
// Find the item, setting the long filename
diveDir.rewind();
@ -399,7 +399,7 @@ void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=fa
if (!dir.open(&diveDir, segment, O_READ)) {
SERIAL_EOL();
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(STR_SD_CANT_OPEN_SUBDIR, segment);
SERIAL_ECHOPGM(STR_SD_CANT_OPEN_SUBDIR, segment);
break;
}
@ -475,7 +475,7 @@ void CardReader::manage_media() {
uint8_t stat = uint8_t(IS_SD_INSERTED());
if (stat == prev_stat) return;
DEBUG_ECHOLNPAIR("SD: Status changed from ", prev_stat, " to ", stat);
DEBUG_ECHOLNPGM("SD: Status changed from ", prev_stat, " to ", stat);
flag.workDirIsRoot = true; // Return to root on mount/release
@ -606,7 +606,7 @@ void CardReader::getAbsFilenameInCWD(char *dst) {
}
void openFailed(const char * const fname) {
SERIAL_ECHOLNPAIR(STR_SD_OPEN_FILE_FAIL, fname, ".");
SERIAL_ECHOLNPGM(STR_SD_OPEN_FILE_FAIL, fname, ".");
}
void announceOpen(const uint8_t doing, const char * const path) {
@ -615,7 +615,7 @@ void announceOpen(const uint8_t doing, const char * const path) {
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Now ");
SERIAL_ECHOPGM_P(doing == 1 ? PSTR("doing") : PSTR("fresh"));
SERIAL_ECHOLNPAIR(" file: ", path);
SERIAL_ECHOLNPGM(" file: ", path);
}
}
@ -678,7 +678,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ
{ // Don't remove this block, as the PORT_REDIRECT is a RAII
PORT_REDIRECT(SerialMask::All);
SERIAL_ECHOLNPAIR(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize);
SERIAL_ECHOLNPGM(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize);
SERIAL_ECHOLNPGM(STR_SD_FILE_SELECTED);
}
@ -690,7 +690,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ
}
inline void echo_write_to_file(const char * const fname) {
SERIAL_ECHOLNPAIR(STR_SD_WRITE_TO_FILE, fname);
SERIAL_ECHOLNPGM(STR_SD_WRITE_TO_FILE, fname);
}
//
@ -730,7 +730,7 @@ void CardReader::openFileWrite(const char * const path) {
bool CardReader::fileExists(const char * const path) {
if (!isMounted()) return false;
DEBUG_ECHOLNPAIR("fileExists: ", path);
DEBUG_ECHOLNPGM("fileExists: ", path);
// Dive to the file's directory and get the base name
SdFile *diveDir = nullptr;
@ -762,21 +762,21 @@ void CardReader::removeFile(const char * const name) {
if (!fname) return;
#if ENABLED(SDCARD_READONLY)
SERIAL_ECHOLNPAIR("Deletion failed (read-only), File: ", fname, ".");
SERIAL_ECHOLNPGM("Deletion failed (read-only), File: ", fname, ".");
#else
if (file.remove(itsDirPtr, fname)) {
SERIAL_ECHOLNPAIR("File deleted:", fname);
SERIAL_ECHOLNPGM("File deleted:", fname);
sdpos = 0;
TERN_(SDCARD_SORT_ALPHA, presort());
}
else
SERIAL_ECHOLNPAIR("Deletion failed, File: ", fname, ".");
SERIAL_ECHOLNPGM("Deletion failed, File: ", fname, ".");
#endif
}
void CardReader::report_status() {
if (isPrinting()) {
SERIAL_ECHOPAIR(STR_SD_PRINTING_BYTE, sdpos);
SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE, sdpos);
SERIAL_CHAR('/');
SERIAL_ECHOLN(filesize);
}
@ -924,12 +924,12 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con
// Parsing the path string
const char *atom_ptr = path;
DEBUG_ECHOLNPAIR(" path = '", path, "'");
DEBUG_ECHOLNPGM(" path = '", path, "'");
if (path[0] == '/') { // Starting at the root directory?
inDirPtr = &root;
atom_ptr++;
DEBUG_ECHOLNPAIR(" CWD to root: ", hex_address((void*)inDirPtr));
DEBUG_ECHOLNPGM(" CWD to root: ", hex_address((void*)inDirPtr));
if (update_cwd) workDirDepth = 0; // The cwd can be updated for the benefit of sub-programs
}
else
@ -937,7 +937,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con
startDirPtr = inDirPtr;
DEBUG_ECHOLNPAIR(" startDirPtr = ", hex_address((void*)startDirPtr));
DEBUG_ECHOLNPGM(" startDirPtr = ", hex_address((void*)startDirPtr));
while (atom_ptr) {
// Find next subdirectory delimiter
@ -954,7 +954,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con
if (echo) SERIAL_ECHOLN(dosSubdirname);
DEBUG_ECHOLNPAIR(" sub = ", hex_address((void*)sub));
DEBUG_ECHOLNPGM(" sub = ", hex_address((void*)sub));
// Open inDirPtr (closing first)
sub->close();
@ -966,24 +966,24 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con
// Close inDirPtr if not at starting-point
if (inDirPtr != startDirPtr) {
DEBUG_ECHOLNPAIR(" closing inDirPtr: ", hex_address((void*)inDirPtr));
DEBUG_ECHOLNPGM(" closing inDirPtr: ", hex_address((void*)inDirPtr));
inDirPtr->close();
}
// inDirPtr now subDir
inDirPtr = sub;
DEBUG_ECHOLNPAIR(" inDirPtr = sub: ", hex_address((void*)inDirPtr));
DEBUG_ECHOLNPGM(" inDirPtr = sub: ", hex_address((void*)inDirPtr));
// Update workDirParents and workDirDepth
if (update_cwd) {
DEBUG_ECHOLNPAIR(" update_cwd");
DEBUG_ECHOLNPGM(" update_cwd");
if (workDirDepth < MAX_DIR_DEPTH)
workDirParents[workDirDepth++] = *inDirPtr;
}
// Point sub at the other scratch object
sub = (inDirPtr != &newDir1) ? &newDir1 : &newDir2;
DEBUG_ECHOLNPAIR(" swapping sub = ", hex_address((void*)sub));
DEBUG_ECHOLNPGM(" swapping sub = ", hex_address((void*)sub));
// Next path atom address
atom_ptr = name_end + 1;
@ -991,12 +991,12 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con
if (update_cwd) {
workDir = *inDirPtr;
DEBUG_ECHOLNPAIR(" final workDir = ", hex_address((void*)inDirPtr));
DEBUG_ECHOLNPGM(" final workDir = ", hex_address((void*)inDirPtr));
flag.workDirIsRoot = (workDirDepth == 0);
TERN_(SDCARD_SORT_ALPHA, presort());
}
DEBUG_ECHOLNPAIR(" returning string ", atom_ptr ?: "nullptr");
DEBUG_ECHOLNPGM(" returning string ", atom_ptr ?: "nullptr");
return atom_ptr;
}
@ -1138,9 +1138,9 @@ void CardReader::cdroot() {
selectFileByIndex(i);
SET_SORTNAME(i);
SET_SORTSHORT(i);
// char out[30];
// sprintf_P(out, PSTR("---- %i %s %s"), i, flag.filenameIsDir ? "D" : " ", sortnames[i]);
// SERIAL_ECHOLN(out);
//char out[30];
//sprintf_P(out, PSTR("---- %i %s %s"), i, flag.filenameIsDir ? "D" : " ", sortnames[i]);
//SERIAL_ECHOLN(out);
#if HAS_FOLDER_SORTING
const uint16_t bit = i & 0x07, ind = i >> 3;
if (bit == 0) isDir[ind] = 0x00;

View File

@ -34,9 +34,9 @@
#define USB_STARTUP_DELAY 0
// uncomment to get 'printf' console debugging. NOT FOR UNO!
//#define HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
//#define BS_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
//#define MAX_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
//#define HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);}
//#define BS_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);}
//#define MAX_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPGM("UHS:",s);}
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
@ -170,7 +170,7 @@ void DiskIODriver_USBFlash::idle() {
UHS_USB_DEBUG(CONFIGURING_DONE);
UHS_USB_DEBUG(RUNNING);
default:
SERIAL_ECHOLNPAIR("UHS_USB_HOST_STATE: ", task_state);
SERIAL_ECHOLNPGM("UHS_USB_HOST_STATE: ", task_state);
break;
}
}
@ -273,14 +273,14 @@ bool DiskIODriver_USBFlash::init(const uint8_t, const pin_t) {
#if USB_DEBUG >= 1
const uint32_t sectorSize = bulk.GetSectorSize(0);
if (sectorSize != 512) {
SERIAL_ECHOLNPAIR("Expecting sector size of 512. Got: ", sectorSize);
SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize);
return false;
}
#endif
#if USB_DEBUG >= 3
lun0_capacity = bulk.GetCapacity(0);
SERIAL_ECHOLNPAIR("LUN Capacity (in blocks): ", lun0_capacity);
SERIAL_ECHOLNPGM("LUN Capacity (in blocks): ", lun0_capacity);
#endif
return true;
}
@ -299,11 +299,11 @@ bool DiskIODriver_USBFlash::readBlock(uint32_t block, uint8_t *dst) {
if (!isInserted()) return false;
#if USB_DEBUG >= 3
if (block >= lun0_capacity) {
SERIAL_ECHOLNPAIR("Attempt to read past end of LUN: ", block);
SERIAL_ECHOLNPGM("Attempt to read past end of LUN: ", block);
return false;
}
#if USB_DEBUG >= 4
SERIAL_ECHOLNPAIR("Read block ", block);
SERIAL_ECHOLNPGM("Read block ", block);
#endif
#endif
return bulk.Read(0, block, 512, 1, dst) == 0;
@ -313,11 +313,11 @@ bool DiskIODriver_USBFlash::writeBlock(uint32_t block, const uint8_t *src) {
if (!isInserted()) return false;
#if USB_DEBUG >= 3
if (block >= lun0_capacity) {
SERIAL_ECHOLNPAIR("Attempt to write past end of LUN: ", block);
SERIAL_ECHOLNPGM("Attempt to write past end of LUN: ", block);
return false;
}
#if USB_DEBUG >= 4
SERIAL_ECHOLNPAIR("Write block ", block);
SERIAL_ECHOLNPGM("Write block ", block);
#endif
#endif
return bulk.Write(0, block, 512, 1, src) == 0;

View File

@ -121,7 +121,7 @@ bool MAX3421e::start() {
const uint8_t revision = regRd(rREVISION);
if (revision == 0x00 || revision == 0xFF) {
SERIAL_ECHOLNPAIR("Revision register appears incorrect on MAX3421e initialization. Got ", revision);
SERIAL_ECHOLNPGM("Revision register appears incorrect on MAX3421e initialization. Got ", revision);
return false;
}