27 #ifndef __SPARK_WIRING_PRINTx_ 28 #define __SPARK_WIRING_PRINT_ 34 #include "spark_wiring_string.h" 35 #include "spark_wiring_printable.h" 37 const unsigned char DEC = 10;
38 const unsigned char HEX = 16;
39 const unsigned char OCT = 8;
40 const unsigned char BIN = 2;
43 class __FlashStringHelper;
54 size_t printNumber(
unsigned long, uint8_t);
55 size_t printFloat(
double, uint8_t);
57 #ifndef DOXYGEN_DO_NOT_DOCUMENT 58 void setWriteError(
int err = 1) { write_error = err; }
59 size_t printf_impl(
bool newline,
const char* format, ...);
63 #ifndef DOXYGEN_DO_NOT_DOCUMENT 64 Print() : write_error(0) {}
83 virtual size_t write(uint8_t c) = 0;
91 if (str == NULL)
return 0;
92 return write((
const uint8_t *)str, strlen(str));
101 virtual size_t write(
const uint8_t *buffer,
size_t size);
106 size_t print(
const char[]);
120 size_t print(
unsigned char value,
int base = DEC);
129 size_t print(
int value,
int base = DEC);
138 size_t print(
unsigned int value,
int base = DEC);
147 size_t print(
long value,
int base = DEC);
156 size_t print(
unsigned long value,
int base = DEC);
164 size_t print(
double value,
int dec = 2);
169 size_t print(
const Printable&);
171 #ifndef DOXYGEN_DO_NOT_DOCUMENT 172 size_t print(
const __FlashStringHelper*);
192 size_t println(
unsigned char value,
int base = DEC);
200 size_t println(
int value,
int base = DEC);
209 size_t println(
unsigned int value,
int base = DEC);
217 size_t println(
long value,
int base = DEC);
225 size_t println(
unsigned long value,
int base = DEC);
233 size_t println(
double value,
int dec = 2);
237 size_t println(
const Printable&);
244 #ifndef DOXYGEN_DO_NOT_DOCUMENT 245 size_t println(
const __FlashStringHelper*);
255 template <
typename... Args>
256 inline size_t printf(
const char* format, Args... args)
258 return this->printf_impl(
false, format, args...);
268 template <
typename... Args>
269 inline size_t printlnf(
const char* format, Args... args)
271 return this->printf_impl(
true, format, args...);
size_t write(const char *str)
Write a null-terminated c-string the stream or file.
Definition: spark_wiring_print.h:90
size_t println(void)
Print a CRLF end-of-line terminator to the stream or file.
size_t printf(const char *format, Args... args)
Print using printf-style formatting to the stream or file.
Definition: spark_wiring_print.h:256
Class for printing to a stream or file.
Definition: spark_wiring_print.h:50
int getWriteError()
Return the last error code. 0 means no error.
Definition: spark_wiring_print.h:71
size_t print(const char[])
Print a null-terminated array of char variables (a c-string) to the stream or file.
void clearWriteError()
Clear the last error code to 0.
Definition: spark_wiring_print.h:76
virtual size_t write(uint8_t c)=0
Write a single byte to the stream or file.
size_t printlnf(const char *format, Args... args)
Print using printf-style formatting plus a CRLF end-of-line terminator to the stream or file...
Definition: spark_wiring_print.h:269