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:
8:854c244a7863
Parent:
7:5375acc9a74a
Child:
9:74a845df6e7a
diff -r 5375acc9a74a -r 854c244a7863 AQM1602.hpp
--- a/AQM1602.hpp	Sun Nov 15 06:32:29 2015 +0000
+++ b/AQM1602.hpp	Thu Jan 14 05:55:06 2016 +0000
@@ -6,7 +6,7 @@
 //      D14  SDA ---- to pin4 of LCD module
 //      D15  SCL ---- to pin3 of LCD module
 //
-//  2015/11/15, Copyright (c) 2015 MIKAMI, Naoki
+//  2016/01/14, Copyright (c) 2015 MIKAMI, Naoki
 //-------------------------------------------------------
 
 #ifndef AQM1602I2C_HPP
@@ -35,11 +35,19 @@
                 bool cursor = false,        // cursor:  off
                 bool blink = false);        // blink:   off
 #endif
+        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()
+        {   if (NULL != i2cPtr_) delete i2cPtr_;    }
+
         // Return false if LCD is not connected
         bool IsConnected() { return connected_; }
         
         // All clear
-        void Clear();
+        bool Clear();
         
         // Send command
         bool WriteCmd(uint8_t cmd) { return LcdTx(0x00, cmd); }
@@ -71,9 +79,12 @@
         static const uint8_t LCD_ADDRESS_ = 0x7C;
         static const uint8_t N_CHR = 16;
 
-        I2C i2c_;               // Object of I2C
+        I2C *i2cPtr_;           // Pointer of I2C object
+        I2C &i2c_;              // Reference of I2C object
         bool connected_;        // false: LCD is not connected
 
+        void Init(uint32_t clock, bool cursor, bool blink);
+        
         bool LcdTx(uint8_t cmdData, uint8_t data);
 
         // disallow copy constructor and assignment operator