Arduino Core for STM32  1.0
Print Class Referenceabstract

The stream class is derived from this class. This class contains methods, that are used for to print formatted output. More...

#include <Print.h>

Inheritance diagram for Print:

Public Member Functions

 Print ()
 Constructor. More...
 
int getWriteError ()
 Gets write error. More...
 
void clearWriteError ()
 Clears write error. More...
 
virtual size_t write (uint8_t byte)=0
 Writes one unsigned byte (character). More...
 
size_t write (const char *str)
 Writes character array (string). More...
 
virtual size_t write (const uint8_t *buffer, size_t size)
 Writes byte array (string). More...
 
size_t write (const char *buffer, size_t size)
 Writes character array (string). More...
 
 __INTEGER_ONLY__ (T, size_t) inline write(T val)
 Converts integer type variable to unsigned byte and writes it. More...
 
virtual int availableForWrite ()
 Gets how many bytes can be written, meaning "a single write may block". More...
 
size_t printf (const char *format,...) __attribute__((format(printf
 Prints formatted data. More...
 
size_t size_t print (const String &s)
 Prints string. More...
 
size_t print (const char str[])
 Prints character array (string). More...
 
size_t print (char c)
 Prints one character. More...
 
 __SIGNED_INTEGER_ONLY__ (T, size_t) print(T n
 Converts integer number to character array and prints it. More...
 
size_t println (const String &s)
 Prints string followed by carriage return and new line. More...
 
size_t println (const char[])
 Prints character array (string) followed by carriage return and new line. More...
 
size_t println (char)
 Prints one character followed by carriage return and new line. More...
 
 __INTEGER_ONLY__ (T, size_t) inline println(T n
 Converts integer number to character array followed by carriage return and new line and prints it. More...
 
size_t println (void)
 Prints carriage return and new line. More...
 
template<class T >
Printoperator<< (T value)
 This operator (<<) applied to an output stream is known as insertion operator, it can be used same as cout<< operator. More...
 

Public Attributes

int base
 

Protected Member Functions

void setWriteError (int err=1)
 Sets write error. More...
 

Detailed Description

The stream class is derived from this class. This class contains methods, that are used for to print formatted output.

See also
Print.h
Printable
Stream

Constructor & Destructor Documentation

◆ Print()

Print::Print ( )
inline

Constructor.

Member Function Documentation

◆ setWriteError()

void Print::setWriteError ( int  err = 1)
inlineprotected

Sets write error.

Parameters
errNew error value.
Todo:
Use it in HardwareSerial.h

◆ getWriteError()

int Print::getWriteError ( )
inline

Gets write error.

Returns
Returns write error.
Note
Does not works in HardwareSerial right now!

◆ clearWriteError()

void Print::clearWriteError ( )
inline

Clears write error.

Here is the call graph for this function:

◆ write() [1/4]

virtual size_t Print::write ( uint8_t  byte)
pure virtual

Writes one unsigned byte (character).

Parameters
byteByte you want to write.
Returns
Returns count of successfully written bytes.

Implemented in HardwareI2C, and HardwareSerial.

◆ write() [2/4]

size_t Print::write ( const char *  str)
inline

Writes character array (string).

Parameters
strString you want to write.
Note
String you want to write have to ends with \0, else it can cause unexpected errors.
Returns
Returns count of successfully written bytes (characters).

◆ write() [3/4]

size_t Print::write ( const uint8_t *  buffer,
size_t  size 
)
virtual

Writes byte array (string).

Parameters
bufferData you want to write.
sizeSize of buffer (length of data).
Returns
Returns count of successfully written bytes.

Reimplemented in HardwareSerial, and HardwareI2C.

◆ write() [4/4]

size_t Print::write ( const char *  buffer,
size_t  size 
)
inline

Writes character array (string).

Parameters
bufferData you want to write.
sizeSize of buffer (length of data).
Returns
Returns count of successfully written bytes (characters).

◆ __INTEGER_ONLY__() [1/2]

Print::__INTEGER_ONLY__ ( ,
size_t   
)
inline

Converts integer type variable to unsigned byte and writes it.

Note
These handle ambiguity for write(0) case, because (0) can be a pointer or an integer.
Parameters
valInteger type variable, that will be converted to unsigned byte and will be written.
Returns
Returns count of successfully written bytes (characters).

◆ availableForWrite()

virtual int Print::availableForWrite ( )
inlinevirtual

Gets how many bytes can be written, meaning "a single write may block".

Default set to INT16_MAX.

Note
Should be overriden by subclasses with buffering.
Returns
Returns how many bytes can be written or INT16_MAX if not implemented.

◆ printf()

size_t Print::printf ( const char *  format,
  ... 
)

Prints formatted data.

Parameters
formatChar string, that contains print format.
Returns
Returns count of successfully written bytes.
See also
https://www.cplusplus.com/reference/cstdio/printf/

◆ print() [1/3]

size_t size_t Print::print ( const String &  s)

Prints string.

Parameters
sString to print.
Returns
Returns count of successfully written bytes (characters).

◆ print() [2/3]

size_t Print::print ( const char  str[])

Prints character array (string).

Parameters
strString you want to write.
Note
String you want to write have to ends with \0, else it can cause unexpected errors.
Returns
Returns count of successfully written bytes (characters).

◆ print() [3/3]

size_t Print::print ( char  c)

Prints one character.

Parameters
cCharacter you want to write.
Returns
Returns count of successfully written bytes (characters).

◆ __SIGNED_INTEGER_ONLY__()

Print::__SIGNED_INTEGER_ONLY__ ( ,
size_t   
)

Converts integer number to character array and prints it.

Parameters
nInteger number, you want to convert to character array and print.
baseBase, in what will be the number displayed. Use (DEC, HEX, OCT, BIN)
Returns
Returns count of successfully written bytes (characters).

◆ println() [1/4]

size_t Print::println ( const String &  s)

Prints string followed by carriage return and new line.

Parameters
sString to print.
Returns
Returns count of successfully written bytes (characters) including carriage return and new line characters.

◆ println() [2/4]

size_t Print::println ( const char  c[])

Prints character array (string) followed by carriage return and new line.

Parameters
strString you want to write.
Note
String you want to write have to ends with \0, else it can cause unexpected errors.
Returns
Returns count of successfully written bytes (characters) including carriage return and new line characters.

◆ println() [3/4]

size_t Print::println ( char  c)

Prints one character followed by carriage return and new line.

Parameters
cCharacter you want to write.
Returns
Returns count of successfully written bytes (characters) including carriage return and new line characters.

◆ __INTEGER_ONLY__() [2/2]

Print::__INTEGER_ONLY__ ( ,
size_t   
)

Converts integer number to character array followed by carriage return and new line and prints it.

Parameters
nInteger number, you want to convert to character array and print.
baseBase, in what will be the number displayed. Use (DEC, HEX, OCT, BIN)
Returns
Returns count of successfully written bytes (characters) including carriage return and new line characters.

◆ println() [4/4]

size_t Print::println ( void  )

Prints carriage return and new line.

Returns
Returns count of successfully written bytes (characters) including carriage return and new line characters.
Here is the call graph for this function:

◆ operator<<()

template<class T >
Print& Print::operator<< ( value)
inline

This operator (<<) applied to an output stream is known as insertion operator, it can be used same as cout<< operator.

Parameters
objPrinting stream.
argValue, that will be printed.
Returns
Returns printing stream.
Note
This operator is same as calling print() method, but with different return type.
Here is the call graph for this function:

Member Data Documentation

◆ base

int Print::base

The documentation for this class was generated from the following files: