AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This is an abstract class defining a generic interface to write numbers and strings to a sequential stream of bytes (such as a serial output device). More...
#include <Writer.h>
Public Types | |
enum | IntegerOutputBase { kBin = 2, kOct = 8, kDec = 10, kHex = 16 } |
An enumeration that defines the number that will be used as the base for representing integer quantities as a string of characters. More... | |
Public Member Functions | |
virtual size_t | write (char c)=0 |
Pure virtual function that writes a single character to the output stream. More... | |
virtual size_t | write (const char *str)=0 |
Pure virtual function that writes a null-terminated string to the output stream. More... | |
virtual size_t | write (const char *buffer, size_t size)=0 |
Pure virtual function that writes a given number of characters from a buffer to the output stream. More... | |
virtual size_t | write (const uint8_t *buffer, size_t size)=0 |
Pure virtual function that writes a given number of bytes from a buffer to the output stream. More... | |
virtual void | flush ()=0 |
Pure virtual function to flush the output stream. When this function returns, all previously written data will have been transmitted through the underlying output stream. | |
size_t | print (const char *str, bool addLn=false) |
Print a null-terminated string to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (const uint8_t *buf, size_t size, bool addLn=false) |
Print a number of bytes to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (char c, bool addLn=false) |
Print a single character to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (int8_t n, int base=kDec, bool addLn=false) |
Print an 8-bit integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (uint8_t n, int base=kDec, bool addLn=false) |
Print an 8-bit unsigned integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (int n, int base=kDec, bool addLn=false) |
Print an integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (unsigned int n, int base=kDec, bool addLn=false) |
Print an unsigned integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (long n, int base=kDec, bool addLn=false) |
Print a long integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (unsigned long n, int base=kDec, bool addLn=false) |
Print an unsigned long integer to the output stream, with or without adding a new line character at the end. More... | |
size_t | print (double d, int digits=2, bool addLn=false) |
Print a floating point number to the output stream, with or without adding a new line character at the end. More... | |
size_t | println (const char *str) |
Print a null-terminated string to the output stream, adding a new line character at the end. More... | |
size_t | println (const uint8_t *buf, size_t size) |
Print a number of bytes to the output stream, adding a new line character at the end. More... | |
size_t | println (char c) |
Print a single character to the output stream, adding a new line character at the end. More... | |
size_t | println (int8_t n, int base=kDec) |
Print an 8-bit integer to the output stream, adding a new line character at the end. More... | |
size_t | println (uint8_t n, int base=kDec) |
Print an 8-bit unsigned integer to the output stream, adding a new line character at the end. More... | |
size_t | println (int n, int base=kDec) |
Print an integer to the output stream, adding a new line character at the end. More... | |
size_t | println (unsigned int n, int base=kDec) |
Print an unsigned integer to the output stream, adding a new line character at the end. More... | |
size_t | println (long n, int base=kDec) |
Print a long integer to the output stream, adding a new line character at the end. More... | |
size_t | println (unsigned long n, int base=kDec) |
Print an unsigned long integer to the output stream, adding a new line character at the end. More... | |
size_t | println (double d, int digits=2) |
Print a floating point number to the output stream, adding a new line character at the end. More... | |
size_t | println () |
Print a new line to the output stream. | |
This is an abstract class defining a generic interface to write numbers and strings to a sequential stream of bytes (such as a serial output device).
It implements functions to convert various integers and floating point numbers into a sequence of bytes (so it is not a pure interface class). These functions depend on a small set of lower-level functions that are purely abstract and must be implemented by classes deriving from Writer.
Serial0 is an example of a class that derives from Writer by implementating the purely abstract functions in Writer.
An enumeration that defines the number that will be used as the base for representing integer quantities as a string of characters.
size_t Writer::print | ( | const char * | str, |
bool | addLn = false |
||
) |
Print a null-terminated string to the output stream, with or without adding a new line character at the end.
str
is the null-terminated string to output. addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | const uint8_t * | buf, |
size_t | size, | ||
bool | addLn = false |
||
) |
Print a number of bytes to the output stream, with or without adding a new line character at the end.
buf
is the buffer containing bytes to output. size
is the number of bytes from the buffer to output. addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | char | c, |
bool | addLn = false |
||
) |
Print a single character to the output stream, with or without adding a new line character at the end.
c
is the character to output. addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | int8_t | n, |
int | base = kDec , |
||
bool | addLn = false |
||
) |
Print an 8-bit integer to the output stream, with or without adding a new line character at the end.
n
is the integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.
|
inline |
Print an 8-bit unsigned integer to the output stream, with or without adding a new line character at the end.
n
is the integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | int | n, |
int | base = kDec , |
||
bool | addLn = false |
||
) |
Print an integer to the output stream, with or without adding a new line character at the end.
n
is the integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.
|
inline |
Print an unsigned integer to the output stream, with or without adding a new line character at the end.
n
is the unsigned integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | long | n, |
int | base = kDec , |
||
bool | addLn = false |
||
) |
Print a long integer to the output stream, with or without adding a new line character at the end.
n
is the long integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | unsigned long | n, |
int | base = kDec , |
||
bool | addLn = false |
||
) |
Print an unsigned long integer to the output stream, with or without adding a new line character at the end.
n
is the unsigned long integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec). addLn
if true, a new line character is added at the end of the output; the default is false.size_t Writer::print | ( | double | d, |
int | digits = 2 , |
||
bool | addLn = false |
||
) |
Print a floating point number to the output stream, with or without adding a new line character at the end.
d
is the floating point number to output. digits
is the number of decimal digits to output; the default is 2. addLn
if true, a new line character is added at the end of the output; the default is false.
|
inline |
Print a null-terminated string to the output stream, adding a new line character at the end.
str
is the null-terminated string to output.
|
inline |
Print a number of bytes to the output stream, adding a new line character at the end.
buf
is the buffer containing bytes to output. size
is the number of bytes from the buffer to output.
|
inline |
Print a single character to the output stream, adding a new line character at the end.
c
is the character to output.
|
inline |
Print an 8-bit integer to the output stream, adding a new line character at the end.
n
is the integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print an 8-bit unsigned integer to the output stream, adding a new line character at the end.
n
is the unsigned integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print an integer to the output stream, adding a new line character at the end.
n
is the integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print an unsigned integer to the output stream, adding a new line character at the end.
n
is the unsigned integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print a long integer to the output stream, adding a new line character at the end.
n
is the long integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print an unsigned long integer to the output stream, adding a new line character at the end.
n
is the unsigned long integer to output. base
is the base used to represent the number; should be one of IntegerOutputBase; defaults to decimal representation (kDec).
|
inline |
Print a floating point number to the output stream, adding a new line character at the end.
d
is the flaoting point number to output. digits
is the number of decimal digits to output; the default is 2.
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |