Ver código fonte

Followup to SD menu optimization (#15252)

Tanguy Pruvot 5 anos atrás
pai
commit
15bea5043c

+ 4
- 1
Marlin/src/lcd/menu/menu_media.cpp Ver arquivo

127
 
127
 
128
   #if HAS_GRAPHICAL_LCD
128
   #if HAS_GRAPHICAL_LCD
129
     static uint16_t fileCnt;
129
     static uint16_t fileCnt;
130
+    static bool at_root;
130
     if (ui.first_page) {
131
     if (ui.first_page) {
131
       fileCnt = card.get_num_Files();
132
       fileCnt = card.get_num_Files();
132
       card.getWorkDirName();
133
       card.getWorkDirName();
134
+      at_root = card.filename[0] == '/';
133
     }
135
     }
134
   #else
136
   #else
135
     const uint16_t fileCnt = card.get_num_Files();
137
     const uint16_t fileCnt = card.get_num_Files();
136
     card.getWorkDirName();
138
     card.getWorkDirName();
139
+    const bool at_root = card.filename[0] == '/';
137
   #endif
140
   #endif
138
 
141
 
139
   START_MENU();
142
   START_MENU();
140
   MENU_BACK(MSG_MAIN);
143
   MENU_BACK(MSG_MAIN);
141
-  if (card.filename[0] == '/') {
144
+  if (at_root) {
142
     #if !PIN_EXISTS(SD_DETECT)
145
     #if !PIN_EXISTS(SD_DETECT)
143
       MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
146
       MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
144
     #endif
147
     #endif

+ 2
- 2
Marlin/src/sd/SdBaseFile.cpp Ver arquivo

273
  *
273
  *
274
  * \return true for success, false for failure.
274
  * \return true for success, false for failure.
275
  */
275
  */
276
-bool SdBaseFile::getFilename(char * const name) {
276
+bool SdBaseFile::getDosName(char * const name) {
277
   if (!isOpen()) return false;
277
   if (!isOpen()) return false;
278
 
278
 
279
   if (isRoot()) {
279
   if (isRoot()) {
957
  */
957
  */
958
 bool SdBaseFile::printName() {
958
 bool SdBaseFile::printName() {
959
   char name[FILENAME_LENGTH];
959
   char name[FILENAME_LENGTH];
960
-  if (!getFilename(name)) return false;
960
+  if (!getDosName(name)) return false;
961
   SERIAL_ECHO(name);
961
   SERIAL_ECHO(name);
962
   return true;
962
   return true;
963
 }
963
 }

+ 1
- 1
Marlin/src/sd/SdBaseFile.h Ver arquivo

286
    */
286
    */
287
   bool isRoot() const { return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; }
287
   bool isRoot() const { return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; }
288
 
288
 
289
-  bool getFilename(char * const name);
289
+  bool getDosName(char * const name);
290
   void ls(uint8_t flags = 0, uint8_t indent = 0);
290
   void ls(uint8_t flags = 0, uint8_t indent = 0);
291
 
291
 
292
   bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);
292
   bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);

+ 2
- 2
Marlin/src/sd/cardreader.cpp Ver arquivo

313
 void CardReader::printFilename() {
313
 void CardReader::printFilename() {
314
   if (file.isOpen()) {
314
   if (file.isOpen()) {
315
     char dosFilename[FILENAME_LENGTH];
315
     char dosFilename[FILENAME_LENGTH];
316
-    file.getFilename(dosFilename);
316
+    file.getDosName(dosFilename);
317
     SERIAL_ECHO(dosFilename);
317
     SERIAL_ECHO(dosFilename);
318
     #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
318
     #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
319
       getfilename(0, dosFilename);
319
       getfilename(0, dosFilename);
404
 }
404
 }
405
 
405
 
406
 void appendAtom(SdFile &file, char *& dst, uint8_t &cnt) {
406
 void appendAtom(SdFile &file, char *& dst, uint8_t &cnt) {
407
-  file.getFilename(dst);
407
+  file.getDosName(dst);
408
   while (*dst && cnt < MAXPATHNAMELENGTH) { dst++; cnt++; }
408
   while (*dst && cnt < MAXPATHNAMELENGTH) { dst++; cnt++; }
409
   if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; }
409
   if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; }
410
 }
410
 }

+ 1
- 1
Marlin/src/sd/cardreader.h Ver arquivo

120
   static inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
120
   static inline void setIndex(const uint32_t index) { sdpos = index; file.seekSet(index); }
121
   static inline uint32_t getIndex() { return sdpos; }
121
   static inline uint32_t getIndex() { return sdpos; }
122
   static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
122
   static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
123
-  static inline char* getWorkDirName() { workDir.getFilename(filename); return filename; }
123
+  static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; }
124
   static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
124
   static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
125
   static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
125
   static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
126
 
126
 

Carregando…
Cancelar
Salvar