Prusa3d Marlin fork
SdFile.h
Go to the documentation of this file.
1 /* Arduino SdFat Library
2  * Copyright (C) 2009 by William Greiman
3  *
4  * This file is part of the Arduino SdFat Library
5  *
6  * This Library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This Library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with the Arduino SdFat Library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
24 #include "Marlin.h"
25 
26 #ifdef SDSUPPORT
27 #include "SdBaseFile.h"
28 //#include <Print.h>
29 #ifndef SdFile_h
30 #define SdFile_h
31 //------------------------------------------------------------------------------
36 class SdFile : public SdBaseFile/*, public Print*/ {
37  // GCode filtering vars and methods - due to optimization reasons not wrapped in a separate class
38 
39  // beware - this read ptr is manipulated inside just 2 methods - readFilteredGcode and gfReset
40  // If you even want to call gfReset from readFilteredGcode, you must make sure
41  // to update gfReadPtr inside readFilteredGcode from a local copy (see explanation of this trick in readFilteredGcode)
42  const uint8_t *gfReadPtr;
43 
44  uint32_t gfBlock; // remember the current file block to be kept in cache - due to reuse of the memory, the block may fall out a must be read back
45  uint16_t gfOffset;
46 
47  const uint8_t *gfBlockBuffBegin()const;
48 
49  void gfReset();
50 
51  bool gfEnsureBlock();
52  bool gfComputeNextFileBlock();
53  void gfUpdateCurrentPosition(uint16_t inc);
54 public:
55  SdFile() {}
56  SdFile(const char* name, uint8_t oflag);
57  #if ARDUINO >= 100
58  size_t write(uint8_t b);
59  #else
60  void write(uint8_t b);
61  #endif
62 
63  bool openFilteredGcode(SdBaseFile* dirFile, const char* path);
64  int16_t readFilteredGcode();
65  bool seekSetFilteredGcode(uint32_t pos);
66  int16_t write(const void* buf, uint16_t nbyte);
67  void write(const char* str);
68  void write_P(PGM_P str);
69  void writeln_P(PGM_P str);
70 };
71 #endif // SdFile_h
72 
73 
74 #endif
SdBaseFile class.
Base class for SdFile with Print and C++ streams.
Definition: SdBaseFile.h:182
SdBaseFile with Print.
Definition: SdFile.h:36
void writeln_P(PGM_P str)
Definition: SdFile.cpp:277
void write_P(PGM_P str)
Definition: SdFile.cpp:269
size_t write(uint8_t b)
Definition: SdFile.cpp:246