File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,26 @@ size_t Print::println(const Printable &x)
196196 return n;
197197}
198198
199+ void Print::printf (const char *format, ...)
200+ {
201+ char buf[PRINTF_BUFFER];
202+ va_list ap;
203+ va_start (ap, format);
204+ vsnprintf (buf, sizeof (buf), format, ap);
205+ write (buf);
206+ va_end (ap);
207+ }
208+
209+ void Print::printf (const __FlashStringHelper *format, ...)
210+ {
211+ char buf[PRINTF_BUFFER];
212+ va_list ap;
213+ va_start (ap, format);
214+ vsnprintf_P (buf, sizeof (buf), (const char *)format, ap);
215+ write (buf);
216+ va_end (ap);
217+ }
218+
199219// Private Methods /////////////////////////////////////////////////////////////
200220
201221size_t Print::printNumber (unsigned long n, uint8_t base)
Original file line number Diff line number Diff line change 2222
2323#include < inttypes.h>
2424#include < stdio.h> // for size_t
25+ #include < stdarg.h> // for printf
2526
2627#include " WString.h"
2728#include " Printable.h"
3132#define OCT 8
3233#define BIN 2
3334
35+ #ifndef PRINTF_BUFFER
36+ #define PRINTF_BUFFER 80
37+ #endif
38+
3439// uncomment next line to support printing of 64 bit ints.
3540#define SUPPORT_LONGLONG
3641
@@ -103,6 +108,9 @@ class Print {
103108 void println (uint64_t , uint8_t = DEC);
104109 void print (uint64_t , uint8_t = DEC);
105110#endif
111+
112+ void printf (const char *format, ...);
113+ void printf (const __FlashStringHelper *format, ...);
106114};
107115
108116#endif
You can’t perform that action at this time.
0 commit comments