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:
3:414f98234c94
Parent:
2:f496f85ce6f2
Child:
4:c943f05b7843
--- a/AQM1602.hpp	Mon Jun 15 05:26:21 2015 +0000
+++ b/AQM1602.hpp	Sun Jul 05 10:35:49 2015 +0000
@@ -1,7 +1,6 @@
 //-------------------------------------------------------
 //  Class for LCD, AQM1602XA-RN-GBW (Header)
 //
-//
 //  Default pin assignments
 //      D14  SDA ---- to pin4 of LCD module
 //      D15  SCL ---- to pin3 of LCD module
@@ -12,7 +11,7 @@
 //      I2C2   PB_3(D3)           PB_10(D6)
 //      I2C3   PB_4(D5) or PC_9   PA_8(D7)
 //
-//  2014/06/15, Copyright (c) 2015 MIKAMI, Naoki
+//  2015/06/15, Copyright (c) 2015 MIKAMI, Naoki
 //-------------------------------------------------------
 
 #ifndef AQM1602I2C_HPP
@@ -33,14 +32,17 @@
                 bool cursor = false,        // cursor:  off
                 bool blink = false);        // blink:   off
 
+        // Return false if LCD is not connected
+        bool IsConnected() { return connected_; }
+        
         // All clear
         void Clear();
         
         // Send command
-        void WriteCmd(uint8_t cmd) { LcdTx(0x00, cmd); }
+        bool WriteCmd(uint8_t cmd) { return LcdTx(0x00, cmd); }
         
         // Write character (Not 0x80 but 0x40)
-        void WriteChar(char data) { LcdTx(0x40, data); }
+        bool WriteChar(char data) { return LcdTx(0x40, data); }
         
         // Specify display position, x: 0 - 7, y: 0, 1
         void SetXY(uint8_t x = 0, uint8_t y = 0)
@@ -61,14 +63,15 @@
         void SetContrast(uint8_t c);
 
     private:
-        // Slave address of AQM0802A
+        // Slave address of AQM1602A
         //      left-justified 7-bit address
         static const uint8_t LCD_ADDRESS_ = 0x7C;
         static const uint8_t N_CHR = 16;
 
         I2C i2c_;               // Object of I2C
+        bool connected_;        //  false: LCD is not connected
 
-        void LcdTx(uint8_t cmdData, uint8_t data);
+        bool LcdTx(uint8_t cmdData, uint8_t data);
 
         // Forbid to use copy constructor
         Aqm1602(const Aqm1602&);
@@ -76,4 +79,4 @@
         Aqm1602& operator=(const Aqm1602&);
     };
 }
-#endif  // AQM0802I2C_HPP
+#endif  // AQM1602I2C_HPP