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

Revision:
13:4975e1c1d743
Parent:
12:21830002e12d
Child:
15:64250b58f933
--- a/AQM1602.hpp	Sat Oct 28 12:57:52 2017 +0000
+++ b/AQM1602.hpp	Fri Feb 07 05:23:48 2020 +0000
@@ -1,70 +1,63 @@
 //---------------------------------------------------------------
-//  Class for LCD, AQM1602XA-RN-GBW (Header)
-//
-//  Default pin assignments for Nucleo
-//      D14  SDA ---- to pin4 of LCD module
-//      D15  SCL ---- to pin3 of LCD module
+//  液晶表示器 AQM1602XA-RN-GBW 用クラス(ヘッダ)
 //
-//  動作を確認したボード: Nucleo-F401RE, Nucleo-F411RE, Nucleo-F446RE,
-//                      LPC1768
-//  動作が不良なボード:  Nucleo-F302R8, Nucle0-F746ZG, Disco-f746NG
+//  Nucleo の場合のデフォルトのピン
+//      D14 ---- 液晶モジュールの SDA ピン
+//      D15 ---- 液晶モジュールの SCL ピン
 //
-//  このプログラムを作った際の mbed のリビジョン:Rev.154
-//
-//  2017/10/28, Copyright (c) 2017 MIKAMI, Naoki
+//  2020/02/07, Copyright (c) 2020 MIKAMI, Naoki
 //---------------------------------------------------------------
 
+#include "mbed.h"
+#include <string>
+
 #ifndef AQM1602I2C_HPP
 #define AQM1602I2C_HPP
 
-#include "mbed.h"
-#include <string>
-#include <algorithm>    // min() で使用
-
 namespace Mikami
 {
     class Aqm1602
     {
     public:
-        // Constructor
-        // sda, scl のデフォルト値は Nucleo に対応
+        // コンストラクタ
+        // SDA, SCA のデフォルト値は Nucleo に対応
         Aqm1602(PinName sda = D14,          // SDA
                 PinName scl = D15,          // SCL
-                uint32_t clock = 100000,    // clock: 100 kHz
-                bool cursor = false,        // cursor:  off
-                bool blink = false);        // blink:   off
+                uint32_t clock = 100000,    // クロック: 100 kHz
+                bool cursor = false,        // カーソル:  off
+                bool blink = false);        // 点滅:     off
 
-        Aqm1602(I2C &i2c,                   // Reference of I2C object
-                uint32_t clock = 100000,    // clock: 100 kHz
-                bool cursor = false,        // cursor:  off
-                bool blink = false);        // blink:   off
+        Aqm1602(I2C &i2c,                   // I2C オブジェクトの参照
+                uint32_t clock = 100000,    // クロック: 100 kHz
+                bool cursor = false,        // カーソル:  off
+                bool blink = false);        // 点滅:     off
 
         virtual ~Aqm1602()
         {   if (NULL != i2cPtr_) delete i2cPtr_;    }
 
-        // Return false if LCD is not connected
+        // 液晶表示器が接続されていない場合 false を返す
         bool IsConnected() { return connected_; }
         
-        // All clear
+        // 表示のクリア
         void Clear();
         
-        // Send command
+        // コマンドの送信
         bool WriteCmd(uint8_t cmd) { return LcdTx(0x00, cmd); }
         
-        // Write character (Not 0x80 but 0x40)
+        // 1文字の書込み
         bool WriteChar(char data) { return LcdTx(0x40, data); }
         
-        // Specify display position, x: 0 - 7, y: 0, 1
+        // 表示位置の設定, x: 0 ~ 15, y: 0, 1
         void SetXY(uint8_t x = 0, uint8_t y = 0)
         { WriteCmd(x + y*0x40 | 0x80);}
         
-        // Write string
+        // 文字列の書込み
         void WriteString(const string str);
         
-        // Write string from specified position
+        // 指定した位置から文字列の書込み
         void WriteStringXY(const string str, uint8_t x, uint8_t y);
 
-        // Write numerical value
+        // 数値の書込み
         template <typename T> void WriteValue(const char fmt[], T value)
         {
             char str[N_CHR+1];
@@ -72,7 +65,7 @@
             WriteString(str);
         }
 
-        // Write numerical value from specified position
+        // 指定した位置から数値の書込み
         template <typename T>
         void WriteValueXY(const char fmt[], T value, uint8_t x, uint8_t y)
         {
@@ -80,28 +73,31 @@
             WriteValue(fmt, value);
         }
 
-        // Clear of specified line
+        // 指定した行のクリア
         void ClearLine(uint8_t line);
 
+        // コントラストの設定
         void SetContrast(uint8_t c);
 
     private:
-        // Slave address of AQM1602A
-        //      left-justified 7-bit address
+        // AQM1602A のアドレス
+        //      左詰め 7-bit アドレス
         static const uint8_t LCD_ADDRESS_ = 0x7C;
         static const uint8_t N_CHR = 16;
 
-        I2C *i2cPtr_;       // Pointer of I2C object
-        I2C &i2c_;          // Reference of I2C object
-        bool connected_;    // false: LCD is not connected
+        I2C *i2cPtr_;       // I2C オブジェクトのポインタ
+        I2C &i2c_;          // I2C オブジェクトの参照
+        bool connected_;    // false: 液晶表示器は接続されていないnected
 
+        // 初期化
         void Init(uint32_t clock, bool cursor, bool blink);
         
+        // コマンドとデータの送信
         bool LcdTx(uint8_t cmdData, uint8_t data);
 
-        // disallow copy constructor and assignment operator
+        // コピー・コンストラクタと代入演算子関数の禁止
         Aqm1602(const Aqm1602&);
         Aqm1602& operator=(const Aqm1602&);
     };
 }
-#endif  // AQM1602I2C_HPP
+#endif  // AQM1602I2C_HPP
\ No newline at end of file