diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2008-04-18 18:39:02 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2008-04-18 18:39:02 +0000 |
commit | 75f170a0f42b3b81c8bd67721d00e40c419550d7 (patch) | |
tree | d4ab36bfc34ad06d9a412bf1c5e83a9a66a9a7fc /cores/arduino/HardwareSerial.cpp | |
parent | 28b81996d3a43317d62ad693902f51eecd9d3a74 (diff) |
Factored out print() and println() from HardwareSerial to a base class for sharing with other things (e.g. LiquidCrystal library), eliminating #include's of avr/signal.h (deprecated). Upping version number and modifying to do list.
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
-rwxr-xr-x | cores/arduino/HardwareSerial.cpp | 126 |
1 files changed, 8 insertions, 118 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 099c261..76cd9b0 100755 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -26,16 +26,13 @@ #include "HardwareSerial.h" +void HardwareSerialWrite(uint8_t value, void *instance) { + ((HardwareSerial *) instance)->write(value); +} + // Constructors //////////////////////////////////////////////////////////////// -HardwareSerial::HardwareSerial(uint8_t uart) -{ - //if(uart == 0){ - // _uart = 0; - //}else{ - // _uart = 1; - //} -} +HardwareSerial::HardwareSerial() : Print(HardwareSerialWrite) {} // Public Methods ////////////////////////////////////////////////////////////// @@ -59,118 +56,11 @@ void HardwareSerial::flush() serialFlush(); } -void HardwareSerial::print(char c) -{ - printByte(c); -} - -void HardwareSerial::print(const char c[]) -{ - printString(c); -} - -void HardwareSerial::print(uint8_t b) -{ - printByte(b); -} - -void HardwareSerial::print(int n) -{ - print((long) n); -} - -void HardwareSerial::print(unsigned int n) -{ - print((unsigned long) n); -} - -void HardwareSerial::print(long n) -{ - if (n < 0) { - print('-'); - n = -n; - } - printNumber(n, 10); -} - -void HardwareSerial::print(unsigned long n) -{ - printNumber(n, 10); -} - -void HardwareSerial::print(long n, int base) -{ - if (base == 0) - print((char) n); - else if (base == 10) - print(n); - else - printNumber(n, base); -} - -void HardwareSerial::println(void) -{ - print('\r'); - print('\n'); -} - -void HardwareSerial::println(char c) -{ - print(c); - println(); -} - -void HardwareSerial::println(const char c[]) -{ - print(c); - println(); -} - -void HardwareSerial::println(uint8_t b) -{ - print(b); - println(); -} - -void HardwareSerial::println(int n) -{ - print(n); - println(); -} - -void HardwareSerial::println(unsigned int n) -{ - print(n); - println(); -} - -void HardwareSerial::println(long n) -{ - print(n); - println(); -} - -void HardwareSerial::println(unsigned long n) -{ - print(n); - println(); -} - -void HardwareSerial::println(long n, int base) -{ - print(n, base); - println(); -} - -// Private Methods ///////////////////////////////////////////////////////////// - -void HardwareSerial::printNumber(unsigned long n, uint8_t base) -{ - printIntegerInBase(n, base); +void HardwareSerial::write(uint8_t b) { + serialWrite(b); } // Preinstantiate Objects ////////////////////////////////////////////////////// -HardwareSerial Serial = HardwareSerial(0); -//HardwareSerial Serial1 = HardwareSerial(1); +HardwareSerial Serial = HardwareSerial(); |