mbed TextOLED Library, for a 4-bit LCD based on Winstar WEH000000 series Originl: http://mbed.org/users/simon/libraries/TextLCD/latest 共立電子 デジット の OLEDモジュール 4bitモード用

Dependents:   Dawson_Controller allsystem_2

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Wed Nov 28 03:32:30 2012 +0000
Parent:
1:df8722660f48
Commit message:
fix init

Changed in this revision

TextOLED.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r df8722660f48 -r 45788bd06d4c TextOLED.cpp
--- a/TextOLED.cpp	Tue Jul 31 04:39:41 2012 +0000
+++ b/TextOLED.cpp	Wed Nov 28 03:32:30 2012 +0000
@@ -31,27 +31,31 @@
                  PinName d6, PinName d7, LCDType type) : _rs(rs),
         _e(e), _d(d4, d5, d6, d7),
         _type(type) {
+    int i;
 
+    _rs = 0;            // command mode
     _e  = 1;
-    _rs = 0;            // command mode
 
     wait_ms(100);        // Wait 15ms to ensure powered up
 
+    for (i = 0; i < 5; i ++) {
+        write4bit(0);
+    }
+/*
     write4bit(0x3);     // 8-bit mode
-    write4bit(0x0);     // 8-bit mode
+    write4bit(0x3);     // 8-bit mode
+    write4bit(0x0);
+*/
     write4bit(0x2);     // 4-bit mode
 
-    writeCommand(0x13); // DCDC off
-    wait_ms(100);
-
     writeCommand(0x28); // Function set 001 BW N F - -
     writeCommand(0x0C); // 0000 1 D C B
     writeCommand(0x06); // Entry mode : 0000 01 I/D S
-    cls();
-    writeCommand(0x02); // Home
     writeCommand(0x10); // Cursor and Display Shift 0001 S/C R/L 0 0
     writeCommand(0x17); // DCDC on
-    wait_ms(100);
+    wait_ms(10);
+    writeCommand(0x02); // Home
+    cls();
 }
 
 void TextOLED::character(int column, int row, int c) {
@@ -97,36 +101,35 @@
 }
 
 void TextOLED::write4bit(int value) {
+    _e = 1;
     _d = value;
     wait_us(1);
     _e = 0;
-    wait_us(1);
-    _e = 1;
     wait_ms(10);
 }
 
 void TextOLED::writeByte(int value) {
-    _d = value >> 4;
+    _e = 1;
+    _d = (value >> 4) & 0x0f;
     wait_us(1);
     _e = 0;
     wait_us(1);
     _e = 1;
-    wait_us(1);
-    _d = value >> 0;
+    _d = value & 0x0f;
     wait_us(1);
     _e = 0;
-    wait_us(1);
-    _e = 1;
     wait_us(50);
 }
 
 void TextOLED::writeCommand(int command) {
     _rs = 0;
+    wait_us(1);
     writeByte(command);
 }
 
 void TextOLED::writeData(int data) {
     _rs = 1;
+    wait_us(1);
     writeByte(data);
 }