Fork of the 4DGL-uLCD-SE library by Jim Hamblen.

Dependents:   ulcd_demo ulcd_accel internet_clock 4180_Final_Project ... more

Fork of 4DGL-uLCD-SE by jim hamblen

Revision:
5:8936798c19a3
Parent:
4:74df7fc26fef
Child:
6:b759b69cbaf9
--- a/uLCD_4DGL_main.cpp	Wed Nov 20 03:25:53 2013 +0000
+++ b/uLCD_4DGL_main.cpp	Fri Nov 22 02:44:37 2013 +0000
@@ -23,6 +23,7 @@
 
 //Serial pc(USBTX,USBRX);
 
+
 //******************************************************************************************************
 uLCD_4DGL :: uLCD_4DGL(PinName tx, PinName rx, PinName rst) : _cmd(tx, rx),
     _rst(rst)
@@ -42,7 +43,6 @@
 #endif
 
     _rst = 1;    // put RESET pin to high to start TFT screen
-
     reset();
 
 //  autobaud();  // send autobaud command
@@ -131,9 +131,9 @@
 //**************************************************************************
 void uLCD_4DGL :: reset()    // Reset Screen
 {
-
+    wait_ms(5);
     _rst = 0;               // put RESET pin to low
-    wait_ms(TEMPO);         // wait a few milliseconds for command reception
+    wait_ms(5);         // wait a few milliseconds for command reception
     _rst = 1;               // put RESET back to high
     wait(3);                // wait 3s for screen to restart
 
@@ -264,6 +264,21 @@
         case 256000 :
             newbaud = BAUD_256000;
             break;
+        case 300000 :
+            newbaud = BAUD_300000;
+            speed = 272727;
+            break;
+        case 375000 :
+            newbaud = BAUD_375000;
+            speed = 333333;
+            break;
+        case 500000 :
+            newbaud = BAUD_500000;
+            speed = 428571;
+            break;
+        case 600000 :
+            newbaud = BAUD_600000;
+            break;
         default   :
             newbaud = BAUD_9600;
             speed = 9600;
@@ -275,11 +290,15 @@
     freeBUFFER();
     command[1] = char(newbaud >>8);
     command[2] = char(newbaud % 256);
-    for (i = 0; i <3; i++) writeBYTE(command[i]);      // send command to serial port
+    wait_ms(1);
+    for (i = 0; i <3; i++) writeBYTEfast(command[i]);      // send command to serial port
+    wait_ms(10); //dont change baud until all characters get sent out
     _cmd.baud(speed);                                  // set mbed to same speed
-
-    while (!_cmd.readable()) wait_ms(TEMPO);           // wait for screen answer
-
+    i=0;
+    while ((!_cmd.readable()) && (i<25000)) {
+        wait_ms(TEMPO);           // wait for screen answer - comes 100ms after change
+        i++; //timeout if ack character missed by baud change
+    }
     if (_cmd.readable()) resp = _cmd.getc();           // read response if any
     switch (resp) {
         case ACK :                                     // if OK return   1