Akinori Hashimoto / SO1602A

Dependents:   NEW_LineTraceHub NEW_LineTraceHub_2 ColorSensorTest

Files at this revision

API Documentation at this revision

Comitter:
AkinoriHashimoto
Date:
Wed Sep 09 00:04:00 2015 +0000
Parent:
0:d8b95544d238
Child:
2:45791c1064f6
Commit message:
Write example code.; Make setDisplayFlag Function.

Changed in this revision

SO1602A.cpp Show annotated file Show diff for this revision Revisions of this file
SO1602A.h Show annotated file Show diff for this revision Revisions of this file
--- a/SO1602A.cpp	Tue Sep 08 08:35:42 2015 +0000
+++ b/SO1602A.cpp	Wed Sep 09 00:04:00 2015 +0000
@@ -68,9 +68,8 @@
     wait_ms(10);
     this->clear();
     this->cmd(0x02);    //Return Home.
-    this->cmd(0x0f);    // set On/Off. b3=1, b2:Disp, b1:Cursor, b0:blink.
-    this->cmd(0x01);    //Clear Disp.
-    wait_ms(20);
+    this->setDispFlag(true, true, true);
+    
     return;
 }
 
@@ -88,6 +87,22 @@
     return;
 }
 
+void setDispFlag(bool disp, bool cursor, bool blink)
+{
+    // set On/Off. b3=1, b2:Disp, b1:Cursor, b0:blink.
+    char tmp=  0x08;
+    if(disp)
+        tmp += 0x04;
+    if(cursor)
+        tmp += 0x02;
+    if(blink)
+        tmp += 0x01;
+    this->cmd(tmp);
+    this->cmd(0x01);    //Clear Disp.
+    wait_ms(20);
+    return;
+}
+
 void SO1602A::clear()
 {
     this->cmd(0x01);
--- a/SO1602A.h	Tue Sep 08 08:35:42 2015 +0000
+++ b/SO1602A.h	Wed Sep 09 00:04:00 2015 +0000
@@ -1,3 +1,16 @@
+/**  SO1602A is Organic-LED, and has 16 chars/line and 2 lines.
+ * This librarry supports "printf()" C format.
+ *
+ * EX. code.
+ *  
+ * I2C i2c(p9, p10);
+ * SO1602A oled(i2c); // if SA0 is Low. Otherwise, oled(i2c, 0x7a);
+ * // SO1602A oled(p9, p10);
+ * oled.setContrast(0xff);
+ * oled.setDispFlag(true, true, false);
+ * oled.printf("test:%d,%f", i, 3.14);
+ */
+
 #pragma once
 
 #include "mbed.h"
@@ -29,6 +42,11 @@
      *  @param val; 256steps, 0x00 ~ 0xff. Contrast increas as the value.
      */
     void setContrast(char val);
+    
+    /** Set Display flag.
+     * @parm Enable Display, Cursor turned on, Cursor Blink.
+     */
+    void setDispFlag(bool disp, bool cursor, bool blink);
 
 private:    
     I2C i2c;