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)

Committer:
jk1lot
Date:
Sat Jun 18 08:57:07 2016 +0000
Revision:
0:4ba062d3d524
Child:
1:e46139d4b8ba
1st version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jk1lot 0:4ba062d3d524 1 #ifndef TEXTLCD_OSTREAM_H
jk1lot 0:4ba062d3d524 2 #define TEXTLCD_OSTREAM_H
jk1lot 0:4ba062d3d524 3
jk1lot 0:4ba062d3d524 4 #include "TextLCD.h"
jk1lot 0:4ba062d3d524 5 #include<iostream>
jk1lot 0:4ba062d3d524 6 #include<fstream>
jk1lot 0:4ba062d3d524 7 #include <streambuf>
jk1lot 0:4ba062d3d524 8
jk1lot 0:4ba062d3d524 9 class lcd_streambuf : public std::streambuf {
jk1lot 0:4ba062d3d524 10 public:
jk1lot 0:4ba062d3d524 11 lcd_streambuf(TextLCD_Base *lcd) : _lcd(lcd) {}
jk1lot 0:4ba062d3d524 12 virtual int overflow( int c = EOF );
jk1lot 0:4ba062d3d524 13 private:
jk1lot 0:4ba062d3d524 14 TextLCD_Base *_lcd;
jk1lot 0:4ba062d3d524 15 };
jk1lot 0:4ba062d3d524 16
jk1lot 0:4ba062d3d524 17 class lcd_ostream : public std::ostream {
jk1lot 0:4ba062d3d524 18 public:
jk1lot 0:4ba062d3d524 19 lcd_ostream(TextLCD_Base *lcd);
jk1lot 0:4ba062d3d524 20 virtual ~lcd_ostream();
jk1lot 0:4ba062d3d524 21 lcd_ostream& locate(int column, int row);
jk1lot 0:4ba062d3d524 22 lcd_ostream& cls();
jk1lot 0:4ba062d3d524 23 private:
jk1lot 0:4ba062d3d524 24 TextLCD_Base *_lcd;
jk1lot 0:4ba062d3d524 25 lcd_streambuf *lcd_buf;
jk1lot 0:4ba062d3d524 26 };
jk1lot 0:4ba062d3d524 27 inline lcd_ostream& cls(lcd_ostream& s) {s.cls(); return s;} //manipulator
jk1lot 0:4ba062d3d524 28
jk1lot 0:4ba062d3d524 29 #endif