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)

Files at this revision

API Documentation at this revision

Comitter:
jk1lot
Date:
Wed Jun 22 08:28:51 2016 +0000
Parent:
2:eaa44bec9b96
Child:
4:3a1291526e04
Commit message:
delete lcd_streambuf default constractor

Changed in this revision

TextLCD_ostream.cpp Show annotated file Show diff for this revision Revisions of this file
TextLCD_ostream.h Show annotated file Show diff for this revision Revisions of this file
--- a/TextLCD_ostream.cpp	Sun Jun 19 01:10:35 2016 +0000
+++ b/TextLCD_ostream.cpp	Wed Jun 22 08:28:51 2016 +0000
@@ -6,13 +6,6 @@
     return c;
 }
 
-
-lcd_ostream::lcd_ostream(TextLCD_Base *p) : std::ostream(&lcd_buf)
-{
-    lcd_buf.setlcd(p);
-    lcd=p;
-}
-
 lcd_ostream& lcd_ostream::locate(int column, int row)
 {
     lcd->locate(column,row);
--- a/TextLCD_ostream.h	Sun Jun 19 01:10:35 2016 +0000
+++ b/TextLCD_ostream.h	Wed Jun 22 08:28:51 2016 +0000
@@ -7,9 +7,7 @@
 
 class lcd_streambuf : public std::streambuf {
 public:
-    lcd_streambuf() : lcd(NULL) {}
     lcd_streambuf(TextLCD_Base *p) : lcd(p) {}
-    void setlcd(TextLCD_Base *p) {lcd=p;}
     TextLCD_Base *getlcd() {return lcd;}
 
     virtual int_type overflow( int_type c = EOF );
@@ -36,7 +34,8 @@
 class lcd_ostream : public std::ostream {
 public:
     /// @param p pointer to object of TextLCD_Base and derived from it
-    lcd_ostream(TextLCD_Base *p);
+    lcd_ostream(TextLCD_Base *p)
+      : std::ostream(&lcd_buf),lcd(p),lcd_buf(p) {}
     /// set cursor position.
     /// same as TextLCD::locate(), except return value type
     lcd_ostream& locate(int column, int row);