My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cardreader.h 3.0KB

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