27#ifndef __SPARK_WIRING_PRINTx_
28#define __SPARK_WIRING_PRINT_
34#include "spark_wiring_string.h"
37const unsigned char DEC = 10;
38const unsigned char HEX = 16;
39const unsigned char OCT = 8;
40const unsigned char BIN = 2;
43class __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);
164 size_t print(
double value,
int dec = 2);
171#ifndef DOXYGEN_DO_NOT_DOCUMENT
172 size_t print(
const __FlashStringHelper*);
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...);
Class for printing to a stream or file.
Definition: spark_wiring_print.h:51
size_t println(unsigned char value, int base=DEC)
Print an unsigned char (byte value. 8 bits) in the specified base plus a CRLF end-of-line terminator ...
size_t printf(const char *format, Args... args)
Print using printf-style formatting to the stream or file.
Definition: spark_wiring_print.h:256
size_t print(long value, int base=DEC)
Print a long (32 bit integer) the specified base to the stream or file.
size_t println(void)
Print a CRLF end-of-line terminator to the stream or file.
size_t println(double value, int dec=2)
Print a double floating point value plus a CRLF end-of-line terminator to the stream or file.
size_t print(char)
Print a single character to the stream or file.
size_t println(const Printable &)
Print an object derived from Printable plus a CRLF end-of-line terminator to the stream or file.
size_t println(unsigned int value, int base=DEC)
Print an unsigned int (32 bit unsigned integer) the specified base plus a CRLF end-of-line terminator...
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(char value)
Print a single character plus a CRLF end-of-line terminator to the stream or file.
size_t println(int value, int base=DEC)
Print an int (32 bit integer) the specified base to plus a CRLF end-of-line terminator the stream or ...
size_t println(long value, int base=DEC)
Print a long (32 bit signed integer) the specified base plus a CRLF end-of-line terminator to the str...
virtual size_t write(const uint8_t *buffer, size_t size)
Write a bytes specified by a buffer and length to the stream or file.
int getWriteError()
Return the last error code. 0 means no error.
Definition: spark_wiring_print.h:71
size_t print(const Printable &)
Print an object derived from Printable to the stream or file.
size_t print(int value, int base=DEC)
Print an int (32 bit integer) the specified base to the stream or file.
virtual size_t write(uint8_t c)=0
Write a single byte to the stream or file.
size_t print(unsigned long value, int base=DEC)
Print a unsigned long (32 bit unsigned integer) the specified base to the stream or file.
size_t print(const char[])
Print a null-terminated array of char variables (a c-string) to the stream or file.
size_t println(const char[])
Print a null-terminated array of char variables (a c-string) plus a CRLF end-of-line terminator to th...
size_t print(double value, int dec=2)
Print a double floating point value to the stream or file.
size_t print(unsigned char value, int base=DEC)
Print an unsigned char (byte value, 8 bits) in the specified base to the stream or file.
void clearWriteError()
Clear the last error code to 0.
Definition: spark_wiring_print.h:76
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
size_t println(unsigned long value, int base=DEC)
Print a unsigned long (32 bit unsigned integer) the specified base plus a CRLF end-of-line terminator...
size_t print(unsigned int value, int base=DEC)
Print an unsigned int (32 bit unsigned integer) the specified base to the stream or file.
The Printable class provides a way for new classes to allow themselves to be printed.
Definition: spark_wiring_printable.h:42
const unsigned char DEC
Decimal (base 10)
Definition: spark_wiring_print.h:37
const unsigned char HEX
Hexadecial (base 16)
Definition: spark_wiring_print.h:38
const unsigned char BIN
Binary (base 2)
Definition: spark_wiring_print.h:40
const unsigned char OCT
Octal (base 8)
Definition: spark_wiring_print.h:39
Header for spark_wiring_printable.cpp module.