Fork of 4DGL lib for uLCD-144-G2. Different command values needed. See https://mbed.org/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/ for instructions and demo code.

Dependents:   mythermostat MorseCode SuperMbedBall frogger_G ... more

Fork of 4DGL by Adam Green

Files at this revision

API Documentation at this revision

Comitter:
4180_1
Date:
Wed Nov 20 03:25:53 2013 +0000
Parent:
3:9ba47197d94f
Child:
5:8936798c19a3
Commit message:
ver1.3

Changed in this revision

uLCD_4DGL.h Show annotated file Show diff for this revision Revisions of this file
uLCD_4DGL_Graphics.cpp Show annotated file Show diff for this revision Revisions of this file
uLCD_4DGL_main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/uLCD_4DGL.h	Mon Nov 18 03:05:40 2013 +0000
+++ b/uLCD_4DGL.h	Wed Nov 20 03:25:53 2013 +0000
@@ -26,7 +26,7 @@
 #endif
 
 // Common WAIT value in millisecond
-#define TEMPO 0.1
+#define TEMPO 0.05
 
 // 4DGL Functions values
 #define AUTOBAUD     '\x55'
@@ -301,6 +301,7 @@
 
     void freeBUFFER  (void);
     void writeBYTE   (char);
+    void writeBYTEfast   (char);
     int  writeCOMMAND(char *, int);
     int  writeCOMMANDnull(char *, int);
     int  readVERSION (char *, int);
@@ -316,3 +317,4 @@
 
 
 
+
--- a/uLCD_4DGL_Graphics.cpp	Mon Nov 18 03:05:40 2013 +0000
+++ b/uLCD_4DGL_Graphics.cpp	Wed Nov 20 03:25:53 2013 +0000
@@ -205,12 +205,13 @@
     writeBYTE(w & 0xFF);
     writeBYTE((h >> 8) & 0xFF);
     writeBYTE(h & 0xFF);
+    wait_ms(1);
     for (int i=0; i<w*h; i++) {
         red5   = (colors[i] >> (16 + 3)) & 0x1F;              // get red on 5 bits
         green6 = (colors[i] >> (8 + 2))  & 0x3F;              // get green on 6 bits
         blue5  = (colors[i] >> (0 + 3))  & 0x1F;              // get blue on 5 bits
-        writeBYTE(((red5 << 3)   + (green6 >> 3)) & 0xFF);  // first part of 16 bits color
-        writeBYTE(((green6 << 5) + (blue5 >> 0)) & 0xFF);  // second part of 16 bits color
+        writeBYTEfast(((red5 << 3)   + (green6 >> 3)) & 0xFF);  // first part of 16 bits color
+        writeBYTEfast(((green6 << 5) + (blue5 >> 0)) & 0xFF);  // second part of 16 bits color
     }
     int resp=0;
     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
@@ -305,3 +306,4 @@
 
     writeCOMMAND(command, 2);
 }
+
--- a/uLCD_4DGL_main.cpp	Mon Nov 18 03:05:40 2013 +0000
+++ b/uLCD_4DGL_main.cpp	Wed Nov 20 03:25:53 2013 +0000
@@ -64,7 +64,7 @@
 {
 
     _cmd.putc(c);
-    wait_ms(1);
+    wait_ms(1);  //mbed is too fast for LCD at high baud rates in long commands
 
 #if DEBUGMODE
     pc.printf("   Char sent : 0x%02X\n",c);
@@ -73,6 +73,18 @@
 }
 
 //******************************************************************************************************
+void uLCD_4DGL :: writeBYTEfast(char c)   // send a BYTE command to screen
+{
+
+    _cmd.putc(c);
+    //wait_ms(0.0);  //mbed is too fast for LCD at high baud rates - but not in some commands
+
+#if DEBUGMODE
+    pc.printf("   Char sent : 0x%02X\n",c);
+#endif
+
+}
+//******************************************************************************************************
 void uLCD_4DGL :: freeBUFFER(void)         // Clear serial buffer before writing command
 {
 
@@ -90,8 +102,12 @@
     int i, resp = 0;
     freeBUFFER();
     writeBYTE(0xFF);
-    for (i = 0; i < number; i++) writeBYTE(command[i]); // send command to serial port
-
+    for (i = 0; i < number; i++) {
+        if (i<16)
+            writeBYTEfast(command[i]); // send command to serial port
+        else
+            writeBYTE(command[i]); // send command to serial port but slower
+    }
     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
     if (_cmd.readable()) resp = _cmd.getc();           // read response if any
     switch (resp) {
@@ -134,8 +150,12 @@
     int i, resp = 0;
     freeBUFFER();
     writeBYTE(0x00); //command has a null prefix byte
-    for (i = 0; i < number; i++) writeBYTE(command[i]); // send command to serial port
-
+    for (i = 0; i < number; i++) {
+        if (i<16)
+            writeBYTEfast(command[i]); // send command to serial port
+        else
+            writeBYTE(command[i]); // send command to serial port
+    }
     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
     if (_cmd.readable()) resp = _cmd.getc();           // read response if any
     switch (resp) {
@@ -215,8 +235,7 @@
             newbaud = BAUD_4800;
             break;
         case 9600 :
-            newbaud = char(BAUD_9600 >>8);
-            newbaud = char(BAUD_9600 % 256);
+            newbaud = BAUD_9600;
             break;
         case 14400 :
             newbaud = BAUD_14400;