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, committed 2016-06-26
- Comitter:
- jk1lot
- Date:
- Sun Jun 26 08:32:25 2016 +0000
- Parent:
- 3:183bcab4951b
- Child:
- 5:6c1109b4dfb8
- Commit message:
- add lcd(); add library TextLCD
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Sun Jun 26 08:32:25 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/wim/code/TextLCD/#111ca62e8a59
--- a/TextLCD_ostream.cpp Wed Jun 22 08:28:51 2016 +0000 +++ b/TextLCD_ostream.cpp Sun Jun 26 08:32:25 2016 +0000 @@ -8,12 +8,12 @@ lcd_ostream& lcd_ostream::locate(int column, int row) { - lcd->locate(column,row); + lcdp->locate(column,row); return *this; } lcd_ostream& lcd_ostream::cls() { - lcd->cls(); + lcdp->cls(); return *this; }
--- 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