My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

cardreader.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef CARDREADER_H
  2. #define CARDREADER_H
  3. #ifdef SDSUPPORT
  4. #include "SdFile.h"
  5. enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
  6. class CardReader
  7. {
  8. public:
  9. CardReader();
  10. void initsd();
  11. void write_command(char *buf);
  12. //files auto[0-9].g on the sd card are performed in a row
  13. //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
  14. void checkautostart(bool x);
  15. void openFile(char* name,bool read);
  16. void removeFile(char* name);
  17. void closefile();
  18. void release();
  19. void startFileprint();
  20. void pauseSDPrint();
  21. void getStatus();
  22. void printingHasFinished();
  23. void getfilename(const uint8_t nr);
  24. uint16_t getnrfilenames();
  25. void ls();
  26. void chdir(const char * relpath);
  27. void updir();
  28. void setroot();
  29. FORCE_INLINE bool eof() { return sdpos>=filesize ;};
  30. FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  31. FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
  32. FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
  33. FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
  34. public:
  35. bool saving;
  36. bool sdprinting ;
  37. bool cardOK ;
  38. char filename[13];
  39. char longFilename[LONG_FILENAME_LENGTH];
  40. bool filenameIsDir;
  41. int lastnr; //last number of the autostart;
  42. private:
  43. SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
  44. Sd2Card card;
  45. SdVolume volume;
  46. SdFile file;
  47. uint32_t filesize;
  48. //int16_t n;
  49. unsigned long autostart_atmillis;
  50. uint32_t sdpos ;
  51. bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
  52. LsAction lsAction; //stored for recursion.
  53. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
  54. char* diveDirName;
  55. void lsDive(const char *prepend,SdFile parent);
  56. };
  57. extern CardReader card;
  58. #define IS_SD_PRINTING (card.sdprinting)
  59. #if (SDCARDDETECT > -1)
  60. # ifdef SDCARDDETECTINVERTED
  61. # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0)
  62. # else
  63. # define IS_SD_INSERTED (READ(SDCARDDETECT)==0)
  64. # endif //SDCARDTETECTINVERTED
  65. #else
  66. //If we don't have a card detect line, aways asume the card is inserted
  67. # define IS_SD_INSERTED true
  68. #endif
  69. #else
  70. #define IS_SD_PRINTING (false)
  71. #endif //SDSUPPORT
  72. #endif