From b726511a3bc2db618e3f346431eb7f703fb501fd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Dec 2014 20:22:33 -0800 Subject: [PATCH] A few constants where they belong --- Marlin/Marlin_main.cpp | 4 ++-- Marlin/SdFatConfig.h | 4 +++- Marlin/cardreader.cpp | 10 +++++----- Marlin/cardreader.h | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 616b7a1906..f65df7736b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -429,7 +429,7 @@ void enquecommand(const char *cmd) //this is dangerous if a mixing of serial and this happens strcpy(&(cmdbuffer[bufindw][0]),cmd); SERIAL_ECHO_START; - SERIAL_ECHOPGM("enqueing \""); + SERIAL_ECHOPGM(MSG_Enqueing); SERIAL_ECHO(cmdbuffer[bufindw]); SERIAL_ECHOLNPGM("\""); bufindw= (bufindw + 1)%BUFSIZE; @@ -444,7 +444,7 @@ void enquecommand_P(const char *cmd) //this is dangerous if a mixing of serial and this happens strcpy_P(&(cmdbuffer[bufindw][0]),cmd); SERIAL_ECHO_START; - SERIAL_ECHOPGM("enqueing \""); + SERIAL_ECHOPGM(MSG_Enqueing); SERIAL_ECHO(cmdbuffer[bufindw]); SERIAL_ECHOLNPGM("\""); bufindw= (bufindw + 1)%BUFSIZE; diff --git a/Marlin/SdFatConfig.h b/Marlin/SdFatConfig.h index 710b1f7924..742f5aa358 100644 --- a/Marlin/SdFatConfig.h +++ b/Marlin/SdFatConfig.h @@ -113,8 +113,10 @@ uint8_t const SOFT_SPI_SCK_PIN = 13; */ /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */ #define MAX_VFAT_ENTRIES (2) +/** Number of UTF-16 characters per entry */ +#define FILENAME_LENGTH 13 /** Total size of the buffer used to store the long filenames */ -#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1) +#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1) #endif // SdFatConfig_h diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index d2fb418fba..6bf43b918a 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -60,8 +60,8 @@ void CardReader::lsDive(const char *prepend,SdFile parent) if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint { - char path[13*2]; - char lfilename[13]; + char path[FILENAME_LENGTH*2]; + char lfilename[FILENAME_LENGTH]; createFilename(lfilename,p); path[0]=0; @@ -235,7 +235,7 @@ void CardReader::getAbsFilename(char *t) while(*t!=0 && cnt< MAXPATHNAMELENGTH) {t++;cnt++;} //crawl counter forward. } - if(cnt0 && dirname_end>dirname_start) { - char subdirname[13]; + char subdirname[FILENAME_LENGTH]; strncpy(subdirname, dirname_start, dirname_end-dirname_start); subdirname[dirname_end-dirname_start]=0; SERIAL_ECHOLN(subdirname); @@ -401,7 +401,7 @@ void CardReader::removeFile(char* name) //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name)); if(dirname_end>0 && dirname_end>dirname_start) { - char subdirname[13]; + char subdirname[FILENAME_LENGTH]; strncpy(subdirname, dirname_start, dirname_end-dirname_start); subdirname[dirname_end-dirname_start]=0; SERIAL_ECHOLN(subdirname); diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index 78f7148b1f..fa38508e3b 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -52,7 +52,7 @@ public: bool logging; bool sdprinting ; bool cardOK ; - char filename[13]; + char filename[FILENAME_LENGTH]; char longFilename[LONG_FILENAME_LENGTH]; bool filenameIsDir; int lastnr; //last number of the autostart; @@ -63,7 +63,7 @@ private: SdVolume volume; SdFile file; #define SD_PROCEDURE_DEPTH 1 - #define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1) + #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1) uint8_t file_subcall_ctr; uint32_t filespos[SD_PROCEDURE_DEPTH]; char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];