aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rwxr-xr-xcores/arduino/HardwareSerial.h1
-rwxr-xr-xcores/arduino/Print.cpp20
-rwxr-xr-xcores/arduino/Print.h5
3 files changed, 21 insertions, 5 deletions
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index 55abf07..8610f5a 100755
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -50,6 +50,7 @@ class HardwareSerial : public Print
int read(void);
void flush(void);
virtual void write(uint8_t);
+ using Print::write; // pull in write(str) and write(buf, size) from Print
};
extern HardwareSerial Serial;
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index d4833da..74d0e5b 100755
--- a/cores/arduino/Print.cpp
+++ b/cores/arduino/Print.cpp
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
-#include <inttypes.h>
#include <math.h>
#include "wiring.h"
@@ -29,6 +28,20 @@
// Public Methods //////////////////////////////////////////////////////////////
+/* default implementation: may be overridden */
+void Print::write(const char *str)
+{
+ while (*str)
+ write(*str++);
+}
+
+/* default implementation: may be overridden */
+void Print::write(const uint8_t *buffer, size_t size)
+{
+ while (size--)
+ write(*buffer++);
+}
+
void Print::print(uint8_t b)
{
this->write(b);
@@ -39,10 +52,9 @@ void Print::print(char c)
print((byte) c);
}
-void Print::print(const char c[])
+void Print::print(const char str[])
{
- while (*c)
- print(*c++);
+ write(str);
}
void Print::print(int n)
diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h
index c95a0dc..a69e85d 100755
--- a/cores/arduino/Print.h
+++ b/cores/arduino/Print.h
@@ -21,6 +21,7 @@
#define Print_h
#include <inttypes.h>
+#include <stdio.h> // for size_t
#define DEC 10
#define HEX 16
@@ -34,7 +35,9 @@ class Print
void printNumber(unsigned long, uint8_t);
void printFloat(double, uint8_t);
public:
- virtual void write(uint8_t);
+ virtual void write(uint8_t) = 0;
+ virtual void write(const char *str);
+ virtual void write(const uint8_t *buffer, size_t size);
void print(char);
void print(const char[]);
void print(uint8_t);