Using std::ostream with TextLCD

Dependencies:   ACM1602NI TextLCD

Dependents:   TextLCD_ostream_sample

This is class library inherited std::ostream for TextLCD
Because a large amount of memory is needed, do not work in low memory MPU

Sample program is here. And notebook page is here (sorry notebook page is only in Japanese)

Revision:
0:4ba062d3d524
Child:
1:e46139d4b8ba
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD_ostream.h	Sat Jun 18 08:57:07 2016 +0000
@@ -0,0 +1,29 @@
+#ifndef TEXTLCD_OSTREAM_H
+#define TEXTLCD_OSTREAM_H
+
+#include "TextLCD.h"
+#include<iostream>
+#include<fstream>
+#include <streambuf>
+
+class lcd_streambuf : public std::streambuf {
+public:
+    lcd_streambuf(TextLCD_Base *lcd) : _lcd(lcd) {}
+    virtual int overflow( int c = EOF );
+private:
+    TextLCD_Base *_lcd;
+};
+
+class lcd_ostream : public std::ostream {
+public:
+    lcd_ostream(TextLCD_Base *lcd);
+    virtual ~lcd_ostream();
+    lcd_ostream& locate(int column, int row);
+    lcd_ostream& cls();
+private:
+    TextLCD_Base *_lcd;
+    lcd_streambuf *lcd_buf;
+};
+inline lcd_ostream& cls(lcd_ostream& s) {s.cls(); return s;}  //manipulator
+
+#endif
\ No newline at end of file