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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 startFilewrite(char *name);
  20. void pauseSDPrint();
  21. void getStatus();
  22. void cd(char * absolutPath);
  23. //void selectFile(char* name);
  24. void getfilename(const uint8_t nr);
  25. uint16_t getnrfilenames();
  26. void ls();
  27. void lsDive(char *prepend,SdFile parent);
  28. inline bool eof() { return sdpos>=filesize ;};
  29. inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  30. inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
  31. inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
  32. public:
  33. bool saving;
  34. bool sdprinting ;
  35. bool cardOK ;
  36. char filename[11];
  37. private:
  38. SdFile root,*curDir;
  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. };
  51. #else
  52. class CardReader
  53. {
  54. public:
  55. inline CardReader(){};
  56. inline static void initsd(){};
  57. inline static void write_command(char *buf){};
  58. inline static void checkautostart(bool x) {};
  59. inline static void closefile() {};
  60. inline static void release(){};
  61. inline static void startFileprint(){};
  62. inline static void startFilewrite(char *name){};
  63. inline static void pauseSDPrint(){};
  64. inline static void getStatus(){};
  65. inline static void selectFile(char* name){};
  66. inline static void getfilename(const uint8_t nr){};
  67. inline static uint8_t getnrfilenames(){return 0;};
  68. inline static void ls() {};
  69. inline static bool eof() {return true;};
  70. inline static char get() {return 0;};
  71. inline static void setIndex(){};
  72. };
  73. #endif //SDSUPPORT
  74. #endif