diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2010-07-04 23:22:34 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2010-07-04 23:22:34 +0000 |
commit | 2c32369685d38f7367328d470571dd2f9a1104c7 (patch) | |
tree | 9ad168b426edf2c33b349ad28722235e493caa08 /cores | |
parent | 50bfce889e07711450adace72d5eed785d71ee2e (diff) |
Adding support for printing Strings to the Print class.
Diffstat (limited to 'cores')
-rwxr-xr-x | cores/arduino/HardwareSerial.cpp | 1 | ||||
-rwxr-xr-x | cores/arduino/Print.cpp | 12 | ||||
-rwxr-xr-x | cores/arduino/Print.h | 6 | ||||
-rw-r--r-- | cores/arduino/WString.h | 3 |
4 files changed, 20 insertions, 2 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 712a4c7..638b6d1 100755 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -19,6 +19,7 @@ Modified 23 November 2006 by David A. Mellis */ +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <inttypes.h> diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index fb5afc1..6fe162d 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -19,6 +19,7 @@ Modified 23 November 2006 by David A. Mellis */ +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> @@ -42,6 +43,11 @@ void Print::write(const uint8_t *buffer, size_t size) write(*buffer++); } +void Print::print(const String &s) +{ + print(s.toCharArray()); +} + void Print::print(const char str[]) { write(str); @@ -99,6 +105,12 @@ void Print::println(void) print('\n'); } +void Print::println(const String &s) +{ + print(s); + println(); +} + void Print::println(const char c[]) { print(c); diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index 8a1e2b8..b092ae5 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -23,6 +23,8 @@ #include <inttypes.h> #include <stdio.h> // for size_t +#include "WString.h" + #define DEC 10 #define HEX 16 #define OCT 8 @@ -38,7 +40,8 @@ class Print virtual void write(uint8_t) = 0; virtual void write(const char *str); virtual void write(const uint8_t *buffer, size_t size); - + + void print(const String &); void print(const char[]); void print(char, int = BYTE); void print(unsigned char, int = BYTE); @@ -48,6 +51,7 @@ class Print void print(unsigned long, int = DEC); void print(double, int = 2); + void println(const String &s); void println(const char[]); void println(char, int = BYTE); void println(unsigned char, int = BYTE); diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index 205c1f0..531c6b8 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -20,7 +20,8 @@ #ifndef String_h #define String_h -#include "WProgram.h" +//#include "WProgram.h" +#include <stdlib.h> #include <string.h> #include <ctype.h> |