Selaa lähdekoodia

Move SD Fat library out of main src

odewdney 10 vuotta sitten
vanhempi
commit
f84ff4ba7d

+ 1
- 4
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/Sd2Card.cpp Näytä tiedosto

@@ -17,9 +17,8 @@
17 17
  * along with the Arduino Sd2Card Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
20
+#include "SdFat.h"
21 21
 
22
-#ifdef SDSUPPORT
23 22
 #include "Sd2Card.h"
24 23
 //------------------------------------------------------------------------------
25 24
 #ifndef SOFTWARE_SPI
@@ -719,5 +718,3 @@ bool Sd2Card::writeStop() {
719 718
   chipSelectHigh();
720 719
   return false;
721 720
 }
722
-
723
-#endif

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/Sd2Card.h Näytä tiedosto

@@ -18,9 +18,6 @@
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20 20
 
21
-#include "Marlin.h"
22
-#ifdef SDSUPPORT
23
-
24 21
 #ifndef Sd2Card_h
25 22
 #define Sd2Card_h
26 23
 /**
@@ -238,6 +235,3 @@ class Sd2Card {
238 235
   bool writeData(uint8_t token, const uint8_t* src);
239 236
 };
240 237
 #endif  // Sd2Card_h
241
-
242
-
243
-#endif

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/Sd2PinMap.h Näytä tiedosto

@@ -18,9 +18,6 @@
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20 20
 // Warning this file was generated by a program.
21
-#include "Marlin.h"
22
-#ifdef SDSUPPORT
23
-
24 21
 #ifndef Sd2PinMap_h
25 22
 #define Sd2PinMap_h
26 23
 #include <avr/io.h>
@@ -363,6 +360,3 @@ static inline __attribute__((always_inline))
363 360
   }
364 361
 }
365 362
 #endif  // Sd2PinMap_h
366
-
367
-
368
-#endif

+ 26
- 23
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdBaseFile.cpp Näytä tiedosto

@@ -17,9 +17,8 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-
21
-#include "Marlin.h"
22
-#ifdef SDSUPPORT
20
+#include "SdFat.h"
21
+#include <Print.h>
23 22
 
24 23
 #include "SdBaseFile.h"
25 24
 //------------------------------------------------------------------------------
@@ -315,14 +314,14 @@ void SdBaseFile::getpos(fpos_t* pos) {
315 314
  * \param[in] indent Amount of space before file name. Used for recursive
316 315
  * list to indicate subdirectory level.
317 316
  */
318
-void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
317
+void SdBaseFile::ls(Print *p, uint8_t flags, uint8_t indent) {
319 318
   rewind();
320 319
   int8_t status;
321
-  while ((status = lsPrintNext( flags, indent))) {
320
+  while ((status = lsPrintNext( p, flags, indent))) {
322 321
     if (status > 1 && (flags & LS_R)) {
323 322
       uint16_t index = curPosition()/32 - 1;
324 323
       SdBaseFile s;
325
-      if (s.open(this, index, O_READ)) s.ls( flags, indent + 2);
324
+      if (s.open(this, index, O_READ)) s.ls( p, flags, indent + 2);
326 325
       seekSet(32 * (index + 1));
327 326
     }
328 327
   }
@@ -330,7 +329,8 @@ void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
330 329
 //------------------------------------------------------------------------------
331 330
 // saves 32 bytes on stack for ls recursion
332 331
 // return 0 - EOF, 1 - normal file, or 2 - directory
333
-int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) {
332
+int8_t SdBaseFile::lsPrintNext( Print *p, uint8_t flags, uint8_t indent) {
333
+	Print &MYSERIAL = *p;
334 334
   dir_t dir;
335 335
   uint8_t w = 0;
336 336
 
@@ -365,9 +365,9 @@ int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) {
365 365
   // print modify date/time if requested
366 366
   if (flags & LS_DATE) {
367 367
     MYSERIAL.write(' ');
368
-    printFatDate( dir.lastWriteDate);
368
+    printFatDate( p, dir.lastWriteDate);
369 369
     MYSERIAL.write(' ');
370
-    printFatTime( dir.lastWriteTime);
370
+    printFatTime( p, dir.lastWriteTime);
371 371
   }
372 372
   // print size if requested
373 373
   if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
@@ -939,8 +939,8 @@ int SdBaseFile::peek() {
939 939
  * \param[in] width Blank fill name if length is less than \a width.
940 940
  * \param[in] printSlash Print '/' after directory names if true.
941 941
  */
942
-void SdBaseFile::printDirName(const dir_t& dir,
943
-  uint8_t width, bool printSlash) {
942
+void SdBaseFile::printDirName(Print *p, const dir_t& dir, uint8_t width, bool printSlash) {
943
+		Print &MYSERIAL = *p;
944 944
   uint8_t w = 0;
945 945
   for (uint8_t i = 0; i < 11; i++) {
946 946
     if (dir.name[i] == ' ')continue;
@@ -962,7 +962,8 @@ void SdBaseFile::printDirName(const dir_t& dir,
962 962
 }
963 963
 //------------------------------------------------------------------------------
964 964
 // print uint8_t with width 2
965
-static void print2u( uint8_t v) {
965
+static void print2u( Print *p, uint8_t v) {
966
+	Print &MYSERIAL = *p;
966 967
   if (v < 10) MYSERIAL.write('0');
967 968
   MYSERIAL.print(v, DEC);
968 969
 }
@@ -982,12 +983,14 @@ static void print2u( uint8_t v) {
982 983
  * \param[in] pr Print stream for output.
983 984
  * \param[in] fatDate The date field from a directory entry.
984 985
  */
985
-void SdBaseFile::printFatDate(uint16_t fatDate) {
986
+void SdBaseFile::printFatDate(Print *p, uint16_t fatDate) {
987
+	Print &MYSERIAL = *p;
988
+
986 989
   MYSERIAL.print(FAT_YEAR(fatDate));
987 990
   MYSERIAL.write('-');
988
-  print2u( FAT_MONTH(fatDate));
991
+  print2u( p, FAT_MONTH(fatDate));
989 992
   MYSERIAL.write('-');
990
-  print2u( FAT_DAY(fatDate));
993
+  print2u( p, FAT_DAY(fatDate));
991 994
 }
992 995
 
993 996
 //------------------------------------------------------------------------------
@@ -998,12 +1001,14 @@ void SdBaseFile::printFatDate(uint16_t fatDate) {
998 1001
  * \param[in] pr Print stream for output.
999 1002
  * \param[in] fatTime The time field from a directory entry.
1000 1003
  */
1001
-void SdBaseFile::printFatTime( uint16_t fatTime) {
1002
-  print2u( FAT_HOUR(fatTime));
1004
+void SdBaseFile::printFatTime( Print *p, uint16_t fatTime) {
1005
+	Print &MYSERIAL = *p;
1006
+
1007
+  print2u( p, FAT_HOUR(fatTime));
1003 1008
   MYSERIAL.write(':');
1004
-  print2u( FAT_MINUTE(fatTime));
1009
+  print2u( p, FAT_MINUTE(fatTime));
1005 1010
   MYSERIAL.write(':');
1006
-  print2u( FAT_SECOND(fatTime));
1011
+  print2u( p, FAT_SECOND(fatTime));
1007 1012
 }
1008 1013
 //------------------------------------------------------------------------------
1009 1014
 /** Print a file's name to Serial
@@ -1011,7 +1016,8 @@ void SdBaseFile::printFatTime( uint16_t fatTime) {
1011 1016
  * \return The value one, true, is returned for success and
1012 1017
  * the value zero, false, is returned for failure.
1013 1018
  */
1014
-bool SdBaseFile::printName() {
1019
+bool SdBaseFile::printName(Print *p) {
1020
+	Print &MYSERIAL = *p;
1015 1021
   char name[13];
1016 1022
   if (!getFilename(name)) return false;
1017 1023
   MYSERIAL.print(name);
@@ -1820,6 +1826,3 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
1820 1826
 #if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
1821 1827
 void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0;  // NOLINT
1822 1828
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
1823
-
1824
-
1825
-#endif

+ 8
- 11
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdBaseFile.h Näytä tiedosto

@@ -17,16 +17,12 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22
-
23 20
 #ifndef SdBaseFile_h
24 21
 #define SdBaseFile_h
25 22
 /**
26 23
  * \file
27 24
  * \brief SdBaseFile class
28 25
  */
29
-#include "Marlin.h"
30 26
 #include "SdFatConfig.h"
31 27
 #include "SdVolume.h"
32 28
 //------------------------------------------------------------------------------
@@ -174,6 +170,8 @@ static inline uint8_t FAT_SECOND(uint16_t fatTime) {
174 170
 uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
175 171
 /** Default time for file timestamp is 1 am */
176 172
 uint16_t const FAT_DEFAULT_TIME = (1 << 11);
173
+
174
+class Print;
177 175
 //------------------------------------------------------------------------------
178 176
 /**
179 177
  * \class SdBaseFile
@@ -266,7 +264,7 @@ class SdBaseFile {
266 264
   bool isRoot() const {
267 265
     return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
268 266
   }
269
-  void ls( uint8_t flags = 0, uint8_t indent = 0);
267
+  void ls( Print *p, uint8_t flags = 0, uint8_t indent = 0);
270 268
   bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);
271 269
   // alias for backward compactability
272 270
   bool makeDir(SdBaseFile* dir, const char* path) {
@@ -278,9 +276,9 @@ class SdBaseFile {
278 276
   bool openNext(SdBaseFile* dirFile, uint8_t oflag);
279 277
   bool openRoot(SdVolume* vol);
280 278
   int peek();
281
-  static void printFatDate(uint16_t fatDate);
282
-  static void printFatTime( uint16_t fatTime);
283
-  bool printName();
279
+  static void printFatDate(Print *p, uint16_t fatDate);
280
+  static void printFatTime(Print *p, uint16_t fatTime);
281
+  bool printName(Print *p);
284 282
   int16_t read();
285 283
   int16_t read(void* buf, uint16_t nbyte);
286 284
   int8_t readDir(dir_t* dir, char* longFilename);
@@ -352,7 +350,7 @@ class SdBaseFile {
352 350
   bool addCluster();
353 351
   bool addDirCluster();
354 352
   dir_t* cacheDirEntry(uint8_t action);
355
-  int8_t lsPrintNext( uint8_t flags, uint8_t indent);
353
+  int8_t lsPrintNext( Print *p, uint8_t flags, uint8_t indent);
356 354
   static bool make83Name(const char* str, uint8_t* name, const char** ptr);
357 355
   bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
358 356
   bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
@@ -360,7 +358,7 @@ class SdBaseFile {
360 358
   dir_t* readDirCache();
361 359
 //------------------------------------------------------------------------------
362 360
 // to be deleted
363
-  static void printDirName( const dir_t& dir,
361
+  static void printDirName( Print *p, const dir_t& dir,
364 362
     uint8_t width, bool printSlash);
365 363
 //------------------------------------------------------------------------------
366 364
 // Deprecated functions  - suppress cpplint warnings with NOLINT comment
@@ -480,4 +478,3 @@ class SdBaseFile {
480 478
 };
481 479
 
482 480
 #endif  // SdBaseFile_h
483
-#endif

+ 5
- 0
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFat.h Näytä tiedosto

@@ -0,0 +1,5 @@
1
+#ifndef AT90USB
2
+#define  HardwareSerial_h // trick to disable the standard HWserial
3
+#endif
4
+
5
+#include <arduino.h>

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFatConfig.h Näytä tiedosto

@@ -21,9 +21,6 @@
21 21
  * \file
22 22
  * \brief configuration definitions
23 23
  */
24
-#include "Marlin.h"
25
-#ifdef SDSUPPORT
26
-
27 24
 #ifndef SdFatConfig_h
28 25
 #define SdFatConfig_h
29 26
 #include <stdint.h>
@@ -118,6 +115,3 @@ uint8_t const SOFT_SPI_SCK_PIN = 13;
118 115
 /** Total size of the buffer used to store the long filenames */
119 116
 #define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
120 117
 #endif  // SdFatConfig_h
121
-
122
-
123
-#endif

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFatStructs.h Näytä tiedosto

@@ -17,9 +17,6 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22
-
23 20
 #ifndef SdFatStructs_h
24 21
 #define SdFatStructs_h
25 22
 
@@ -641,6 +638,3 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
641 638
   return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
642 639
 }
643 640
 #endif  // SdFatStructs_h
644
-
645
-
646
-#endif

+ 11
- 11
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFatUtil.cpp Näytä tiedosto

@@ -17,9 +17,8 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-
22
-#ifdef SDSUPPORT
20
+#include "SdFat.h"
21
+#include <Print.h>
23 22
 #include "SdFatUtil.h"
24 23
 
25 24
 //------------------------------------------------------------------------------
@@ -50,7 +49,8 @@ int SdFatUtil::FreeRam() {
50 49
  * \param[in] pr Print object for output.
51 50
  * \param[in] str Pointer to string stored in flash memory.
52 51
  */
53
-void SdFatUtil::print_P( PGM_P str) {
52
+void SdFatUtil::print_P( Print *p, PGM_P str) {
53
+	Print &MYSERIAL = *p;
54 54
   for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
55 55
 }
56 56
 //------------------------------------------------------------------------------
@@ -59,8 +59,9 @@ void SdFatUtil::print_P( PGM_P str) {
59 59
  * \param[in] pr Print object for output.
60 60
  * \param[in] str Pointer to string stored in flash memory.
61 61
  */
62
-void SdFatUtil::println_P( PGM_P str) {
63
-  print_P( str);
62
+void SdFatUtil::println_P( Print *p, PGM_P str) {
63
+	Print &MYSERIAL = *p;
64
+  print_P( p, str);
64 65
   MYSERIAL.println();
65 66
 }
66 67
 //------------------------------------------------------------------------------
@@ -68,15 +69,14 @@ void SdFatUtil::println_P( PGM_P str) {
68 69
  *
69 70
  * \param[in] str Pointer to string stored in flash memory.
70 71
  */
71
-void SdFatUtil::SerialPrint_P(PGM_P str) {
72
-  print_P(str);
72
+void SdFatUtil::SerialPrint_P( Print *p, PGM_P str) {
73
+  print_P(p, str);
73 74
 }
74 75
 //------------------------------------------------------------------------------
75 76
 /** %Print a string in flash memory to Serial followed by a CR/LF.
76 77
  *
77 78
  * \param[in] str Pointer to string stored in flash memory.
78 79
  */
79
-void SdFatUtil::SerialPrintln_P(PGM_P str) {
80
-  println_P( str);
80
+void SdFatUtil::SerialPrintln_P(Print *p, PGM_P str) {
81
+  println_P( p, str);
81 82
 }
82
-#endif

+ 4
- 17
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFatUtil.h Näytä tiedosto

@@ -17,32 +17,19 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22
-
23 20
 #ifndef SdFatUtil_h
24 21
 #define SdFatUtil_h
25 22
 /**
26 23
  * \file
27 24
  * \brief Useful utility functions.
28 25
  */
29
-#include "Marlin.h"
30
-#include "MarlinSerial.h"
31
-/** Store and print a string in flash memory.*/
32
-#define PgmPrint(x) SerialPrint_P(PSTR(x))
33
-/** Store and print a string in flash memory followed by a CR/LF.*/
34
-#define PgmPrintln(x) SerialPrintln_P(PSTR(x))
35 26
 
36 27
 namespace SdFatUtil {
37 28
   int FreeRam();
38
-  void print_P( PGM_P str);
39
-  void println_P( PGM_P str);
40
-  void SerialPrint_P(PGM_P str);
41
-  void SerialPrintln_P(PGM_P str);
29
+  void print_P( Print *p, PGM_P str);
30
+  void println_P( Print *p, PGM_P str);
31
+  void SerialPrint_P(Print *p, PGM_P str);
32
+  void SerialPrintln_P(Print *p, PGM_P str);
42 33
 }
43
-
44 34
 using namespace SdFatUtil;  // NOLINT
45 35
 #endif  // #define SdFatUtil_h
46
-
47
-
48
-#endif

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFile.cpp Näytä tiedosto

@@ -17,9 +17,6 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-
22
-#ifdef SDSUPPORT
23 20
 #include "SdFile.h"
24 21
 /**  Create a file object and open it in the current working directory.
25 22
  *
@@ -90,6 +87,3 @@ void SdFile::writeln_P(PGM_P str) {
90 87
   write_P(str);
91 88
   write_P(PSTR("\r\n"));
92 89
 }
93
-
94
-
95
-#endif

+ 0
- 6
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdFile.h Näytä tiedosto

@@ -21,9 +21,6 @@
21 21
  * \file
22 22
  * \brief SdFile class
23 23
  */
24
-#include "Marlin.h"
25
-
26
-#ifdef SDSUPPORT
27 24
 #include "SdBaseFile.h"
28 25
 #include <Print.h>
29 26
 #ifndef SdFile_h
@@ -49,6 +46,3 @@ class SdFile : public SdBaseFile, public Print {
49 46
   void writeln_P(PGM_P str);
50 47
 };
51 48
 #endif  // SdFile_h
52
-
53
-
54
-#endif

+ 0
- 5
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdInfo.h Näytä tiedosto

@@ -17,9 +17,6 @@
17 17
  * along with the Arduino Sd2Card Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22
-
23 20
 #ifndef SdInfo_h
24 21
 #define SdInfo_h
25 22
 #include <stdint.h>
@@ -276,5 +273,3 @@ union csd_t {
276 273
   csd2_t v2;
277 274
 };
278 275
 #endif  // SdInfo_h
279
-
280
-#endif

+ 1
- 4
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdVolume.cpp Näytä tiedosto

@@ -17,9 +17,7 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22
-
20
+#include "SdFat.h"
23 21
 #include "SdVolume.h"
24 22
 //------------------------------------------------------------------------------
25 23
 #if !USE_MULTIPLE_CARDS
@@ -402,4 +400,3 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
402 400
  fail:
403 401
   return false;
404 402
 }
405
-#endif

+ 0
- 3
ArduinoAddons/Arduino_1.0.x/libraries/SdFat/SdVolume.h Näytä tiedosto

@@ -17,8 +17,6 @@
17 17
  * along with the Arduino SdFat Library.  If not, see
18 18
  * <http://www.gnu.org/licenses/>.
19 19
  */
20
-#include "Marlin.h"
21
-#ifdef SDSUPPORT
22 20
 #ifndef SdVolume_h
23 21
 #define SdVolume_h
24 22
 /**
@@ -211,4 +209,3 @@ class SdVolume {
211 209
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
212 210
 };
213 211
 #endif  // SdVolume
214
-#endif

+ 5
- 0
Marlin/Marlin.pde Näytä tiedosto

@@ -54,3 +54,8 @@
54 54
 #if defined(DIGIPOT_I2C)
55 55
   #include <Wire.h>
56 56
 #endif
57
+
58
+#if defined(HEATER_0_USES_MAX6675) || defined(SDSUPPORT)
59
+#include <Sd2Card.h>
60
+#endif
61
+

+ 3
- 2
Marlin/temperature.cpp Näytä tiedosto

@@ -34,8 +34,9 @@
34 34
 #include "temperature.h"
35 35
 #include "watchdog.h"
36 36
 
37
-#include "Sd2PinMap.h"
38
-
37
+#ifdef HEATER_0_USES_MAX6675
38
+//#include <Sd2PinMap.h>
39
+#endif
39 40
 
40 41
 //===========================================================================
41 42
 //=============================public variables============================

Loading…
Peruuta
Tallenna