From 102e6f03e9d1ab9dc213b021b1dbe81d7fda332a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 23 Sep 2021 20:58:49 +0200 Subject: lora32u4ii: stdout: Add pprint for PSTR (pgmspace strings) --- include/arch/lora32u4ii/driver/stdout.h | 2 ++ src/arch/lora32u4ii/driver/stdout.cc | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/arch/lora32u4ii/driver/stdout.h b/include/arch/lora32u4ii/driver/stdout.h index 2eb669d..e9f0411 100644 --- a/include/arch/lora32u4ii/driver/stdout.h +++ b/include/arch/lora32u4ii/driver/stdout.h @@ -1,6 +1,7 @@ #ifndef STANDARDOUTPUT_H #define STANDARDOUTPUT_H +#include #include "object/outputstream.h" class StandardOutput : public OutputStream { @@ -12,6 +13,7 @@ class StandardOutput : public OutputStream { void setup(); virtual void put(char c) override; + OutputStream & pprint(const char *text); }; extern StandardOutput kout; diff --git a/src/arch/lora32u4ii/driver/stdout.cc b/src/arch/lora32u4ii/driver/stdout.cc index afe6ff8..ee45a43 100644 --- a/src/arch/lora32u4ii/driver/stdout.cc +++ b/src/arch/lora32u4ii/driver/stdout.cc @@ -1,6 +1,5 @@ #include "driver/stdout.h" #include -#include #ifndef BAUD #define BAUD 9600UL @@ -24,6 +23,17 @@ void StandardOutput::setup() //UCSR1D = 0; } +OutputStream & StandardOutput::pprint(const char *text) +{ + PGM_P p = reinterpret_cast(text); + char c; + while ((c = pgm_read_byte(p++))) { + put(c); + } + return *this; +} + + void StandardOutput::put(char c) { while (!(UCSR1A & _BV(UDRE1))); -- cgit v1.2.3