This is a port of Henning Kralsen's UTFT library for Arduino/chipKIT to mbed, refactored to make full use of C inheritance and access control, in order to reduce work when implementing new drivers and at the same time make the code more readable and easier to maintain. As of now supported are SSD1289 (16-bit interface), HX8340-B (serial interface) and ST7735 (serial interface). Drivers for other controllers will be added as time and resources to acquire the displays to test the code permit.

Dependents:   UTFT_SSD1289

Fork of TFTLCD by Todor Todorov

Revision:
26:28f64fbcf7df
Parent:
25:6cffb758c075
Child:
27:26491d710e72
--- a/ili9328.cpp	Sun Jun 16 02:53:06 2013 +0000
+++ b/ili9328.cpp	Sun Jun 16 03:36:07 2013 +0000
@@ -85,6 +85,10 @@
     }
     switch ( _colorDepth )
     {
+        case RGB18:
+            entryMod |= 0x9000;
+            break;
+            
         case RGB16:
         default:
             entryMod |= 0x1000;
@@ -212,6 +216,7 @@
 {
     unsigned char r, g, b;
     unsigned short clr;
+    r = g = b = 0;
     if ( _colorDepth == RGB16 )
     {
         switch ( mode )
@@ -243,23 +248,20 @@
                 r = ( ( color >> 8 ) & 0xF8 ) | ( ( color & 0x8000 ) >> 13 );
                 g = ( color >> 3 ) & 0xFC;
                 b = ( ( color << 3 ) & 0xFC ) | ( ( color >> 3 ) & 0x01 );
-                WriteData( ( r << 8 ) | g );
-                WriteData( b );
                 break;
             case RGB18:
                 b = ( color << 2 ) & 0xFC;
                 g = ( color >> 4 ) & 0xFC;
                 r = ( color >> 10 ) & 0xFC;
-                WriteData( ( r << 8 ) | g );
-                WriteData( b );
                 break;
             case RGB24:
                 r = ( color >> 16 ) & 0xFC;
                 g = ( color >> 8 ) & 0xFC;
                 b = color & 0xFC;
-                WriteData( ( r << 8 ) | g );
-                WriteData( b );
                 break;
         }
+        clr = ( r << 8 ) | ( g << 2 ) | ( b >> 4 );
+        WriteData( clr );
+        WriteData( b << 4 );
     }
 }