Correct SD for Arduino 1.0 compatibility
With Arduino 1.0 Print class: - write() should return, and - print() with a uint_8 or int_8 character argument does not call print(char) anymore. So character argument should be casted to 'char' explicitly.
This commit is contained in:
parent
0ed514e153
commit
b4911b203a
3 changed files with 26 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue