sample program using TextLCD_ostream
Dependencies: TextLCD_ostream mbed
This is sample program using std::ostream with TextLCD
Because a large amount of memory is needed, it does not work in low memory MPU.
(It works fine on mbed LPC1768 and STM32 Nucleo-L476RG. But linker error occard on TG-LPC11U35-501)
main.cpp
- Committer:
- jk1lot
- Date:
- 2016-06-26
- Revision:
- 5:4d1ddc9177b0
- Parent:
- 4:0e305f955741
- Child:
- 6:96bc6126d7f0
File content as of revision 5:4d1ddc9177b0:
#include "mbed.h" #include "TextLCD_ostream.h" #include <iomanip> I2C i2c(p28,p27); // SDA, SCL //マルツ MI2CLCD-01 I2C 16x2+icon //ストロベリーリナックス I2C 16x2+icon //秋月 小型I2C 16x2 TextLCD_I2C_N lcd(&i2c); const int LCDCONTRAST=32; //秋月 超小型I2C 8x2 //TextLCD_I2C_N lcd(&i2c, ST7032_SA, TextLCD::LCD8x2); //const int LCDCONTRAST=20; //秋月 PIC搭載 I2C 16x2 これはうまくいかない //TextLCD_I2C_N lcd(&i2c, 0xA0, TextLCD::LCD16x2,NC,TextLCD::ST7066_ACM); //const int LCDCONTRAST=0; //contrast control is not supported lcd_ostream lcds(&lcd); int main() { using namespace std; // lcds.lcd() で元の TextLCDにアクセス出来る if(LCDCONTRAST) lcds.lcd().setContrast(LCDCONTRAST); while(true) { // lcds.cls() は lcd_ostream& を返すので、そこにそのまま << 出来る // endl で次の行の先頭に行く lcds.cls() << "Hello world" << endl << "LCD ostream"; wait(2); lcds.cls(); for(int i=0; i<6; i++) { //最下行で endl すると1行目に移動する lcds << "line:" << i << endl; wait(1); } lcds.cls() << 10L << ',' << setw(4) << 3.14f << endl << "count: "; for(int i=3; i>=0; i--) { // locate() も cls()と同様に続けて << 出来る lcds.locate(8,1) << i; wait(1); } wait(2); } }