2020-04-27 16:01:25 +00:00
|
|
|
#include "RedirectablePrint.h"
|
2020-11-12 23:48:25 +00:00
|
|
|
#include "configuration.h"
|
2020-04-27 16:01:25 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A printer that doesn't go anywhere
|
|
|
|
*/
|
|
|
|
NoopPrint noopPrint;
|
|
|
|
|
|
|
|
void RedirectablePrint::setDestination(Print *_dest)
|
|
|
|
{
|
|
|
|
assert(_dest);
|
|
|
|
dest = _dest;
|
2020-11-12 23:48:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t RedirectablePrint::write(uint8_t c)
|
|
|
|
{
|
|
|
|
#ifdef SEGGER_STDOUT_CH
|
|
|
|
SEGGER_RTT_PutCharSkip(SEGGER_STDOUT_CH, c);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dest->write(c);
|
|
|
|
return 1; // We always claim one was written, rather than trusting what the serial port said (which could be zero)
|
2020-04-27 16:01:25 +00:00
|
|
|
}
|