My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cardreader.h 2.8KB

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. inline bool eof() { return sdpos>=filesize ;};
  28. inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  29. inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
  30. inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
  31. 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. inline CardReader(){};
  59. inline static void initsd(){};
  60. inline static void write_command(char *buf){};
  61. inline static void checkautostart(bool x) {};
  62. inline static void openFile(char* name,bool read){};
  63. inline static void closefile() {};
  64. inline static void release(){};
  65. inline static void startFileprint(){};
  66. inline static void startFilewrite(char *name){};
  67. inline static void pauseSDPrint(){};
  68. inline static void getStatus(){};
  69. inline static void selectFile(char* name){};
  70. inline static void getfilename(const uint8_t nr){};
  71. inline static uint8_t getnrfilenames(){return 0;};
  72. inline static void ls() {};
  73. inline static bool eof() {return true;};
  74. inline static char get() {return 0;};
  75. inline static void setIndex(){};
  76. inline uint8_t percentDone(){return 0;};
  77. };
  78. #endif //SDSUPPORT
  79. #endif