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

cardreader.h 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef __CARDREADERH
  2. #define __CARDREADERH
  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 closefile();
  17. void release();
  18. void startFileprint();
  19. void pauseSDPrint();
  20. void getStatus();
  21. void getfilename(const uint8_t nr);
  22. uint16_t getnrfilenames();
  23. void ls();
  24. void chdir(const char * relpath);
  25. void updir();
  26. inline bool eof() { return sdpos>=filesize ;};
  27. inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  28. inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
  29. inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
  30. inline char* getWorkDirName(){workDir.getFilename(filename);return filename;};
  31. public:
  32. bool saving;
  33. bool sdprinting ;
  34. bool cardOK ;
  35. char filename[11];
  36. bool filenameIsDir;
  37. private:
  38. SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
  39. Sd2Card card;
  40. SdVolume volume;
  41. SdFile file;
  42. uint32_t filesize;
  43. //int16_t n;
  44. unsigned long autostart_atmillis;
  45. uint32_t sdpos ;
  46. bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
  47. LsAction lsAction; //stored for recursion.
  48. 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.
  49. char* diveDirName;
  50. void lsDive(char *prepend,SdFile parent);
  51. };
  52. #else
  53. #define dir_t bool
  54. class CardReader
  55. {
  56. public:
  57. inline CardReader(){};
  58. inline static void initsd(){};
  59. inline static void write_command(char *buf){};
  60. inline static void checkautostart(bool x) {};
  61. inline static void openFile(char* name,bool read){};
  62. inline static void closefile() {};
  63. inline static void release(){};
  64. inline static void startFileprint(){};
  65. inline static void startFilewrite(char *name){};
  66. inline static void pauseSDPrint(){};
  67. inline static void getStatus(){};
  68. inline static void selectFile(char* name){};
  69. inline static void getfilename(const uint8_t nr){};
  70. inline static uint8_t getnrfilenames(){return 0;};
  71. inline static void ls() {};
  72. inline static bool eof() {return true;};
  73. inline static char get() {return 0;};
  74. inline static void setIndex(){};
  75. inline uint8_t percentDone(){return 0;};
  76. };
  77. #endif //SDSUPPORT
  78. #endif