My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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,bool replace_current=true);
  17. void openLogFile(char* name);
  18. void removeFile(char* name);
  19. void closefile(bool store_location=false);
  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 getAbsFilename(char *t);
  28. void ls();
  29. void chdir(const char * relpath);
  30. void updir();
  31. void setroot();
  32. FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
  33. FORCE_INLINE bool eof() { return sdpos>=filesize ;};
  34. FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
  35. FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
  36. FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
  37. FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
  38. public:
  39. bool saving;
  40. bool logging;
  41. bool sdprinting ;
  42. bool cardOK ;
  43. char filename[13];
  44. char longFilename[LONG_FILENAME_LENGTH];
  45. bool filenameIsDir;
  46. int lastnr; //last number of the autostart;
  47. private:
  48. SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
  49. uint16_t workDirDepth;
  50. Sd2Card card;
  51. SdVolume volume;
  52. SdFile file;
  53. #define SD_PROCEDURE_DEPTH 1
  54. #define MAXPATHNAMELENGTH (13*MAX_DIR_DEPTH+MAX_DIR_DEPTH+1)
  55. uint8_t file_subcall_ctr;
  56. uint32_t filespos[SD_PROCEDURE_DEPTH];
  57. char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
  58. uint32_t filesize;
  59. //int16_t n;
  60. unsigned long autostart_atmillis;
  61. uint32_t sdpos ;
  62. bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
  63. LsAction lsAction; //stored for recursion.
  64. 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.
  65. char* diveDirName;
  66. void lsDive(const char *prepend,SdFile parent);
  67. };
  68. extern CardReader card;
  69. #define IS_SD_PRINTING (card.sdprinting)
  70. #if (SDCARDDETECT > -1)
  71. # ifdef SDCARDDETECTINVERTED
  72. # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0)
  73. # else
  74. # define IS_SD_INSERTED (READ(SDCARDDETECT)==0)
  75. # endif //SDCARDTETECTINVERTED
  76. #else
  77. //If we don't have a card detect line, aways asume the card is inserted
  78. # define IS_SD_INSERTED true
  79. #endif
  80. #else
  81. #define IS_SD_PRINTING (false)
  82. #endif //SDSUPPORT
  83. #endif