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.7KB

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