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/wiring_serial.c | |
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/wiring_serial.c')
-rwxr-xr-x | cores/arduino/wiring_serial.c | 85 |
1 files changed, 1 insertions, 84 deletions
diff --git a/cores/arduino/wiring_serial.c b/cores/arduino/wiring_serial.c index 9392a09..4cac891 100755 --- a/cores/arduino/wiring_serial.c +++ b/cores/arduino/wiring_serial.c @@ -126,87 +126,4 @@ SIGNAL(SIG_UART_RECV) rx_buffer[rx_buffer_head] = c; rx_buffer_head = i; } -} - -void printMode(int mode) -{ - // do nothing, we only support serial printing, not lcd. -} - -void printByte(unsigned char c) -{ - serialWrite(c); -} - -void printNewline() -{ - printByte('\n'); -} - -void printString(const char *s) -{ - while (*s) - printByte(*s++); -} - -void printIntegerInBase(unsigned long n, unsigned long base) -{ - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. - unsigned long i = 0; - - if (n == 0) { - printByte('0'); - return; - } - - while (n > 0) { - buf[i++] = n % base; - n /= base; - } - - for (; i > 0; i--) - printByte(buf[i - 1] < 10 ? - '0' + buf[i - 1] : - 'A' + buf[i - 1] - 10); -} - -void printInteger(long n) -{ - if (n < 0) { - printByte('-'); - n = -n; - } - - printIntegerInBase(n, 10); -} - -void printHex(unsigned long n) -{ - printIntegerInBase(n, 16); -} - -void printOctal(unsigned long n) -{ - printIntegerInBase(n, 8); -} - -void printBinary(unsigned long n) -{ - printIntegerInBase(n, 2); -} - -/* Including print() adds approximately 1500 bytes to the binary size, - * so we replace it with the smaller and less-confusing printString(), - * printInteger(), etc. -void print(const char *format, ...) -{ - char buf[256]; - va_list ap; - - va_start(ap, format); - vsnprintf(buf, 256, format, ap); - va_end(ap); - - printString(buf); -} -*/ +}
\ No newline at end of file |