Use serial macros where possible

This commit is contained in:
Scott Lahteine 2018-02-16 17:53:47 -06:00
parent 023d21a1cf
commit 12628d43ce
5 changed files with 25 additions and 25 deletions

View File

@ -339,38 +339,38 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
&& DIR_IS_FILE_OR_SUBDIR(&dir)) break; && DIR_IS_FILE_OR_SUBDIR(&dir)) break;
} }
// indent for dir level // indent for dir level
for (uint8_t i = 0; i < indent; i++) MYSERIAL0.write(' '); for (uint8_t i = 0; i < indent; i++) SERIAL_CHAR(' ');
// print name // print name
for (uint8_t i = 0; i < 11; i++) { for (uint8_t i = 0; i < 11; i++) {
if (dir.name[i] == ' ')continue; if (dir.name[i] == ' ')continue;
if (i == 8) { if (i == 8) {
MYSERIAL0.write('.'); SERIAL_CHAR('.');
w++; w++;
} }
MYSERIAL0.write(dir.name[i]); SERIAL_CHAR(dir.name[i]);
w++; w++;
} }
if (DIR_IS_SUBDIR(&dir)) { if (DIR_IS_SUBDIR(&dir)) {
MYSERIAL0.write('/'); SERIAL_CHAR('/');
w++; w++;
} }
if (flags & (LS_DATE | LS_SIZE)) { if (flags & (LS_DATE | LS_SIZE)) {
while (w++ < 14) MYSERIAL0.write(' '); while (w++ < 14) SERIAL_CHAR(' ');
} }
// print modify date/time if requested // print modify date/time if requested
if (flags & LS_DATE) { if (flags & LS_DATE) {
MYSERIAL0.write(' '); SERIAL_CHAR(' ');
printFatDate(dir.lastWriteDate); printFatDate(dir.lastWriteDate);
MYSERIAL0.write(' '); SERIAL_CHAR(' ');
printFatTime(dir.lastWriteTime); printFatTime(dir.lastWriteTime);
} }
// print size if requested // print size if requested
if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) { if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
MYSERIAL0.write(' '); SERIAL_CHAR(' ');
MYSERIAL0.print(dir.fileSize); SERIAL_PROTOCOL(dir.fileSize);
} }
MYSERIAL0.println(); SERIAL_EOL();
return DIR_IS_FILE(&dir) ? 1 : 2; return DIR_IS_FILE(&dir) ? 1 : 2;
} }
@ -905,8 +905,8 @@ int SdBaseFile::peek() {
// print uint8_t with width 2 // print uint8_t with width 2
static void print2u(uint8_t v) { static void print2u(uint8_t v) {
if (v < 10) MYSERIAL0.write('0'); if (v < 10) SERIAL_CHAR('0');
MYSERIAL0.print(v, DEC); SERIAL_PRINT(v, DEC);
} }
/** /**
@ -927,10 +927,10 @@ static void print2u(uint8_t v) {
* \param[in] fatDate The date field from a directory entry. * \param[in] fatDate The date field from a directory entry.
*/ */
void SdBaseFile::printFatDate(uint16_t fatDate) { void SdBaseFile::printFatDate(uint16_t fatDate) {
MYSERIAL0.print(FAT_YEAR(fatDate)); SERIAL_PROTOCOL(FAT_YEAR(fatDate));
MYSERIAL0.write('-'); SERIAL_CHAR('-');
print2u(FAT_MONTH(fatDate)); print2u(FAT_MONTH(fatDate));
MYSERIAL0.write('-'); SERIAL_CHAR('-');
print2u(FAT_DAY(fatDate)); print2u(FAT_DAY(fatDate));
} }
@ -945,9 +945,9 @@ void SdBaseFile::printFatDate(uint16_t fatDate) {
*/ */
void SdBaseFile::printFatTime(uint16_t fatTime) { void SdBaseFile::printFatTime(uint16_t fatTime) {
print2u(FAT_HOUR(fatTime)); print2u(FAT_HOUR(fatTime));
MYSERIAL0.write(':'); SERIAL_CHAR(':');
print2u(FAT_MINUTE(fatTime)); print2u(FAT_MINUTE(fatTime));
MYSERIAL0.write(':'); SERIAL_CHAR(':');
print2u(FAT_SECOND(fatTime)); print2u(FAT_SECOND(fatTime));
} }
@ -959,7 +959,7 @@ void SdBaseFile::printFatTime(uint16_t fatTime) {
bool SdBaseFile::printName() { bool SdBaseFile::printName() {
char name[FILENAME_LENGTH]; char name[FILENAME_LENGTH];
if (!getFilename(name)) return false; if (!getFilename(name)) return false;
MYSERIAL0.print(name); SERIAL_PROTOCOL(name);
return true; return true;
} }

View File

@ -63,7 +63,7 @@ int SdFatUtil::FreeRam() {
* \param[in] str Pointer to string stored in flash memory. * \param[in] str Pointer to string stored in flash memory.
*/ */
void SdFatUtil::print_P(PGM_P str) { void SdFatUtil::print_P(PGM_P str) {
for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL0.write(c); for (uint8_t c; (c = pgm_read_byte(str)); str++) SERIAL_CHAR(c);
} }
/** /**
@ -72,7 +72,7 @@ void SdFatUtil::print_P(PGM_P str) {
* \param[in] pr Print object for output. * \param[in] pr Print object for output.
* \param[in] str Pointer to string stored in flash memory. * \param[in] str Pointer to string stored in flash memory.
*/ */
void SdFatUtil::println_P(PGM_P str) { print_P(str); MYSERIAL0.println(); } void SdFatUtil::println_P(PGM_P str) { print_P(str); SERIAL_EOL(); }
/** /**
* %Print a string in flash memory to Serial. * %Print a string in flash memory to Serial.

View File

@ -474,9 +474,9 @@ inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = f
for (uint8_t y = 0; y < 28; y++) { // always print pin name for (uint8_t y = 0; y < 28; y++) { // always print pin name
temp_char = pgm_read_byte(name_mem_pointer + y); temp_char = pgm_read_byte(name_mem_pointer + y);
if (temp_char != 0) if (temp_char != 0)
MYSERIAL0.write(temp_char); SERIAL_CHAR(temp_char);
else { else {
for (uint8_t i = 0; i < 28 - y; i++) MYSERIAL0.write(' '); for (uint8_t i = 0; i < 28 - y; i++) SERIAL_CHAR(' ');
break; break;
} }
} }

View File

@ -33,4 +33,4 @@ void serial_echopair_PGM(const char* s_P, float v) { serialprintPGM(s_P)
void serial_echopair_PGM(const char* s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(const char* s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(const char* s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) MYSERIAL0.write(' '); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }

View File

@ -336,8 +336,8 @@ class Stepper {
} }
if (timer < 100) { // (20kHz - this should never happen) if (timer < 100) { // (20kHz - this should never happen)
timer = 100; timer = 100;
MYSERIAL0.print(MSG_STEPPER_TOO_HIGH); SERIAL_PROTOCOL(MSG_STEPPER_TOO_HIGH);
MYSERIAL0.println(step_rate); SERIAL_PROTOCOLLN(step_rate);
} }
return timer; return timer;
} }