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:
- 7:5375acc9a74a
- Parent:
- 4:c943f05b7843
- Child:
- 8:854c244a7863
diff -r 01336babcccd -r 5375acc9a74a AQM1602.cpp --- a/AQM1602.cpp Mon Sep 07 09:14:06 2015 +0000 +++ b/AQM1602.cpp Sun Nov 15 06:32:29 2015 +0000 @@ -1,7 +1,8 @@ //------------------------------------------------------- // Class for LCD, AQM1602XA-RN-GBW +// Do not use mbed Rev.109, using Nucleo-F401/441 // -// 2015/07/06, Copyright (c) 2015 MIKAMI, Naoki +// 2015/11/15, Copyright (c) 2015 MIKAMI, Naoki //------------------------------------------------------- #include "AQM1602.hpp" @@ -15,31 +16,30 @@ { if (clock != 100000) i2c_.frequency(clock); - wait_ms(40); - connected_ = Clear(); // Clear display - WriteCmd(0x39); // To extended command + wait_ms(50); + connected_ = WriteCmd(0x38); 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 - WriteCmd(0x6C); // Follower control + WriteCmd(0x39); // To extended command + WriteCmd(0x14); // Internal OSC frequency + WriteCmd(0x70 | 0x00); // Contrast set + WriteCmd(0x54 | 0x02); // Power/ICON/Contrast control + WriteCmd(0x6C); // Follower control wait_ms(200); + WriteCmd(0x01); WriteCmd(0x38); // data length:8-bit, 2-line, 5×8 dots WriteCmd(0x0C | (cursor << 1) | blink); } // All clear - bool Aqm1602::Clear() + void Aqm1602::Clear() { - bool ok = WriteCmd(0x01); - wait_ms(50); - return ok; + WriteCmd(0x01); + wait_ms(2); } // Write string @@ -83,6 +83,7 @@ { char tx[2] = { cmdData, data }; int rt = i2c_.write(LCD_ADDRESS_, tx, 2); + wait_us(30); return (rt == 0) ? true : false; } }