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

Revision:
4:74df7fc26fef
Parent:
2:edae99e4abe7
Child:
5:8936798c19a3
--- 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;