Commit 1249920a authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

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

parent 8578e1ea
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+10 −1
Original line number Diff line number Diff line
@@ -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)));