Demo project to demonstrate that ILI9340 display driver and graphics library. very simple but a good starting point for any project using such a display. Please use this to thoroughly enjoy yourself and make your projects cool!

Dependencies:   ILI9340_Driver_Lib mbed

About the Driver:

This driver will drive any display that uses an ILI9340 display controller in SPI mode - such as the adafruits 2.2" 240 x 320 display found here: http://www.adafruit.com/products/1480

All this code has been ported from other peoples hard work - Thanks to All !

Files at this revision

API Documentation at this revision

Comitter:
dextorslabs
Date:
Sun Jun 01 17:02:58 2014 +0000
Parent:
1:0615e3c659c0
Commit message:
Demo Project - A good base for starting your own projects using the ILI9340 driver library. I hope people find this helpful!

Changed in this revision

Demo.cpp Show annotated file Show diff for this revision Revisions of this file
ILI9340_Driver.cpp Show diff for this revision Revisions of this file
ILI9340_Driver.h Show diff for this revision Revisions of this file
ILI9340_Driver_Lib.lib Show annotated file Show diff for this revision Revisions of this file
SimpleFont.cpp Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
diff -r 0615e3c659c0 -r 7800c62c22d1 Demo.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Demo.cpp	Sun Jun 01 17:02:58 2014 +0000
@@ -0,0 +1,104 @@
+/***************************************************************
+    ILI9340_Driver  v1.1    26.05.14    Ian Weston
+    
+Demo project to demonstrate the ILI9340 display driver and graphics
+library in action. very simple, good base for any project.    
+
+About the Library:
+
+Driver and integrated graphics library for displays that use the 
+ILI9340 controller in SPI mode.
+
+The code was prted from several sources, the driver section
+was completely ported from the Adafruits Arduino source code, and
+the graphics functions were ported from the Adafruits GFX library
+and some elements were ported from code by Elmicros seeduio port.
+
+Future revisions will include more advanced graphics functions.
+
+Rough and ready Demo code to for showing the driver and some 
+functions in action.
+
+***************************************************************/
+
+
+#include "mbed.h"
+#include "ILI9340_Driver.h"
+
+
+int main() {
+
+    // create the display object
+    ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26);
+
+    // initialise the display
+    tft.DispInit();
+    
+    // clears the screen to remove all noise data
+    tft.FillScreen(ILI9340_WHITE);
+        
+
+
+    // set up variables for graphics functions
+    uint16_t c1, c2, c3, c4, c5, c6;
+    uint8_t r = 0, g = 0, b = 0;
+    char elapsed[] = "1111";
+    int counter = 0;
+
+    // variables for the 'waiting..' squares
+    int red[] = {0,30,60,90,120};
+    int green[] = {0,30,60,90,120};
+    int blue[] = {0,30,60,90,120};
+    
+    
+    while(true) {    
+        // draws a black window
+        tft.DrawRect(20, 20, 200, 280, ILI9340_BLACK);
+    
+        // Small amount of text to the display.
+        tft.DrawString("Hello ILI9340 Lib!", 50, 120, 1, ILI9340_BLACK);
+        tft.DrawString("Frame Count:", 70, 135, 1, ILI9340_BLACK);
+        tft.DrawString("Go Create!", 45, 210, 2, ILI9340_BLUE);
+    
+        // convert the RGB values into values that can be writen to the screen
+        c1 = tft.Colour565(r, g, b);
+        c2 = tft.Colour565(red[0], green[0], blue[0]);
+        c3 = tft.Colour565(red[1], green[1], blue[1]);
+        c4 = tft.Colour565(red[2], green[2], blue[2]);
+        c5 = tft.Colour565(red[3], green[3], blue[3]);
+        c6 = tft.Colour565(red[4], green[4], blue[4]);
+        
+        // Print a 'waiting..' animation to the screen.
+        tft.FillRect( 30, 60, 20, 20, c6);
+        tft.FillRect( 70, 60, 20, 20, c5);
+        tft.FillRect( 110, 60, 20, 20, c4);
+        tft.FillRect( 150, 60, 20, 20, c3);
+        tft.FillRect( 190, 60, 20, 20, c2);
+        
+        // change the RGB vlaues for circle effect
+        r += 4; g += 6; b += 8; 
+        
+        // change RGB values for the 'waiting' animation effect
+        for (int i = 0; i < 5; i++) {
+            red[i]   += 5;
+            green[i] += 5;
+            blue[i]  += 5;
+            }
+        
+               
+        //Write the frame count to screen, first overwriting the previos value in the background colour
+        tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_WHITE);
+        if (counter++ > 9999) {counter = 0;}
+        tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_RED);
+        
+        // Draw the circle ripples to the screen
+        tft.DrawCircle(120, 265, r, c1);
+        
+        
+        // Do the waiting thang...
+        wait(0.025);
+
+    }
+
+}
+
diff -r 0615e3c659c0 -r 7800c62c22d1 ILI9340_Driver.cpp
--- a/ILI9340_Driver.cpp	Mon May 26 18:32:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,547 +0,0 @@
-/***************************************************************
-    ILI9340_Driver  v1.0    26.05.14    Ian Weston
-    
-Driver and integrated graphics library for displays that use the 
-ILI9340 controller in SPI mode.
-
-The code was prted from several sources, the driver section
-was completely ported from the Adafruits Arduino source code, and
-the graphics functions were ported from the Adafruits GFX library
-and some elements were ported from code by Elmicros seeduio port.
-
-Future revisions will include more advanced graphics functions.
-
-***************************************************************/
-
-
-#include "mbed.h"
-#include "ILI9340_Driver.h"
-#include "SimpleFont.cpp"
-
-
-// Constructor, assigns the pins to the SPI object, set orientation, and sets screen dims.
-ILI9340_Display::ILI9340_Display(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dc)
-    : spi(mosi, miso, sclk), cs(cs), rst(rst), dc(dc) {
-    _height = _TFTHEIGHT;
-    _width = _TFTWIDTH;
-    orientation = 0;
-    }
-
-
-// Command writing code
-void ILI9340_Display::WriteCommand(uint8_t command) {
-    dc = 0;
-    cs = 0;
-    spi.write(command);
-    cs = 1;
-    }
-  
-    
-// Data writing code
-void ILI9340_Display::WriteData(uint8_t data) {
-    cs = 0;
-    dc = 1;
-    spi.write(data);
-    cs = 1;    
-    }
-    
-    
-// Initilise the display
-void ILI9340_Display::DispInit(void) {
-    //CtrlOutput();
-    
-    rst = 0;
-    
-    // Setup the spi for 8 bit data, high steady state clock,
-    // second edge capture, with a 1MHz clock rate
-    //spi.format(8,3);
-    spi.frequency(24000000); // actually seems to work up to about 20Mhz... way better than the 8mhz as std.
-    
-    // Toggle rst to reset
-    rst = 1;
-    wait(0.005);
-    rst = 0;
-    wait(0.020);
-    rst = 1;
-    wait(0.150);
-    
-    WriteCommand(0xEF);
-    WriteData(0x03);
-    WriteData(0x80);
-    WriteData(0x02);
-
-    WriteCommand(0xCF);  
-    WriteData(0x00); 
-    WriteData(0xC1); 
-    WriteData(0x30); 
-
-    WriteCommand(0xED);  
-    WriteData(0x64); 
-    WriteData(0x03); 
-    WriteData(0x12); 
-    WriteData(0x81); 
- 
-    WriteCommand(0xE8);  
-    WriteData(0x85); 
-    WriteData(0x00); 
-    WriteData(0x78); 
-
-    WriteCommand(0xCB);  
-    WriteData(0x39); 
-    WriteData(0x2C); 
-    WriteData(0x00); 
-    WriteData(0x34); 
-    WriteData(0x02); 
- 
-    WriteCommand(0xF7);  
-    WriteData(0x20); 
-
-    WriteCommand(0xEA);  
-    WriteData(0x00); 
-    WriteData(0x00); 
- 
-    WriteCommand(ILI9340_PWCTR1);    //Power control 
-    WriteData(0x23);   //VRH[5:0] 
- 
-    WriteCommand(ILI9340_PWCTR2);    //Power control 
-    WriteData(0x10);   //SAP[2:0];BT[3:0] 
- 
-    WriteCommand(ILI9340_VMCTR1);    //VCM control 
-    WriteData(0x3e); //�Աȶȵ���
-    WriteData(0x28); 
-  
-    WriteCommand(ILI9340_VMCTR2);    //VCM control2 
-    WriteData(0x86);  //--
- 
-    WriteCommand(ILI9340_MADCTL);    // Memory Access Control 
-    WriteData(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
-
-    WriteCommand(ILI9340_PIXFMT);    
-    WriteData(0x55); 
-  
-    WriteCommand(ILI9340_FRMCTR1);    
-    WriteData(0x00);  
-    WriteData(0x18); 
- 
-    WriteCommand(ILI9340_DFUNCTR);    // Display Function Control 
-    WriteData(0x08); 
-    WriteData(0x82);
-    WriteData(0x27);  
- 
-    WriteCommand(0xF2);    // 3Gamma Function Disable 
-    WriteData(0x00); 
- 
-    WriteCommand(ILI9340_GAMMASET);    //Gamma curve selected 
-    WriteData(0x01); 
- 
-    WriteCommand(ILI9340_GMCTRP1);    //Set Gamma 
-    WriteData(0x0F); 
-    WriteData(0x31); 
-    WriteData(0x2B); 
-    WriteData(0x0C); 
-    WriteData(0x0E); 
-    WriteData(0x08); 
-    WriteData(0x4E); 
-    WriteData(0xF1); 
-    WriteData(0x37); 
-    WriteData(0x07); 
-    WriteData(0x10); 
-    WriteData(0x03); 
-    WriteData(0x0E); 
-    WriteData(0x09); 
-    WriteData(0x00); 
-  
-    WriteCommand(ILI9340_GMCTRN1);    //Set Gamma 
-    WriteData(0x00); 
-    WriteData(0x0E); 
-    WriteData(0x14); 
-    WriteData(0x03); 
-    WriteData(0x11); 
-    WriteData(0x07); 
-    WriteData(0x31); 
-    WriteData(0xC1); 
-    WriteData(0x48); 
-    WriteData(0x08); 
-    WriteData(0x0F); 
-    WriteData(0x0C); 
-    WriteData(0x31); 
-    WriteData(0x36); 
-    WriteData(0x0F); 
-
-    WriteCommand(ILI9340_SLPOUT);    //Exit Sleep 
-    wait(0.120);       
-    WriteCommand(ILI9340_DISPON);    //Display on 
-    
-    }
-    
-
-// Sets the rotation of the display
-void ILI9340_Display::SetRotation(uint8_t m) {
-
-  WriteCommand(ILI9340_MADCTL);
-  orientation = m % 4; // can't be higher than 3
-  
-  switch (orientation) {
-   case 0:
-     WriteData(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
-     _width  = _TFTWIDTH;
-     _height = _TFTHEIGHT;
-     break;
-   case 1:
-     WriteData(ILI9340_MADCTL_MV | ILI9340_MADCTL_BGR);
-     _width  = _TFTHEIGHT;
-     _height = _TFTWIDTH;
-     break;
-  case 2:
-    WriteData(ILI9340_MADCTL_MY | ILI9340_MADCTL_BGR);
-     _width  = _TFTWIDTH;
-     _height = _TFTHEIGHT;
-    break;
-   case 3:
-     WriteData(ILI9340_MADCTL_MV | ILI9340_MADCTL_MY | ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
-     _width  = _TFTHEIGHT;
-     _height = _TFTWIDTH;
-     break;
-  }
-}
-
-
-// Invert the colours of the display in hardware
-void ILI9340_Display::InvertDisplay(bool i) {
-  WriteCommand(i ? ILI9340_INVON : ILI9340_INVOFF);
-}
-
-
-    
-// Set address window for writing data to.
-void ILI9340_Display::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
-
-  WriteCommand(ILI9340_CASET); // Column addr set
-  WriteData(x0 >> 8);
-  WriteData(x0 & 0xFF);     // XSTART 
-  WriteData(x1 >> 8);
-  WriteData(x1 & 0xFF);     // XEND
-
-  WriteCommand(ILI9340_PASET); // Row addr set
-  WriteData(y0>>8);
-  WriteData(y0);     // YSTART
-  WriteData(y1>>8);
-  WriteData(y1);     // YEND
-
-  WriteCommand(ILI9340_RAMWR); // write to RAM
-}
-
-
-
-// To draw the humble pixel
-void ILI9340_Display::DrawPixel(uint16_t x, uint16_t y, uint16_t colour) {
-    if((x < 1) ||(x >= _width) || (y < 1) || (y >= _height)) return;
-   
-    SetAddrWindow(x,y,x+1,y+1);
-    
-    dc = 1;
-    cs = 0;
-    
-    spi.write(colour >> 8);
-    spi.write(colour);
-    
-    cs = 1;
-    }
-    
-
-// Fill the screen with a colour
-void ILI9340_Display::FillScreen(uint16_t colour) {
-    SetAddrWindow(0,0,_width,_height);
-    
-    dc = 1;
-    cs = 0;
-    
-    unsigned int total = _width * _height;
-    unsigned int position = 0;
-    
-    while (position < total) {
-        spi.write(colour >> 8);
-        spi.write(colour);
-        position++;
-        }
-    cs = 1;
-    }
-    
-
-// Draws a vertical line fast
-void ILI9340_Display::DrawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t colour) {
-
-  // Rudimentary clipping
-  if((x >= _width) || (y >= _height)) return;
-
-  if((y+h-1) >= _height) 
-    h = _height-y;
-
-  SetAddrWindow(x, y, x, y+h-1);
-
-  uint8_t hi = colour >> 8, lo = colour;
-
-  dc = 1;
-  cs = 0;
-
-  while (h--) {
-    spi.write(hi);
-    spi.write(lo);
-  }
-  cs = 1;
-}
-
-
-// Draws a horizontal line fast
-void ILI9340_Display::DrawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t colour) {
-
-  // Rudimentary clipping
-  if((x >= _width) || (y >= _height)) return;
-  if((x+w-1) >= _height)  w = _width-x;
-  SetAddrWindow(x, y, x+w-1, y);
-
-  uint8_t hi = colour >> 8, lo = colour;
-  dc = 1;
-  cs = 0;
-  while (w--) {
-    spi.write(hi);
-    spi.write(lo);
-  }
-  cs = 1;
-}
-
-
-// Draws a filled rectangle 
-void ILI9340_Display::FillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t colour) {
-
-  // rudimentary clipping (drawChar w/big text requires this)
-  if((x >= _width) || (y >= _height)) return;
-  if((x + w - 1) >= _width)  w = _width  - x;
-  if((y + h - 1) >= _height) h = _height - y;
-
-  SetAddrWindow(x, y, x+w-1, y+h-1);
-
-  uint8_t hi = colour >> 8, lo = colour;
-
-  dc = 1;
-  cs = 0;
-
-  for(y=h; y>0; y--) {
-    for(x=w; x>0; x--) {
-      spi.write(hi);
-      spi.write(lo);
-    }
-  }
-  cs = 1;
-}
-
-
-
-// Draw an unfilled rectangle
-void ILI9340_Display::DrawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){
-    DrawFastHLine(x, y, w, color);
-    DrawFastHLine(x, y+h-1, w, color);
-    DrawFastVLine(x, y, h, color);
-    DrawFastVLine(x+w-1, y, h, color);
-}
-
-
-// draw an unfilled circle
-void ILI9340_Display::DrawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t colour){
-    int16_t f = 1 - r;
-    int16_t ddF_x = 1;
-    int16_t ddF_y = -2 * r;
-    int16_t x = 0;
-    int16_t y = r;
- 
-    DrawPixel(x0  , y0+r, colour);
-    DrawPixel(x0  , y0-r, colour);
-    DrawPixel(x0+r, y0  , colour);
-    DrawPixel(x0-r, y0  , colour);
- 
-    while (x<y) {
-        if (f >= 0) {
-            y--;
-            ddF_y += 2;
-            f += ddF_y;
-        }
-        x++;
-        ddF_x += 2;
-        f += ddF_x;
- 
-        DrawPixel(x0 + x, y0 + y, colour);
-        DrawPixel(x0 - x, y0 + y, colour);
-        DrawPixel(x0 + x, y0 - y, colour);
-        DrawPixel(x0 - x, y0 - y, colour);
-        DrawPixel(x0 + y, y0 + x, colour);
-        DrawPixel(x0 - y, y0 + x, colour);
-        DrawPixel(x0 + y, y0 - x, colour);
-        DrawPixel(x0 - y, y0 - x, colour);
-    }
-}
-
-
-// Pass 8-bit (each) R,G,B, get back 16-bit packed color
-uint16_t ILI9340_Display::Colour565(uint8_t r, uint8_t g, uint8_t b) {
-  return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
-}
-
-
-// Writes an ascii character to the display
-void ILI9340_Display::DrawAscii(unsigned char ascii, uint16_t x, uint16_t y, uint16_t size, uint16_t colour) {
-    SetAddrWindow(x, y, x+size, y+size);
-    
-    if( (ascii < 0x20) || (ascii > 0x7e) )      //check for valid ASCII char
-    {
-        ascii = '?';                            //char not supported
-    }
-    for(unsigned char i=0; i<8; i++)
-    {
-        unsigned char temp = simpleFont[ascii - 0x20][i];
-        for(unsigned char f=0; f<8; f++)
-        {
-            if( (temp>>f) & 0x01 )
-            {
-                switch(orientation)
-                {                
-                case '0':
-                    FillRect(x+f*size, y-i*size, size, size, colour);
-                    break;
-                case '1':
-                     FillRect(x-i*size, x-f*size, size, size, colour);
-                     break;
-                case '2':
-                     FillRect(x-f*size, y+i*size, size, size, colour);
-                     break;
-                case '3':
-                default:
-                       FillRect(x+i*size, y+f*size, size, size, colour);
-                }
-            }    
-        }
-    }
-}
-
-
-// Writes a character array to the display
-void ILI9340_Display::DrawString(char *string, uint16_t x, uint16_t y, uint8_t size, uint16_t colour)
-{
-    while(*string)
-    {
-        DrawAscii(*string, x, y, size, colour);
-        *string++;
-        switch(orientation)
-        {        
-        case '0':          
-            if(y > 0) y-=8*size;              //Change position to next char 
-              break;
-        case '1':        
-            if(x > 0) x-=8*size;                       
-            break;
-        case '2':          
-            if(y < _height) y+=8*size;   
-            break;
-        case '3':
-        default:        
-              if(x < _width) x+=8*size; 
-        }          
-    }
-}
-
-// Converts integers into a character array
-void ILI9340_Display::IntToChars (char* buffer, int value, uint8_t spaceonbuffer, uint8_t countbase, uint16_t x, uint16_t y, uint8_t size, uint16_t colour) {
-    int workvalue = value;
-    int i;
-    int valuetowrite;
-    int  end_i = 0;
-
-    if (value < 0)
-    {
-        workvalue = -value;
-        end_i = 1;
-        buffer[0] = '-';
-    }
-
-    for (i = spaceonbuffer - 1; i >= end_i; i--)
-    {
-        valuetowrite = (workvalue % countbase);
-        if (workvalue == 0)
-        {
-            if (i == (spaceonbuffer - 1))
-            {
-                buffer[i] = 48;                        // ASCII 0
-            } else {
-                buffer[i] = 32;                        // ASCII SPACE
-            }
-        } else {
-            if (valuetowrite > 9)
-            {
-                buffer[i] = valuetowrite + 55;        // ASCII A-Z
-            } else {
-                buffer[i] = valuetowrite + 48;        // ASCII of that character
-            }
-        };
-        workvalue = (workvalue - valuetowrite) / countbase;
-    }
-    
-    DrawString(buffer, x, y, size, colour);
-}
-
-
-
-// Functional code to swap data contents of 16bit registers
-void ILI9340_Display::Swap(int16_t *a, int16_t *b) {
-    
-    int16_t x = *a;
-    *a = *b;
-    *b = x;    
-    }
-
-
-// Draws a line with any length and orientation
-void ILI9340_Display::DrawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour){
-    int16_t steep = abs(y1 - y0) > abs(x1 - x0);
-    if (steep) {
-        Swap(&x0, &y0);
-        Swap(&x1, &y1);
-    }
- 
-    if (x0 > x1) {
-        Swap(&x0, &x1);
-        Swap(&y0, &y1);
-    }
- 
-    int16_t dx, dy;
-    dx = x1 - x0;
-    dy = abs(y1 - y0);
- 
-    int16_t err = dx / 2;
-    int16_t ystep;
- 
-    if (y0 < y1) {
-        ystep = 1;
-    } else {
-        ystep = -1;
-    }
- 
-    for (; x0<=x1; x0++) {
-        if (steep) {
-            DrawPixel(y0, x0, colour);
-        } else {
-            DrawPixel(x0, y0, colour);
-        }
-        err -= dy;
-        if (err < 0) {
-            y0 += ystep;
-            err += dx;
-        }
-    }
-}
-
-
-
-
-
-
-
-
diff -r 0615e3c659c0 -r 7800c62c22d1 ILI9340_Driver.h
--- a/ILI9340_Driver.h	Mon May 26 18:32:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/***************************************************************
-    ILI9340_Driver  v1.0    26.05.14    Ian Weston
-    
-Driver and integrated graphics library for displays that use the 
-ILI9340 controller in SPI mode.
-
-The code was prted from several sources, the driver section
-was completely ported from the Adafruits Arduino source code, and
-the graphics functions were ported from the Adafruits GFX library
-and some elements were ported from code by Elmicros seeduio port.
-
-Future revisions will include more advanced graphics functions.
-
-***************************************************************/
-
-
-
-#include "mbed.h"
-
-#ifndef ILI9340_DRIVER_h
-#define ILI9340_DRIVER_h
-
-
-#define _TFTWIDTH  240
-#define _TFTHEIGHT 320
-
-#define ILI9340_NOP     0x00
-#define ILI9340_SWRESET 0x01
-#define ILI9340_RDDID   0x04
-#define ILI9340_RDDST   0x09
-
-#define ILI9340_SLPIN   0x10
-#define ILI9340_SLPOUT  0x11
-#define ILI9340_PTLON   0x12
-#define ILI9340_NORON   0x13
-
-#define ILI9340_RDMODE  0x0A
-#define ILI9340_RDMADCTL  0x0B
-#define ILI9340_RDPIXFMT  0x0C
-#define ILI9340_RDIMGFMT  0x0A
-#define ILI9340_RDSELFDIAG  0x0F
-
-#define ILI9340_INVOFF  0x20
-#define ILI9340_INVON   0x21
-#define ILI9340_GAMMASET 0x26
-#define ILI9340_DISPOFF 0x28
-#define ILI9340_DISPON  0x29
-
-#define ILI9340_CASET   0x2A
-#define ILI9340_PASET   0x2B
-#define ILI9340_RAMWR   0x2C
-#define ILI9340_RAMRD   0x2E
-
-#define ILI9340_PTLAR   0x30
-#define ILI9340_MADCTL  0x36
-
-
-#define ILI9340_MADCTL_MY  0x80
-#define ILI9340_MADCTL_MX  0x40
-#define ILI9340_MADCTL_MV  0x20
-#define ILI9340_MADCTL_ML  0x10
-#define ILI9340_MADCTL_RGB 0x00
-#define ILI9340_MADCTL_BGR 0x08
-#define ILI9340_MADCTL_MH  0x04
-
-#define ILI9340_PIXFMT  0x3A
-
-#define ILI9340_FRMCTR1 0xB1
-#define ILI9340_FRMCTR2 0xB2
-#define ILI9340_FRMCTR3 0xB3
-#define ILI9340_INVCTR  0xB4
-#define ILI9340_DFUNCTR 0xB6
-
-#define ILI9340_PWCTR1  0xC0
-#define ILI9340_PWCTR2  0xC1
-#define ILI9340_PWCTR3  0xC2
-#define ILI9340_PWCTR4  0xC3
-#define ILI9340_PWCTR5  0xC4
-#define ILI9340_VMCTR1  0xC5
-#define ILI9340_VMCTR2  0xC7
-
-#define ILI9340_RDID1   0xDA
-#define ILI9340_RDID2   0xDB
-#define ILI9340_RDID3   0xDC
-#define ILI9340_RDID4   0xDD
-
-#define ILI9340_GMCTRP1 0xE0
-#define ILI9340_GMCTRN1 0xE1
-/*
-#define ILI9340_PWCTR6  0xFC
-
-*/
-
-// Color definitions
-#define ILI9340_BLACK   0x0000
-#define ILI9340_BLUE    0x001F
-#define ILI9340_RED     0xF800
-#define ILI9340_GREEN   0x07E0
-#define ILI9340_CYAN    0x07FF
-#define ILI9340_MAGENTA 0xF81F
-#define ILI9340_YELLOW  0xFFE0  
-#define ILI9340_WHITE   0xFFFF
-
-
-
-class ILI9340_Display {
-    
-    public:
-    
-    uint16_t _height;
-    uint16_t _width;
-    
-    ILI9340_Display(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName dc);
-    
-    void DispInit();
-    void WriteCommand(uint8_t);
-    void WriteData(uint8_t);
-    void SetRotation(uint8_t);
-    void InvertDisplay(bool);
-    void SetAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t);
-    
-    void DrawPixel(uint16_t, uint16_t, uint16_t);
-    void FillScreen(uint16_t);
-    void DrawFastVLine(int16_t, int16_t, int16_t, uint16_t);
-    void DrawFastHLine(int16_t, int16_t, int16_t, uint16_t);
-    void FillRect(int16_t, int16_t, int16_t, int16_t, uint16_t);
-    void DrawRect(int16_t, int16_t, int16_t, int16_t, uint16_t);
-    void DrawCircle(int16_t, int16_t, int16_t, uint16_t);
-    uint16_t Colour565(uint8_t, uint8_t, uint8_t);
-    
-    void DrawAscii(unsigned char, uint16_t, uint16_t, uint16_t, uint16_t);
-    void DrawString(char *string, uint16_t, uint16_t, uint8_t, uint16_t);
-    void IntToChars (char*, int, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t, uint16_t);
-    
-    void Swap(int16_t*, int16_t*);
-    void DrawLine(int16_t, int16_t, int16_t, int16_t, uint16_t);
-    
-    protected:
-    SPI spi; // mosi, miso, sclk
-    DigitalOut cs;
-    DigitalOut rst;
-    DigitalOut dc;
-    
-    uint8_t orientation;
-       
-    };
-
-
-
-
-
-#endif
\ No newline at end of file
diff -r 0615e3c659c0 -r 7800c62c22d1 ILI9340_Driver_Lib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ILI9340_Driver_Lib.lib	Sun Jun 01 17:02:58 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dextorslabs/code/ILI9340_Driver_Lib/#216d35e347b8
diff -r 0615e3c659c0 -r 7800c62c22d1 SimpleFont.cpp
--- a/SimpleFont.cpp	Mon May 26 18:32:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
-  ST7781R TFT Library. 
-
-  2011 Copyright (c) Seeed Technology Inc.
-
-*/
-
-
-//#include <avr/pgmspace.h>
-
-const unsigned char simpleFont[][8] =
-{
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
-  {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
-  {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
-  {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
-  {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
-  {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
-  {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
-  {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
-  {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
-  {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
-  {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
-  {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
-  {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
-  {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
-  {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
-  {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
-  {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
-  {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
-  {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
-  {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
-  {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
-  {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
-  {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
-  {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
-  {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
-  {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
-  {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
-  {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
-  {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
-  {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
-  {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
-  {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
-  {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
-  {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
-  {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
-  {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
-  {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
-  {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
-  {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
-  {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
-  {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
-  {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
-  {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
-  {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
-  {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
-  {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
-  {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
-  {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
-  {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
-  {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
-  {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
-  {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
-  {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
-  {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
-  {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
-  {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
-  {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
-  {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
-  {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
-  {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
-  {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
-  {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
-  {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
-  {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
-  {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
-  {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
-  {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
-  {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
-  {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
-  {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
-  {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
-  {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
-  {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
-  {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
-  {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
-  {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
-  {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
-  {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
-  {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
-  {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
-  {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
-  {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
-  {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
-  {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
-  {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
-  {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
-  {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
-  {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
-  {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
-  {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
-  {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} 
-};
diff -r 0615e3c659c0 -r 7800c62c22d1 main.cpp
--- a/main.cpp	Mon May 26 18:32:43 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/***************************************************************
-    ILI9340_Driver  v1.0    26.05.14    Ian Weston
-    
-Driver and integrated graphics library for displays that use the 
-ILI9340 controller in SPI mode.
-
-The code was prted from several sources, the driver section
-was completely ported from the Adafruits Arduino source code, and
-the graphics functions were ported from the Adafruits GFX library
-and some elements were ported from code by Elmicros seeduio port.
-
-Future revisions will include more advanced graphics functions.
-
-Rough and ready Demo code to for showing the driver and some 
-functions in action.
-
-***************************************************************/
-
-
-#include "mbed.h"
-#include "ILI9340_Driver.h"
-
-
-int main() {
-
-    // create the display object
-    ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26);
-
-    // initialise the display
-    tft.DispInit();
-    
-    // clears the screen to remove all noise data
-    tft.FillScreen(ILI9340_WHITE);
-        
-
-
-    // set up variables for graphics functions
-    uint16_t c1, c2, c3, c4, c5, c6;
-    uint8_t r = 0, g = 0, b = 0;
-    char elapsed[] = "1111";
-    int counter = 0;
-
-    // variables for the 'waiting..' squares
-    int red[] = {0,30,60,90,120};
-    int green[] = {0,30,60,90,120};
-    int blue[] = {0,30,60,90,120};
-    
-    
-    while(true) {    
-        // draws a black window
-        tft.DrawRect(20, 20, 200, 280, ILI9340_BLACK);
-    
-        // Small amount of text to the display.
-        tft.DrawString("Hello ILI9340 Lib!", 50, 120, 1, ILI9340_BLACK);
-        tft.DrawString("Frame Count:", 70, 135, 1, ILI9340_BLACK);
-        tft.DrawString("Go Create!", 45, 210, 2, ILI9340_BLUE);
-    
-        // convert the RGB values into values that can be writen to the screen
-        c1 = tft.Colour565(r, g, b);
-        c2 = tft.Colour565(red[0], green[0], blue[0]);
-        c3 = tft.Colour565(red[1], green[1], blue[1]);
-        c4 = tft.Colour565(red[2], green[2], blue[2]);
-        c5 = tft.Colour565(red[3], green[3], blue[3]);
-        c6 = tft.Colour565(red[4], green[4], blue[4]);
-        
-        // Print a 'waiting..' animation to the screen.
-        tft.FillRect( 30, 60, 20, 20, c6);
-        tft.FillRect( 70, 60, 20, 20, c5);
-        tft.FillRect( 110, 60, 20, 20, c4);
-        tft.FillRect( 150, 60, 20, 20, c3);
-        tft.FillRect( 190, 60, 20, 20, c2);
-        
-        // change the RGB vlaues for circle effect
-        r += 4; g += 6; b += 8; 
-        
-        // change RGB values for the 'waiting' animation effect
-        for (int i = 0; i < 5; i++) {
-            red[i]   += 5;
-            green[i] += 5;
-            blue[i]  += 5;
-            }
-        
-               
-        //Write the frame count to screen, first overwriting the previos value in the background colour
-        tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_WHITE);
-        if (counter++ > 9999) {counter = 0;}
-        tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_RED);
-        
-        // Make a mess of the screen by drawing random lines and, a ripple of circles.
-        tft.DrawCircle(120, 265, r, c1);
-        
-        // Do the waiting thang...
-        wait(0.025);
-
-    }
-
-}
-