summaryrefslogtreecommitdiff
path: root/Sprinter
diff options
context:
space:
mode:
authorkliment <kliment.yanev@gmail.com>2012-03-04 08:50:33 -0800
committerkliment <kliment.yanev@gmail.com>2012-03-04 08:50:33 -0800
commit0a47e2d0b6493eeba856d9c71bafc9f97abd3ec3 (patch)
tree5e29245fa12631e165a2d80129a930d78fede8d6 /Sprinter
parent0ed514e153a7fe6fa6d9810e7373798ac4088dff (diff)
parent8465acbfb8946d1f02de7aae8e1b29ecd0ae5867 (diff)
Merge pull request #147 from changwoo/arduino-1.0-compatibility
Arduino 1.0 compatibility for experimental
Diffstat (limited to 'Sprinter')
-rw-r--r--Sprinter/SdFat.h4
-rw-r--r--Sprinter/SdFatUtil.h2
-rw-r--r--Sprinter/SdFile.cpp33
3 files changed, 26 insertions, 13 deletions
diff --git a/Sprinter/SdFat.h b/Sprinter/SdFat.h
index 048fa71..7a11bba 100644
--- a/Sprinter/SdFat.h
+++ b/Sprinter/SdFat.h
@@ -283,7 +283,11 @@ class SdFile : public Print {
}
/** \return SdVolume that contains this file. */
SdVolume* volume(void) const {return vol_;}
+#if ARDUINO >= 100
+ size_t write(uint8_t b);
+#else
void write(uint8_t b);
+#endif
int16_t write(const void* buf, uint16_t nbyte);
void write(const char* str);
void write_P(PGM_P str);
diff --git a/Sprinter/SdFatUtil.h b/Sprinter/SdFatUtil.h
index 8bf9048..de3fee3 100644
--- a/Sprinter/SdFatUtil.h
+++ b/Sprinter/SdFatUtil.h
@@ -55,7 +55,7 @@ static int FreeRam(void) {
* \param[in] str Pointer to string stored in flash memory.
*/
static NOINLINE void SerialPrint_P(PGM_P str) {
- for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.print(c);
+ for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.print(char(c));
}
//------------------------------------------------------------------------------
/**
diff --git a/Sprinter/SdFile.cpp b/Sprinter/SdFile.cpp
index 0a27159..13f4c6a 100644
--- a/Sprinter/SdFile.cpp
+++ b/Sprinter/SdFile.cpp
@@ -213,7 +213,7 @@ void SdFile::ls(uint8_t flags, uint8_t indent) {
if (!DIR_IS_FILE_OR_SUBDIR(p)) continue;
// print any indent spaces
- for (int8_t i = 0; i < indent; i++) Serial.print(' ');
+ for (int8_t i = 0; i < indent; i++) Serial.print(char(' '));
// print file name with possible blank fill
printDirName(*p, flags & (LS_DATE | LS_SIZE) ? 14 : 0);
@@ -221,12 +221,12 @@ void SdFile::ls(uint8_t flags, uint8_t indent) {
// print modify date/time if requested
if (flags & LS_DATE) {
printFatDate(p->lastWriteDate);
- Serial.print(' ');
+ Serial.print(char(' '));
printFatTime(p->lastWriteTime);
}
// print size if requested
if (!DIR_IS_SUBDIR(p) && (flags & LS_SIZE)) {
- Serial.print(' ');
+ Serial.print(char(' '));
Serial.print(p->fileSize);
}
Serial.println();
@@ -587,18 +587,18 @@ void SdFile::printDirName(const dir_t& dir, uint8_t width) {
for (uint8_t i = 0; i < 11; i++) {
if (dir.name[i] == ' ')continue;
if (i == 8) {
- Serial.print('.');
+ Serial.print(char('.'));
w++;
}
- Serial.print(dir.name[i]);
+ Serial.print(char(dir.name[i]));
w++;
}
if (DIR_IS_SUBDIR(&dir)) {
- Serial.print('/');
+ Serial.print(char('/'));
w++;
}
while (w < width) {
- Serial.print(' ');
+ Serial.print(char(' '));
w++;
}
}
@@ -611,9 +611,9 @@ void SdFile::printDirName(const dir_t& dir, uint8_t width) {
*/
void SdFile::printFatDate(uint16_t fatDate) {
Serial.print(FAT_YEAR(fatDate));
- Serial.print('-');
+ Serial.print(char('-'));
printTwoDigits(FAT_MONTH(fatDate));
- Serial.print('-');
+ Serial.print(char('-'));
printTwoDigits(FAT_DAY(fatDate));
}
//------------------------------------------------------------------------------
@@ -625,9 +625,9 @@ void SdFile::printFatDate(uint16_t fatDate) {
*/
void SdFile::printFatTime(uint16_t fatTime) {
printTwoDigits(FAT_HOUR(fatTime));
- Serial.print(':');
+ Serial.print(char(':'));
printTwoDigits(FAT_MINUTE(fatTime));
- Serial.print(':');
+ Serial.print(char(':'));
printTwoDigits(FAT_SECOND(fatTime));
}
//------------------------------------------------------------------------------
@@ -1219,8 +1219,17 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
*
* Use SdFile::writeError to check for errors.
*/
-void SdFile::write(uint8_t b) {
+#if ARDUINO >= 100
+size_t SdFile::write(uint8_t b)
+#else
+void SdFile::write(uint8_t b)
+#endif
+{
+#if ARDUINO >= 100
+ return (size_t) write(&b, 1);
+#else
write(&b, 1);
+#endif
}
//------------------------------------------------------------------------------
/**