Akinori Hashimoto / SO1602A

Dependents:   NEW_LineTraceHub NEW_LineTraceHub_2 ColorSensorTest

Revision:
0:d8b95544d238
Child:
1:eef15a16fe7a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SO1602A.h	Tue Sep 08 08:35:42 2015 +0000
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "mbed.h"
+
+// SA0(Pin4)=Low: i2c_addr= 0x78, High: 0x7a;
+// DDRAM addr. Line1: 0x00 ~ 0x0f. Line2: 0x20 ~ 0x2f.
+
+class SO1602A : public Stream{
+public:
+    SO1602A (PinName sda, PinName scl, char address= 0x78);
+    SO1602A (I2C &_i2c, char address= 0x78);
+    
+//  ******************** printf() future of C-language. ***************************
+
+    /** Initialize
+     */
+    void init();
+
+    /** Clear Display.
+     */
+    void clear();
+    
+    /** Set Position of char.
+     *  @param col: column, row: rows.
+     */
+    void locate(int col, int row);
+    
+    /** Set Contrast.
+     *  @param val; 256steps, 0x00 ~ 0xff. Contrast increas as the value.
+     */
+    void setContrast(char val);
+
+private:    
+    I2C i2c;
+    char addr;
+    char buf[3];
+    int _column, _row;
+    
+    bool cmd(char chr);
+    
+    // virtual func for printf() in Stream-class.
+    virtual int _putc(int val);
+    virtual int _getc();
+    
+// Function SET
+    void setRE();
+    void clearRE();
+    void setSD();
+    void clearSD();
+
+};
+
+// EOF
\ No newline at end of file