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:
4:3a1291526e04
Parent:
3:183bcab4951b
Child:
5:6c1109b4dfb8
--- a/TextLCD_ostream.h	Wed Jun 22 08:28:51 2016 +0000
+++ b/TextLCD_ostream.h	Sun Jun 26 08:32:25 2016 +0000
@@ -2,14 +2,12 @@
 #define TEXTLCD_OSTREAM_H
 
 #include "TextLCD.h"
-#include<iostream>
+#include <iostream>
 #include <streambuf>
 
 class lcd_streambuf : public std::streambuf {
 public:
     lcd_streambuf(TextLCD_Base *p) : lcd(p) {}
-    TextLCD_Base *getlcd() {return lcd;}
-
     virtual int_type overflow( int_type c = EOF );
 private:
     TextLCD_Base *lcd;
@@ -35,16 +33,18 @@
 public:
     /// @param p pointer to object of TextLCD_Base and derived from it
     lcd_ostream(TextLCD_Base *p)
-      : std::ostream(&lcd_buf),lcd(p),lcd_buf(p) {}
+      : std::ostream(&lcd_buf),lcdp(p),lcd_buf(p) {}
+    /// access TextLCD object  
+    TextLCD_Base& lcd() {return *lcdp;}
+    //TextLCD_Base& operator*() const {return *lcd;}
     /// set cursor position.
     /// same as TextLCD::locate(), except return value type
     lcd_ostream& locate(int column, int row);
     /// clear screen
     /// same as TextLCD::cls(), except return value type
     lcd_ostream& cls();
-protected:
-    TextLCD_Base *lcd;
 private:
+    TextLCD_Base* const lcdp;
     lcd_streambuf lcd_buf;
 };
 #endif
\ No newline at end of file