My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cardreader.h 2.6KB

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