From c8b8b8724cc94cdd9290033d76513c8f816ad862 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 26 Feb 2011 13:58:03 -0500 Subject: Removing BYTE keyword (use Serial.write() instead). --- cores/arduino/Print.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index b092ae5..c090636 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -29,7 +29,6 @@ #define HEX 16 #define OCT 8 #define BIN 2 -#define BYTE 0 class Print { @@ -43,8 +42,8 @@ class Print void print(const String &); void print(const char[]); - void print(char, int = BYTE); - void print(unsigned char, int = BYTE); + void print(char); + void print(unsigned char, int = DEC); void print(int, int = DEC); void print(unsigned int, int = DEC); void print(long, int = DEC); @@ -53,8 +52,8 @@ class Print void println(const String &s); void println(const char[]); - void println(char, int = BYTE); - void println(unsigned char, int = BYTE); + void println(char); + void println(unsigned char, int = DEC); void println(int, int = DEC); void println(unsigned int, int = DEC); void println(long, int = DEC); -- cgit v1.2.3-18-g5258 From ffe7bc53c1862866bf38e01174bd35d20632608c Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sun, 27 Mar 2011 15:06:20 -0400 Subject: Adding F("foo") syntax for flash strings. --- cores/arduino/Print.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index c090636..a447753 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -40,6 +40,7 @@ class Print virtual void write(const char *str); virtual void write(const uint8_t *buffer, size_t size); + void print(const __FlashStringHelper *); void print(const String &); void print(const char[]); void print(char); @@ -50,6 +51,7 @@ class Print void print(unsigned long, int = DEC); void print(double, int = 2); + void println(const __FlashStringHelper *); void println(const String &s); void println(const char[]); void println(char); -- cgit v1.2.3-18-g5258 From a239d2c541094ef5445159360ae5d2d6a93dbf00 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 4 Jun 2011 09:19:17 -0400 Subject: Added Printable interface class to allow printing of classes such as IPAddress --- cores/arduino/Print.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index a447753..bf10b14 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -24,6 +24,7 @@ #include // for size_t #include "WString.h" +#include "Printable.h" #define DEC 10 #define HEX 16 @@ -50,6 +51,7 @@ class Print void print(long, int = DEC); void print(unsigned long, int = DEC); void print(double, int = 2); + void print(const Printable&); void println(const __FlashStringHelper *); void println(const String &s); @@ -61,6 +63,7 @@ class Print void println(long, int = DEC); void println(unsigned long, int = DEC); void println(double, int = 2); + void println(const Printable&); void println(void); }; -- cgit v1.2.3-18-g5258 From f282cbaf968f7142ef5abb68a92e970c3d5eea35 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 23 Aug 2011 19:12:03 -0400 Subject: write(), print(), and println() now return number of bytes written. The type is long, and negative values indicate errors. Needs more testing. http://code.google.com/p/arduino/issues/detail?id=551 --- cores/arduino/Print.h | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index bf10b14..d5b02ff 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -34,37 +34,37 @@ class Print { private: - void printNumber(unsigned long, uint8_t); - void printFloat(double, uint8_t); + long printNumber(unsigned long, uint8_t); + long printFloat(double, uint8_t); public: - virtual void write(uint8_t) = 0; - virtual void write(const char *str); - virtual void write(const uint8_t *buffer, size_t size); + virtual long write(uint8_t) = 0; + virtual long write(const char *str); + virtual long write(const uint8_t *buffer, size_t size); - void print(const __FlashStringHelper *); - void print(const String &); - void print(const char[]); - void print(char); - void print(unsigned char, int = DEC); - void print(int, int = DEC); - void print(unsigned int, int = DEC); - void print(long, int = DEC); - void print(unsigned long, int = DEC); - void print(double, int = 2); - void print(const Printable&); + long print(const __FlashStringHelper *); + long print(const String &); + long print(const char[]); + long print(char); + long print(unsigned char, int = DEC); + long print(int, int = DEC); + long print(unsigned int, int = DEC); + long print(long, int = DEC); + long print(unsigned long, int = DEC); + long print(double, int = 2); + long print(const Printable&); - void println(const __FlashStringHelper *); - void println(const String &s); - void println(const char[]); - void println(char); - void println(unsigned char, int = DEC); - void println(int, int = DEC); - void println(unsigned int, int = DEC); - void println(long, int = DEC); - void println(unsigned long, int = DEC); - void println(double, int = 2); - void println(const Printable&); - void println(void); + long println(const __FlashStringHelper *); + long println(const String &s); + long println(const char[]); + long println(char); + long println(unsigned char, int = DEC); + long println(int, int = DEC); + long println(unsigned int, int = DEC); + long println(long, int = DEC); + long println(unsigned long, int = DEC); + long println(double, int = 2); + long println(const Printable&); + long println(void); }; #endif -- cgit v1.2.3-18-g5258 From 0635790dd111e91e5c488acc599cc404dc707abd Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 26 Aug 2011 14:20:41 -0400 Subject: Changing from long to ssize_t (int) for write(), print(), println() return. --- cores/arduino/Print.h | 58 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index d5b02ff..3f303f3 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -23,6 +23,8 @@ #include #include // for size_t +typedef int ssize_t; + #include "WString.h" #include "Printable.h" @@ -34,37 +36,37 @@ class Print { private: - long printNumber(unsigned long, uint8_t); - long printFloat(double, uint8_t); + ssize_t printNumber(unsigned long, uint8_t); + ssize_t printFloat(double, uint8_t); public: - virtual long write(uint8_t) = 0; - virtual long write(const char *str); - virtual long write(const uint8_t *buffer, size_t size); + virtual ssize_t write(uint8_t) = 0; + virtual ssize_t write(const char *str); + virtual ssize_t write(const uint8_t *buffer, size_t size); - long print(const __FlashStringHelper *); - long print(const String &); - long print(const char[]); - long print(char); - long print(unsigned char, int = DEC); - long print(int, int = DEC); - long print(unsigned int, int = DEC); - long print(long, int = DEC); - long print(unsigned long, int = DEC); - long print(double, int = 2); - long print(const Printable&); + ssize_t print(const __FlashStringHelper *); + ssize_t print(const String &); + ssize_t print(const char[]); + ssize_t print(char); + ssize_t print(unsigned char, int = DEC); + ssize_t print(int, int = DEC); + ssize_t print(unsigned int, int = DEC); + ssize_t print(long, int = DEC); + ssize_t print(unsigned long, int = DEC); + ssize_t print(double, int = 2); + ssize_t print(const Printable&); - long println(const __FlashStringHelper *); - long println(const String &s); - long println(const char[]); - long println(char); - long println(unsigned char, int = DEC); - long println(int, int = DEC); - long println(unsigned int, int = DEC); - long println(long, int = DEC); - long println(unsigned long, int = DEC); - long println(double, int = 2); - long println(const Printable&); - long println(void); + ssize_t println(const __FlashStringHelper *); + ssize_t println(const String &s); + ssize_t println(const char[]); + ssize_t println(char); + ssize_t println(unsigned char, int = DEC); + ssize_t println(int, int = DEC); + ssize_t println(unsigned int, int = DEC); + ssize_t println(long, int = DEC); + ssize_t println(unsigned long, int = DEC); + ssize_t println(double, int = 2); + ssize_t println(const Printable&); + ssize_t println(void); }; #endif -- cgit v1.2.3-18-g5258 From 5130a1329462aa36d5f18e31851d3d9d5086e411 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 26 Aug 2011 16:08:14 -0400 Subject: Moving write errors out of return value into separate API methods. write(), print(), println() now return size_t (and don't use negative values to signal errors). Print adds writeError() for checking for write errors, clearWriteError() to reset the flag to false, and a protected setWriteError() for signalling errors. http://code.google.com/p/arduino/issues/detail?id=598 --- cores/arduino/Print.h | 66 ++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'cores/arduino/Print.h') diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h index 3f303f3..fce302e 100755 --- a/cores/arduino/Print.h +++ b/cores/arduino/Print.h @@ -23,8 +23,6 @@ #include #include // for size_t -typedef int ssize_t; - #include "WString.h" #include "Printable.h" @@ -36,37 +34,45 @@ typedef int ssize_t; class Print { private: - ssize_t printNumber(unsigned long, uint8_t); - ssize_t printFloat(double, uint8_t); + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printFloat(double, uint8_t); + protected: + void setWriteError(int err = 1) { write_error = err; } public: - virtual ssize_t write(uint8_t) = 0; - virtual ssize_t write(const char *str); - virtual ssize_t write(const uint8_t *buffer, size_t size); + Print() : write_error(0) {} + + int writeError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buffer, size_t size); - ssize_t print(const __FlashStringHelper *); - ssize_t print(const String &); - ssize_t print(const char[]); - ssize_t print(char); - ssize_t print(unsigned char, int = DEC); - ssize_t print(int, int = DEC); - ssize_t print(unsigned int, int = DEC); - ssize_t print(long, int = DEC); - ssize_t print(unsigned long, int = DEC); - ssize_t print(double, int = 2); - ssize_t print(const Printable&); + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); - ssize_t println(const __FlashStringHelper *); - ssize_t println(const String &s); - ssize_t println(const char[]); - ssize_t println(char); - ssize_t println(unsigned char, int = DEC); - ssize_t println(int, int = DEC); - ssize_t println(unsigned int, int = DEC); - ssize_t println(long, int = DEC); - ssize_t println(unsigned long, int = DEC); - ssize_t println(double, int = 2); - ssize_t println(const Printable&); - ssize_t println(void); + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); }; #endif -- cgit v1.2.3-18-g5258