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@4:0e305f955741, 2016-06-22 (annotated)
- Committer:
- jk1lot
- Date:
- Wed Jun 22 08:31:30 2016 +0000
- Revision:
- 4:0e305f955741
- Parent:
- 1:2775f5dc2099
- Child:
- 5:4d1ddc9177b0
add akiduki LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jk1lot | 0:52f56aefba64 | 1 | #include "mbed.h" |
jk1lot | 0:52f56aefba64 | 2 | #include "TextLCD_ostream.h" |
jk1lot | 1:2775f5dc2099 | 3 | #include <iomanip> |
jk1lot | 0:52f56aefba64 | 4 | |
jk1lot | 0:52f56aefba64 | 5 | I2C i2c(p28,p27); // SDA, SCL |
jk1lot | 4:0e305f955741 | 6 | //マルツ MI2CLCD |
jk1lot | 4:0e305f955741 | 7 | //TextLCD_I2C_N lcd(&i2c, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); |
jk1lot | 4:0e305f955741 | 8 | //const int LCDCONTRAST=32; |
jk1lot | 4:0e305f955741 | 9 | //秋月8x2 |
jk1lot | 4:0e305f955741 | 10 | //TextLCD_I2C_N lcd(&i2c, ST7032_SA, TextLCD::LCD8x2); |
jk1lot | 4:0e305f955741 | 11 | //const int LCDCONTRAST=20; |
jk1lot | 4:0e305f955741 | 12 | //秋月16x2小型 |
jk1lot | 4:0e305f955741 | 13 | TextLCD_I2C_N lcd(&i2c); |
jk1lot | 4:0e305f955741 | 14 | const int LCDCONTRAST=30; |
jk1lot | 4:0e305f955741 | 15 | |
jk1lot | 0:52f56aefba64 | 16 | lcd_ostream lcds(&lcd); |
jk1lot | 0:52f56aefba64 | 17 | |
jk1lot | 0:52f56aefba64 | 18 | int main() { |
jk1lot | 0:52f56aefba64 | 19 | using namespace std; |
jk1lot | 4:0e305f955741 | 20 | lcd.setContrast(LCDCONTRAST); |
jk1lot | 0:52f56aefba64 | 21 | while(true) { |
jk1lot | 1:2775f5dc2099 | 22 | // lcds.cls() は lcd_ostream& を返すので、そこにそのまま << 出来る |
jk1lot | 1:2775f5dc2099 | 23 | // endl で次の行の先頭に行く |
jk1lot | 1:2775f5dc2099 | 24 | lcds.cls() << "Hello world" << endl << "LCD ostream"; |
jk1lot | 1:2775f5dc2099 | 25 | wait(2); |
jk1lot | 1:2775f5dc2099 | 26 | lcds.cls(); |
jk1lot | 1:2775f5dc2099 | 27 | for(int i=0; i<6; i++) { |
jk1lot | 1:2775f5dc2099 | 28 | //最下行で endl すると1行目に移動する |
jk1lot | 1:2775f5dc2099 | 29 | lcds << "line:" << i << endl; |
jk1lot | 1:2775f5dc2099 | 30 | wait(1); |
jk1lot | 1:2775f5dc2099 | 31 | } |
jk1lot | 1:2775f5dc2099 | 32 | lcds.cls() << 10L << ',' << setw(4) << 3.14f << endl << "count: "; |
jk1lot | 0:52f56aefba64 | 33 | for(int i=3; i>=0; i--) { |
jk1lot | 1:2775f5dc2099 | 34 | // locate() も cls()と同様に続けて << 出来る |
jk1lot | 0:52f56aefba64 | 35 | lcds.locate(8,1) << i; |
jk1lot | 0:52f56aefba64 | 36 | wait(1); |
jk1lot | 0:52f56aefba64 | 37 | } |
jk1lot | 1:2775f5dc2099 | 38 | wait(2); |
jk1lot | 0:52f56aefba64 | 39 | } |
jk1lot | 0:52f56aefba64 | 40 | } |