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:
- 15:64250b58f933
- Parent:
- 14:5e1b1de66a7f
diff -r 5e1b1de66a7f -r 64250b58f933 AQM1602.cpp --- a/AQM1602.cpp Fri Feb 14 07:14:51 2020 +0000 +++ b/AQM1602.cpp Thu Apr 16 04:22:48 2020 +0000 @@ -1,11 +1,11 @@ //--------------------------------------------------------------- -// 液晶表示器 AQM1602XA-RN-GBW 用クラス(ヘッダ) +// 液晶表示器 AQM1602XA-RN-GBW 用クラス,メンバ関数の定義 // // Nucleo の場合のデフォルトのピン // D14 ---- 液晶モジュールの SDA ピン // D15 ---- 液晶モジュールの SCL ピン // -// 2020/02/14, Copyright (c) 2020 MIKAMI, Naoki +// 2020/04/16, Copyright (c) 2020 MIKAMI, Naoki //--------------------------------------------------------------- #include "AQM1602.hpp" @@ -20,45 +20,45 @@ Aqm1602::Aqm1602(I2C &i2c, uint32_t clock, bool cursor, bool blink) - : i2cPtr_(NULL), i2c_(i2c) + : i2cPtr_(NULL), i2c_(i2c) { Init(clock, cursor, blink); } // 表示のクリア - void Aqm1602::Clear() + void Aqm1602::Clear() const { WriteCmd(0x01); wait_ms(50); } // 文字列の書込み - void Aqm1602::WriteString(const string str) + void Aqm1602::WriteString(const string str) const { int length = min(str.length(), (size_t)N_CHR); for (int n=0; n<length; n++) WriteChar(str[n]); } // 指定した位置から文字列の書込み - void Aqm1602::WriteStringXY(const string str, uint8_t x, uint8_t y) + void Aqm1602::WriteStringXY(const string str, + uint8_t x, uint8_t y) const { SetXY(x, y); WriteString(str); } // 指定した行のクリア - void Aqm1602::ClearLine(uint8_t line) + void Aqm1602::ClearLine(uint8_t line) const { SetXY(0, line); - for (int n=0; n<N_CHR; n++) - WriteString(" "); + for (int n=0; n<N_CHR; n++) WriteString(" "); } // コントラストの設定 - void Aqm1602::SetContrast(uint8_t c) + void Aqm1602::SetContrast(uint8_t c) const { - WriteCmd(0x39); // To extended command - WriteCmd(0x70 | (c & 0x0f)); // Lower 4 bits - WriteCmd(0x5C | ((c >> 4) & 0x03)); // Higher 2 bits - WriteCmd(0x38); // Return to normal command + WriteCmd(0x39); // 拡張コマンドへ + WriteCmd(0x70 | (c & 0x0f)); // 下位 4 ビット + WriteCmd(0x5C | ((c >> 4) & 0x03)); // 上位 2 ビット + WriteCmd(0x38); // ノーマル・コマンドへ } // 初期化 @@ -86,14 +86,14 @@ WriteCmd(0x38); // 通常の命令モードへ復帰, // データ長:8-bit, 2-line, 5×8 dots -// WriteCmd(0x01); // クリア,これを入れると正常に動作しないようだ +// WriteCmd(0x01); // クリア,これを入れると正常に動作しない WriteCmd(0x0C | (cursor << 1) | blink); Clear(); } // コマンドとデータの送信 - bool Aqm1602::LcdTx(uint8_t cmdData, uint8_t data) + bool Aqm1602::LcdTx(uint8_t cmdData, uint8_t data) const { // このメンバ関数を割込み処理で使う場合,以下の処理ではうまく動作しない /* @@ -101,7 +101,7 @@ wait_us(30); return (rt == 0) ? true : false; */ - // 以下の処理は割込み処理で使っても大丈夫 + // 以下の処理の場合は,このメンバ関数を割込み処理で使っても大丈夫 i2c_.start(); if (1 != i2c_.write(LCD_ADDRESS_)) return false; if (1 != i2c_.write(cmdData)) return false;