From 75f170a0f42b3b81c8bd67721d00e40c419550d7 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 18 Apr 2008 18:39:02 +0000 Subject: 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. --- cores/arduino/wiring_serial.c | 85 +------------------------------------------ 1 file changed, 1 insertion(+), 84 deletions(-) (limited to 'cores/arduino/wiring_serial.c') 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 -- cgit v1.2.3-18-g5258