Using std::ostream with TextLCD

Dependencies:   ACM1602NI TextLCD

Dependents:   TextLCD_ostream_sample

Embed: (wiki syntax)

« Back to documentation index

TextLCD_ostream< LCDCLASS > Class Template Reference

TextLCD_ostream< LCDCLASS > Class Template Reference

ostream wrapper for TextLCD. More...

#include <TextLCD_ostream.h>

Public Member Functions

 TextLCD_ostream (LCDCLASS *p)
LCDCLASS & lcd ()
 access LCD object
TextLCD_ostreamlocate (int column, int row)
 set cursor position.
TextLCD_ostreamcls ()
 clear screen same as LCDCLASS::cls(), except return value type

Detailed Description

template<class LCDCLASS>
class TextLCD_ostream< LCDCLASS >

ostream wrapper for TextLCD.

LCDCLASS(TextLCD) need to have putc(),locate(),cls() function.

#include "mbed.h"
#include "TextLCD.h"
#include "TextLCD_ostream.h"
 
I2C i2c(p28,p27); // SDA, SCL
TextLCD_I2C_N lcd(&i2c, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3);
TextLCD_ostream<TextLCD_I2C_N> lcdstream(&lcd);

int main() {
    using namespace std;
    lcd.setContrast(32);
    lcdstream.cls() << "Hello world" << endl << "LCD ostream";
}

Definition at line 26 of file TextLCD_ostream.h.


Constructor & Destructor Documentation

TextLCD_ostream ( LCDCLASS *  p )
Parameters:
ppointer to object of LCD class

Definition at line 29 of file TextLCD_ostream.h.


Member Function Documentation

TextLCD_ostream& cls (  )

clear screen same as LCDCLASS::cls(), except return value type

Definition at line 41 of file TextLCD_ostream.h.

LCDCLASS& lcd (  )

access LCD object

Definition at line 32 of file TextLCD_ostream.h.

TextLCD_ostream& locate ( int  column,
int  row 
)

set cursor position.

same as LCDCLASS::locate(), except return value type

Definition at line 35 of file TextLCD_ostream.h.