I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリ. Library for LCD 1602XA-RN-GBW connected using I2C interface.
Dependents: UIT2_MovingAv_Intr UIT2_VariableFIR UIT2_VowelSynthesizer UIT2_ALE_LeakyLMS ... more
Diff: AQM1602.cpp
- Revision:
- 3:414f98234c94
- Parent:
- 1:18cd1c4212c3
- Child:
- 4:c943f05b7843
--- a/AQM1602.cpp Mon Jun 15 05:26:21 2015 +0000 +++ b/AQM1602.cpp Sun Jul 05 10:35:49 2015 +0000 @@ -1,7 +1,7 @@ //------------------------------------------------------- // Class for LCD, AQM1602XA-RN-GBW // -// 2014/06/09, Copyright (c) 2015 MIKAMI, Naoki +// 2015/07/05, Copyright (c) 2015 MIKAMI, Naoki //------------------------------------------------------- #include "AQM1602.hpp" @@ -16,7 +16,13 @@ if (clock != 100000) i2c_.frequency(clock); wait_ms(40); - WriteCmd(0x39); // To extended command + connected_ = WriteCmd(0x39); // To extended command + if (!connected_) + { + fprintf(stderr, "\r\nLCD AQM1602 not connected\r\n"); + return; + } + WriteCmd(0x14); // Internal OSC frequency WriteCmd(0x70 | 0x00); // Contrast set WriteCmd(0x54 | 0x02); // Power/ICON/Contrast control @@ -72,11 +78,11 @@ // Following functions: private // Send command and data - void Aqm1602::LcdTx(uint8_t cmdData, uint8_t data) + bool Aqm1602::LcdTx(uint8_t cmdData, uint8_t data) { char tx[2] = { cmdData, data }; - i2c_.write(LCD_ADDRESS_, tx, 2); + int rt = i2c_.write(LCD_ADDRESS_, tx, 2); + return (rt == 0) ? true : false; } } -