LPC1768 Mini-DK board with 2.8" SPI TFT and SPI touch

Dependencies:   Mini-DK mbed SDFileSystem

WARNING: filetoflash (SD to CPU flash)

The SPI_TFT library called from Mini-DK.lib contains an option to copy an image from the SD card to the CPU flash memory. This allows you to use an image as background without speed loss when writing other text and graphics.

By default, this option is enabled.

It can be disabled by uncommenting the #define mentioned below in Mini_DK.h:

#define NO_FLASH_BUFFER

Since the flash memory has limited write endurance, DO NOT use this feature when you intend to read multiple images from the SD card (eg: when used as a photo frame).

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Thu Jan 03 21:24:05 2013 +0000
Parent:
5:781a72d380a1
Child:
7:ffdd4e75b366
Commit message:
Faster writing to LCD;

Changed in this revision

Mini-DK/SPI_TFT/BurstSPI.lib Show annotated file Show diff for this revision Revisions of this file
Mini-DK/SPI_TFT/SPI_TFT.cpp Show annotated file Show diff for this revision Revisions of this file
Mini-DK/SPI_TFT/SPI_TFT.h Show annotated file Show diff for this revision Revisions of this file
Mini-DK/SPI_TFT/TextDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
modifs.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mini-DK/SPI_TFT/BurstSPI.lib	Thu Jan 03 21:24:05 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/BurstSPI/#5ef4a019e0db
--- a/Mini-DK/SPI_TFT/SPI_TFT.cpp	Thu Jan 03 20:04:38 2013 +0000
+++ b/Mini-DK/SPI_TFT/SPI_TFT.cpp	Thu Jan 03 21:24:05 2013 +0000
@@ -290,10 +290,14 @@
      _cs = 0;
      wr_dat_start();
      _spi.format(16,3);
-     for( index = 0; index<width()*height(); index++ )
+     int num = width()*height();
+     
+     for( index = 0; index<num; index++ )
      {
-        _spi.write(_background);
+        _spi.fastWrite(_background);
      }
+     _spi.clearRX();
+     
      _spi.format(8,3);
     _cs = 1;
 }
@@ -308,11 +312,15 @@
     wr_cmd(0x22);
     _cs = 0;
     wr_dat_start();
+    
     _spi.format(16,3);
-    for( index = 0; index < (x1 - x0); index++ )
-    {
-        _spi.write(color);
-    }
+    int num = x1-x0;
+    for( index = 0; index<num; index++ )
+     {
+        _spi.fastWrite(color);
+     }
+     _spi.clearRX();
+     
     _spi.format(8,3);
     _cs = 1;
     return;
@@ -329,10 +337,12 @@
      _cs = 0;
      wr_dat_start();
     _spi.format(16,3);
-    for( index = 0; index < (y1 - y0); index++ )
-    {
-        _spi.write(color);
-    }
+    int num = y1-y0;
+    for( index = 0; index<num; index++ )
+     {
+        _spi.fastWrite(color);
+     }
+     _spi.clearRX();
     _spi.format(8,3);
     _cs = 1;
     return;
@@ -440,10 +450,12 @@
     _cs = 0;
     wr_dat_start();
     _spi.format(16,3);
-    for( index = 0; index < h * w; index++ )
-    {
-        _spi.write(color);
-    }
+    int num = h*w;
+    for( index = 0; index<num; index++ )
+     {
+        _spi.fastWrite(color);
+     }
+     _spi.clearRX();
     _spi.format(8,3);
     _cs = 1;
     return;
@@ -640,14 +652,15 @@
             b = 1 << (j & 0x07);
             if (( z & b ) == 0x00)
             {
-                _spi.write(_background);
+                _spi.fastWrite(_background);
             }
             else
             {
-                _spi.write(_foreground);
+                _spi.fastWrite(_foreground);
             }
         }
     }
+    _spi.clearRX();
     _spi.format(8,3);
     _cs = 1;
     if ((w + 2) < hor)                   // x offset to next char
@@ -678,11 +691,12 @@
     {
         for (i = 0; i < w; i++)         // copy pixel data to TFT
         {
-            _spi.write(*bitmap_ptr);    // one line
+            _spi.fastWrite(*bitmap_ptr);    // one line
             bitmap_ptr++;
         }
         bitmap_ptr -= 2*w;
     }
+    _spi.clearRX();
     _spi.format(8,3);
     _cs = 1;
 }
--- a/Mini-DK/SPI_TFT/SPI_TFT.h	Thu Jan 03 20:04:38 2013 +0000
+++ b/Mini-DK/SPI_TFT/SPI_TFT.h	Thu Jan 03 21:24:05 2013 +0000
@@ -5,8 +5,10 @@
 
 
 #include "GraphicsDisplay.h"
+#include "BurstSPI.h"
 #include "mbed.h"
 
+
 #define incx() x++, dxt += d2xt, t += dxt
 #define incy() y--, dyt += d2yt, t += dyt
 
@@ -242,7 +244,7 @@
    */
   void set_orientation(unsigned int o);
   void mod_orientation(void);
-  SPI _spi;
+  BurstSPI _spi;
   DigitalOut _cs;
   unsigned char* font;
 
--- a/Mini-DK/SPI_TFT/TextDisplay.cpp	Thu Jan 03 20:04:38 2013 +0000
+++ b/Mini-DK/SPI_TFT/TextDisplay.cpp	Thu Jan 03 21:24:05 2013 +0000
@@ -5,7 +5,7 @@
  
 #include "TextDisplay.h"
 
-TextDisplay::TextDisplay(const char *name) : Stream(name){
+TextDisplay::TextDisplay(const char *name) : Stream(){
     _row = 0;
     _column = 0;
     if (name == NULL) {
--- a/main.cpp	Thu Jan 03 20:04:38 2013 +0000
+++ b/main.cpp	Thu Jan 03 21:24:05 2013 +0000
@@ -27,16 +27,16 @@
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.set_orientation(0);
     TFT.locate(0,0);
-    printf("  Hello Mbed 0");
+    TFT.printf("  Hello Mbed 0");
     TFT.set_orientation(1);
     TFT.locate(0,0);
-    printf("  Hello Mbed 1");
+    TFT.printf("  Hello Mbed 1");
     TFT.set_orientation(2);
     TFT.locate(0,0);
-    printf("  Hello Mbed 2");
+    TFT.printf("  Hello Mbed 2");
     TFT.set_orientation(3);
     TFT.locate(0,0);
-    printf("  Hello Mbed 3");
+    TFT.printf("  Hello Mbed 3");
     TFT.set_orientation(1);
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(50,100);
@@ -106,7 +106,7 @@
     TFT.locate(10,10);
     TFT.printf("RGB color wheel (2x)");
 
-    uint8_t r = 255, g = 0,  b = 0, step = 5, i;
+    uint8_t r = 255, g = 0,  b = 0, step = 1, i;
     for (i=0;i<2;i++)
     {
         for(;g<255;g+=step) {TFT.fillrect(70,110,100,100,RGB565CONVERT(r, g, b));}      // Cycle from FF0000 to FFFF00 : red to yellow
--- a/mbed.bld	Thu Jan 03 20:04:38 2013 +0000
+++ b/mbed.bld	Thu Jan 03 21:24:05 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
+http://mbed.org/users/mbed_official/code/mbed/builds/63cdd78b2dc1
\ No newline at end of file
--- a/modifs.h	Thu Jan 03 20:04:38 2013 +0000
+++ b/modifs.h	Thu Jan 03 21:24:05 2013 +0000
@@ -62,6 +62,18 @@
       ------------
       Added SD card pins
       Added two macros to enable/disable the LCD MISO pin, allowing use of both SD card and LCD
+      
+      
+      In SPI_TFT
+      ----------
+      Changed the SPI object to a BurstSPI object
+      All cases where large numbers of bytes were writting (filled rect, cls, etc) have been replaced by fastWrite functions for higher speed
+      mbed library updated to this century
+      Removed stream name from TextDisplay (not used in current mbed version)
+      Colorwheel stepsize reduced to 1 in main.cpp
+      
+      Known issue: claim function for stdout does not work
+      
 
 
 General notes