Aitendo OLED device driver library.

Dependents:   AitendoOLED_TestProgram

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Sun Dec 19 07:46:13 2010 +0000
Parent:
1:4b819d5ea905
Commit message:
Bug fixed. The status bit 7 of the resister is not mean busy. It\s just a queue status.

Changed in this revision

AitendoOLED.cpp Show annotated file Show diff for this revision Revisions of this file
AitendoOLED.h Show annotated file Show diff for this revision Revisions of this file
diff -r 4b819d5ea905 -r 74c60a959299 AitendoOLED.cpp
--- a/AitendoOLED.cpp	Sun Dec 19 07:11:08 2010 +0000
+++ b/AitendoOLED.cpp	Sun Dec 19 07:46:13 2010 +0000
@@ -1,6 +1,6 @@
 /**
  * =============================================================================
- * Aitendo OLED device driver library. (Version 0.0.1)
+ * Aitendo OLED device driver library. (Version 0.0.2)
  *
  * [The product]
  * OLED-2P-095BWNN-SPI : http://www.aitendo.co.jp/product/2099
@@ -40,8 +40,8 @@
 #define DC_DAT()        io_dc = 1
 #define SPI_WRITE(a)    io_spi.write((a))
 #define SPI_READ()      io_spi.write(0x00)
+#define WAIT_US(a)      wait_us((a))
 #define swap(a,b) {int c=a;a=b;b=c;}
-#define waitDone() while(1) {uint8_t s = readStatusRegister();if ((s & 0x80) != 0) {break;}}
 
 /**
  * Create.
@@ -119,7 +119,7 @@
     SPI_WRITE(c.g >> 2);
     SPI_WRITE(c.r >> 3);
     CS_DIS();
-    waitDone();
+    WAIT_US(100);
 #else
     /*
      * Bresenham's line algorithm
@@ -183,7 +183,7 @@
     SPI_WRITE(c2.g >> 2);
     SPI_WRITE(c2.r >> 3);
     CS_DIS();
-    waitDone();
+    WAIT_US(400);
 }
 
 /**
@@ -207,7 +207,7 @@
     SPI_WRITE(nx);
     SPI_WRITE(ny);
     CS_DIS();
-    waitDone();
+    WAIT_US(400);
 }
 
 /**
@@ -227,7 +227,7 @@
     SPI_WRITE(x2);
     SPI_WRITE(y2);
     CS_DIS();
-    waitDone();
+    WAIT_US(400);
 }
 
 /**
@@ -239,6 +239,7 @@
  * @param y2 Y2.
  */
 void AitendoOLED::clear(int x1, int y1, int x2, int y2) {
+#if 1
     DC_CMD();
     CS_ENA();
     SPI_WRITE(0x25);
@@ -247,7 +248,18 @@
     SPI_WRITE(x2);
     SPI_WRITE(y2);
     CS_DIS();
-    waitDone();
+    WAIT_US(400);
+#else
+    AitendoOLED::Color c;
+    c.r = 0x00;
+    c.g = 0x00;
+    c.b = 0x00;
+    for (int x = x1; x <= x2; x++) {
+        for (int y = y1; y <= y2; y++) {
+            drawPixel(x, y, c);
+        }
+    }
+#endif
 }
 
 /**
@@ -256,9 +268,9 @@
 void AitendoOLED::reset() {
 
     RES_ENA();
-    wait_ms(200);
+    WAIT_US(200 * 1000);
     RES_DIS();
-    wait_ms(200);
+    WAIT_US(200 * 1000);
 
     setDisplayOnOff(false);
     setRowAddress(0, 63);
@@ -663,7 +675,7 @@
 /**
  * Read the status register.
  *
- * @return the value.
+ * @return the value. (0x80:CommandLock)
  */
 uint8_t AitendoOLED::readStatusRegister() {
     uint8_t s;
diff -r 4b819d5ea905 -r 74c60a959299 AitendoOLED.h
--- a/AitendoOLED.h	Sun Dec 19 07:11:08 2010 +0000
+++ b/AitendoOLED.h	Sun Dec 19 07:46:13 2010 +0000
@@ -1,6 +1,6 @@
 /**
  * =============================================================================
- * Aitendo OLED device driver library. (Version 0.0.1)
+ * Aitendo OLED device driver library. (Version 0.0.2)
  *
  * [The product]
  * OLED-2P-095BWNN-SPI : http://www.aitendo.co.jp/product/2099