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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef CARDREADER_H
  2. #define CARDREADER_H
  3. #ifdef SDSUPPORT
  4. #define MAX_DIR_DEPTH 10
  5. #include "SdFile.h"
  6. enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
  7. class CardReader
  8. {
  9. public:
  10. CardReader();
  11. void initsd();
  12. void write_command(char *buf);
  13. //files auto[0-9].g on the sd card are performed in a row
  14. //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
  15. void checkautostart(bool x);
  16. void openFile(char* name,bool read);
  17. void openLogFile(char* name);
  18. void removeFile(char* name);
  19. void closefile();
  20. void release();
  21. void startFileprint();
  22. void pauseSDPrint();
  23. void getStatus();
  24. void printingHasFinished();
  25. void getfilename(const uint8_t nr);
  26. uint16_t getnrfilenames();
  27. void ls();
  28. void chdir(const char * relpath);
  29. void updir();
  30. void setroot();
  31. FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
  32. FORCE_INLINE bool eof() { return sdpos>=filesize ;};
  33. FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  34. FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
  35. FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
  36. FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
  37. public:
  38. bool saving;
  39. bool logging;
  40. bool sdprinting ;
  41. bool cardOK ;
  42. char filename[13];
  43. char longFilename[LONG_FILENAME_LENGTH];
  44. bool filenameIsDir;
  45. int lastnr; //last number of the autostart;
  46. private:
  47. SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
  48. uint16_t workDirDepth;
  49. Sd2Card card;
  50. SdVolume volume;
  51. SdFile file;
  52. uint32_t filesize;
  53. //int16_t n;
  54. unsigned long autostart_atmillis;
  55. uint32_t sdpos ;
  56. bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
  57. LsAction lsAction; //stored for recursion.
  58. 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.
  59. char* diveDirName;
  60. void lsDive(const char *prepend,SdFile parent);
  61. };
  62. extern CardReader card;
  63. #define IS_SD_PRINTING (card.sdprinting)
  64. #if (SDCARDDETECT > -1)
  65. # ifdef SDCARDDETECTINVERTED
  66. # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0)
  67. # else
  68. # define IS_SD_INSERTED (READ(SDCARDDETECT)==0)
  69. # endif //SDCARDTETECTINVERTED
  70. #else
  71. //If we don't have a card detect line, aways asume the card is inserted
  72. # define IS_SD_INSERTED true
  73. #endif
  74. #else
  75. #define IS_SD_PRINTING (false)
  76. #endif //SDSUPPORT
  77. #endif