Noiasca Buffer Print
Print to an internal buffer
|
#include <NoiascaBufferPrint.h>
Public Member Functions | |
virtual size_t | write (uint8_t)=0 |
similar functionality like in the default Print.h library. More... | |
size_t | add (uint8_t value) |
puf a single value (one character) in to the internal buffer More... | |
size_t | print (int, int=DEC, bool=true) |
print an integer to the buffer More... | |
virtual void | flush ()=0 |
final method to flush data to the interface More... | |
size_t | getBufferLength () |
how many bytes are currently in the buffer More... | |
int | setBufferLength (size_t) |
set actual index More... | |
int | resetBuffer () |
reset the internal buffer to zero More... | |
int | setFlushAfter (size_t) |
set value when to flush More... | |
Protected Attributes | |
char | internal [buffersize] |
the internal buffered stream More... | |
class to print into a buffer
|
pure virtual |
|
inline |
puf a single value (one character) in to the internal buffer
Adds the value to the internal buffer. By default add() doesn't generate output.
value | the value to be added to the buffer |
size_t NoiascaBufferPrint::print | ( | int | n, |
int | base = DEC , |
||
bool | finalFlush = true |
||
) |
print an integer to the buffer
All print() and println() variants from the Print.h are available. All functions can take an additional parameter finalFlush which can be set to false to avoid flush after the print.
This enables one to add several println into the buffer. You only have to set the finalflush to false and can continue to fill the buffer. If the size of the buffer or the set limit is reached, print will flush the stream to your interface.
n | the integer |
base | format DEC, BIN, OCT or HEX |
finalFlush | autoflush after last digit |
|
pure virtual |
final method to flush data to the interface
size_t NoiascaBufferPrint::getBufferLength | ( | ) |
how many bytes are currently in the buffer
Returns the actual bytes in the internal buffer. Use this function in your implementation of flush() to determine, how many bytes should be streamed to your interface.
int NoiascaBufferPrint::setBufferLength | ( | size_t | newValue | ) |
set actual index
sets the actual position in the buffer
newValue | the new actual position in the buffer |
int NoiascaBufferPrint::resetBuffer | ( | ) |
reset the internal buffer to zero
Call this function at the end of your implementation of add() to reset the internal buffer to 0.
int NoiascaBufferPrint::setFlushAfter | ( | size_t | newValue | ) |
set value when to flush
By default the internal buffer is 64 bytes and therefore the buffer will be flushed after 64 bytes latest. If you have an interface which can't handle a stream of 64 bytes, you can reduce the limit to your need.
newValue | the new limit to excecute a auto flush |
|
protected |
the internal buffered stream
This array contains the buffered bytes - the stream to be outputed on next flush(). Use this internal buffer together with getBufferLength() to evaluate the correct length of valid bytes.