|
@ -82,9 +82,18 @@ struct SerialBase { |
|
|
NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } |
|
|
NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } |
|
|
NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } |
|
|
NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } |
|
|
NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } |
|
|
NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } |
|
|
void print(long c, int base = DEC) { if (!base) write(c); write((const uint8_t*)"-", c < 0); printNumber(c < 0 ? -c : c, base); } |
|
|
|
|
|
void print(unsigned long c, int base = DEC) { printNumber(c, base); } |
|
|
void print(unsigned long c, int base = DEC) { printNumber(c, base); } |
|
|
void print(double c, int digits = 2) { printFloat(c, digits); } |
|
|
void print(double c, int digits = 2) { printFloat(c, digits); } |
|
|
|
|
|
void print(long c, int base = DEC) { |
|
|
|
|
|
if (!base) { |
|
|
|
|
|
write(c); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if (base == DEC && c < 0) { |
|
|
|
|
|
write((uint8_t)'-'); c = -c; |
|
|
|
|
|
} |
|
|
|
|
|
printNumber(c, base); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
NO_INLINE void println(const char s[]) { print(s); println(); } |
|
|
NO_INLINE void println(const char s[]) { print(s); println(); } |
|
|
NO_INLINE void println(char c, int base = 0) { print(c, base); println(); } |
|
|
NO_INLINE void println(char c, int base = 0) { print(c, base); println(); } |
|
@ -98,6 +107,10 @@ struct SerialBase { |
|
|
|
|
|
|
|
|
// Print a number with the given base
|
|
|
// Print a number with the given base
|
|
|
void printNumber(unsigned long n, const uint8_t base) { |
|
|
void printNumber(unsigned long n, const uint8_t base) { |
|
|
|
|
|
if (!base) { |
|
|
|
|
|
write((uint8_t)n); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
if (n) { |
|
|
if (n) { |
|
|
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
|
|
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
|
|
int8_t i = 0; |
|
|
int8_t i = 0; |
|
|