diff options
Diffstat (limited to 'cores/arduino/Print.cpp')
-rwxr-xr-x | cores/arduino/Print.cpp | 91 |
1 files changed, 41 insertions, 50 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 74d0e5b..fb5afc1 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -42,70 +42,61 @@ void Print::write(const uint8_t *buffer, size_t size) write(*buffer++); } -void Print::print(uint8_t b) -{ - this->write(b); -} - -void Print::print(char c) -{ - print((byte) c); -} - void Print::print(const char str[]) { write(str); } -void Print::print(int n) +void Print::print(char c, int base) { - print((long) n); + print((long) c, base); } -void Print::print(unsigned int n) +void Print::print(unsigned char b, int base) { - print((unsigned long) n); + print((unsigned long) b, base); } -void Print::print(long n) +void Print::print(int n, int base) { - if (n < 0) { - print('-'); - n = -n; - } - printNumber(n, 10); + print((long) n, base); } -void Print::print(unsigned long n) +void Print::print(unsigned int n, int base) { - printNumber(n, 10); + print((unsigned long) n, base); } void Print::print(long n, int base) { - if (base == 0) - print((char) n); - else if (base == 10) - print(n); - else + if (base == 0) { + write(n); + } else if (base == 10) { + if (n < 0) { + print('-'); + n = -n; + } + printNumber(n, 10); + } else { printNumber(n, base); + } } -void Print::print(double n) +void Print::print(unsigned long n, int base) { - printFloat(n, 2); + if (base == 0) write(n); + else printNumber(n, base); } -void Print::println(void) +void Print::print(double n, int digits) { - print('\r'); - print('\n'); + printFloat(n, digits); } -void Print::println(char c) +void Print::println(void) { - print(c); - println(); + print('\r'); + print('\n'); } void Print::println(const char c[]) @@ -114,45 +105,45 @@ void Print::println(const char c[]) println(); } -void Print::println(uint8_t b) +void Print::println(char c, int base) { - print(b); + print(c, base); println(); } -void Print::println(int n) +void Print::println(unsigned char b, int base) { - print(n); + print(b, base); println(); } -void Print::println(unsigned int n) +void Print::println(int n, int base) { - print(n); + print(n, base); println(); } -void Print::println(long n) +void Print::println(unsigned int n, int base) { - print(n); - println(); + print(n, base); + println(); } -void Print::println(unsigned long n) +void Print::println(long n, int base) { - print(n); - println(); + print(n, base); + println(); } -void Print::println(long n, int base) +void Print::println(unsigned long n, int base) { print(n, base); println(); } -void Print::println(double n) +void Print::println(double n, int digits) { - print(n); + print(n, digits); println(); } |