My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cardreader.h 2.9KB

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