Skip to content
Snippets Groups Projects
Commit 1249920a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

arduino-nano stdout: add pprint (pgmspace string output)

parent 8578e1ea
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#ifndef STANDARDOUTPUT_H
#define STANDARDOUTPUT_H
#include <avr/pgmspace.h>
#include "object/outputstream.h"
class StandardOutput : public OutputStream {
......@@ -17,6 +18,7 @@ class StandardOutput : public OutputStream {
void setup();
virtual void put(char c) override;
OutputStream & pprint(const char *text);
};
extern StandardOutput kout;
......
......@@ -5,7 +5,6 @@
*/
#include "driver/stdout.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#ifndef BAUD
#define BAUD 9600UL
......@@ -28,6 +27,16 @@ void StandardOutput::setup()
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
}
OutputStream & StandardOutput::pprint(const char *text)
{
PGM_P p = reinterpret_cast<PGM_P>(text);
char c;
while ((c = pgm_read_byte(p++))) {
put(c);
}
return *this;
}
void StandardOutput::put(char c)
{
while (!(UCSR0A & _BV(UDRE0)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment