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:
frankvnk
Date:
Tue Jan 08 16:12:13 2013 +0000
Parent:
9:3e117b89c705
Child:
11:763038f9ba3e
Commit message:
TFT.printf replaced with printf (mbed Stream(name) is available again).
; 3 different code examples in main.cpp to demonstate the possibilities of the Mini-DK library.

Changed in this revision

Mini-DK.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib 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 diff for this revision Revisions of this file
--- a/Mini-DK.lib	Fri Jan 04 14:08:03 2013 +0000
+++ b/Mini-DK.lib	Tue Jan 08 16:12:13 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/frankvnk/code/Mini-DK/#9517c10e40d2
+http://mbed.org/users/frankvnk/code/Mini-DK/#9399be4feea0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Jan 08 16:12:13 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- a/main.cpp	Fri Jan 04 14:08:03 2013 +0000
+++ b/main.cpp	Tue Jan 08 16:12:13 2013 +0000
@@ -1,7 +1,29 @@
+/*
+This file contains 3 examples:
+
+ONE   : Original example with paint demo.
+TWO   : Example for displaying a bitmap read from SD card.
+        Download the house.bmp bitmap file from http://mbed.org/media/uploads/frankvnk/house.bmp
+        Copy this file to the root of an SD card, insert it into the Mini-DK.
+THREE : Example for copying a bitmap from SD to flash memory, use it as background and
+        write text without disrupting the background image.
+        Download the house.bmp bitmap file from http://mbed.org/media/uploads/frankvnk/house.bmp
+        Copy this file to the root of an SD card, insert it into the Mini-DK.
+
+IMPORTANT:
+Enable #define USE_FLASH_BUFFER in SPI_TFT.h to allow copy to flash.
+If copy to flash option is not needed - disable it.
+
+UNCOMMENT THE DESIRED CODE TO TEST.
+
+*/
+
+// =========================================================================================================
+// ================================================== ONE ==================================================
+// =========================================================================================================
 #include "stdio.h"
 #include "mbed.h"
 #include "Mini_DK.h"
-//#include "string"
 
 extern unsigned char p1[];  // the mbed logo
 #define RGB565CONVERT(red, green, blue) (uint16_t)( (( red   >> 3 ) << 11 ) | (( green >> 2 ) << 5  ) | ( blue  >> 3 ))
@@ -27,20 +49,20 @@
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.set_orientation(0);
     TFT.locate(0,0);
-    TFT.printf("  Hello Mbed 0");
+    printf("  Hello Mbed 0");
     TFT.set_orientation(1);
     TFT.locate(0,0);
-    TFT.printf("  Hello Mbed 1");
+    printf("  Hello Mbed 1");
     TFT.set_orientation(2);
     TFT.locate(0,0);
-    TFT.printf("  Hello Mbed 2");
+    printf("  Hello Mbed 2");
     TFT.set_orientation(3);
     TFT.locate(0,0);
-    TFT.printf("  Hello Mbed 3");
+    printf("  Hello Mbed 3");
     TFT.set_orientation(1);
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(50,100);
-    TFT.printf("TFT orientation");
+    printf("TFT orientation");
 
     wait(2);
 
@@ -49,7 +71,7 @@
     TFT.set_orientation(1);
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(120,115);
-    TFT.printf("Graphic");
+    printf("Graphic");
     TFT.line(0,0,100,200,Green);
     TFT.rect(100,50,50,50,Red);
     TFT.fillrect(180,25,40,45,Blue);
@@ -68,22 +90,22 @@
     TFT.cls();
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(0,0);
-    TFT.printf("Different Fonts :");
+    printf("Different Fonts :");
 
     TFT.set_font((unsigned char*) Neu42x35);
     TFT.locate(0,50);
-    TFT.printf("Hello");
+    printf("Hello");
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(50,100);
-    TFT.printf("Hello");
+    printf("Hello");
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.locate(55,150);
-    TFT.printf("Hello");
+    printf("Hello");
 
     TFT.set_orientation(2);
     TFT.set_font((unsigned char*) Arial24x23);
     TFT.locate(10,10);
-    TFT.printf("Hi mbed");
+    printf("Hi mbed");
     wait(2);
 
     // mbed logo
@@ -96,7 +118,7 @@
     TFT.set_orientation(0);
     LCD_id = TFT.Read_ID();
     TFT.locate(10,10);
-    TFT.printf("LCD: ILI%04X", LCD_id);
+    printf("LCD: ILI%04X", LCD_id);
     wait(2);
 
     // RGB color wheel demo (cycle through all colors)
@@ -104,7 +126,7 @@
     TFT.foreground(Yellow);    // set chars to yellow
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.locate(10,10);
-    TFT.printf("RGB color wheel (2x)");
+    printf("RGB color wheel (2x)");
 
     uint8_t r = 255, g = 0,  b = 0, step = 1, i;
     for (i=0;i<2;i++)
@@ -118,15 +140,14 @@
     }
     wait(2);
 
-
     // Touchpanel demo
     TP.TouchPanel_Calibrate();
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.set_orientation(0);
     TFT.locate(0,0);
-    TFT.printf(" X:");
+    printf(" X:");
     TFT.locate(70,0);
-    TFT.printf(" Y:");
+    printf(" Y:");
     while (1)
     {
         if (!TP._tp_irq)
@@ -136,20 +157,134 @@
                 TP.getDisplayPoint() ;
                 TP.TP_DrawPoint(TP.display.x,TP.display.y, Blue);
                 TFT.locate(25,0);
-                TFT.printf("%03d",TP.display.x);
+                printf("%03d",TP.display.x);
                 TFT.locate(95,0);
-                TFT.printf("%03d",TP.display.y);
+                printf("%03d",TP.display.y);
                 // Touchscreen area is larger than LCD area.
                 // We use the bottom area outside the LCD area to clear the screen (y value > 320).
                 if (TP.display.y > 320)
                 {
                     TFT.cls();
                     TFT.locate(0,0);
-                    TFT.printf(" X:");
+                    printf(" X:");
                     TFT.locate(70,0);
-                    TFT.printf(" Y:");
+                    printf(" Y:");
                 }
             }
         }
     }
 }
+
+/*
+// =========================================================================================================
+// ================================================== TWO ==================================================
+// =========================================================================================================
+
+#include "stdio.h"
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "Mini_DK.h"
+
+// SD card
+SDFileSystem sd(SD_SDI, SD_SDO, SD_SCK, SD_CS, "sd");
+// TFT -> mosi, miso, sclk, cs
+SPI_TFT TFT(LCD_SDI, LCD_SDO, LCD_SCK, LCD_CS,"TFT");
+// ADS7843 -> mosi, miso, sclk, cs, irq, SPI_TFT
+TouchScreenADS7843 TP(TP_SDI ,TP_SDO ,TP_SCK ,TP_CS ,TP_IRQ, &TFT);
+
+int main()
+{
+    TFT.background(Black);    // set background to black
+    TFT.foreground(White);    // set chars to white
+
+    TFT.claim(stdout);        // send stdout to the TFT display
+    TFT.cls();
+    TFT.set_font((unsigned char*) Arial12x12);
+    TFT.set_orientation(1);
+
+    DISABLE_LCD_MISO;
+    int dummy = TFT.Bitmap(0,0,"/sd/house.bmp");
+    ENABLE_LCD_MISO;
+    TFT.locate(0,0);
+    printf("%02d",dummy); 
+}
+*/
+
+/*
+// =========================================================================================================
+// ================================================= THREE =================================================
+// =========================================================================================================
+
+#include "stdio.h"
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "Mini_DK.h"
+ 
+// SD card
+SDFileSystem sd(SD_SDI, SD_SDO, SD_SCK, SD_CS, "sd");
+// TFT -> mosi, miso, sclk, cs
+SPI_TFT TFT(LCD_SDI, LCD_SDO, LCD_SCK, LCD_CS,"TFT");
+// ADS7843 -> mosi, miso, sclk, cs, irq, SPI_TFT
+TouchScreenADS7843 TP(TP_SDI ,TP_SDO ,TP_SCK ,TP_CS ,TP_IRQ, &TFT);
+
+
+Timer timer;
+ 
+int main()
+{
+    DISABLE_LCD_MISO;
+    TFT.background(Black);    // set background to black
+    TFT.foreground(White);    // set chars to white
+ 
+    TFT.claim(stdout);        // send stdout to the TFT display
+    TFT.cls();
+    TFT.set_font((unsigned char*) Arial12x12);
+    TFT.set_orientation(1);
+    
+    TFT.locate(0,200);
+    printf("Loading from SD...");
+    TFT.Bitmap(0,0,"/sd/house.bmp");
+    
+    TFT.locate(0,0);
+    printf("Copying to flash...");
+    TFT.fileToFlash("/sd/house.bmp");
+    TFT.locate(0,40);
+    printf("Done: CLS in 2 seconds");
+    wait(2);
+    TFT.backgroundImage(false);
+    TFT.cls();
+    wait(2);
+    TFT.backgroundImage(true);
+   
+    
+    timer.reset();
+    timer.start();
+    TFT.cls();
+    timer.stop();
+    TFT.foreground(Black);
+    TFT.locate(0,200);
+    printf("Wrote background in %d ms",timer.read_ms());
+    TFT.foreground(Black);
+
+    TFT.set_orientation(3);
+    TFT.locate(0,200);
+    printf("Wrote background in %d ms",timer.read_ms());
+
+    wait(5);
+    TFT.cls();
+    TFT.set_font((unsigned char*) Neu42x35);
+    TFT.locate(0,50);
+    printf("Orient = 3");
+    TFT.set_orientation(0);
+    TFT.locate(0,50);
+    printf("Orient = 0");
+    wait(5);
+
+    TFT.set_orientation(0);
+    TFT.cls();
+    TFT.locate(0,50);
+    printf("Orient = 0");
+    
+    while(1);
+}
+*/
\ No newline at end of file
--- a/mbed.bld	Fri Jan 04 14:08:03 2013 +0000
+++ b/mbed.bld	Tue Jan 08 16:12:13 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63cdd78b2dc1
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/71b101360fb9
\ No newline at end of file
--- a/modifs.h	Fri Jan 04 14:08:03 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
-Date    : 31.12.12
-Authors : Erik Olieman/Frank Vannieuwkerke
------------------------------------------
-      Code readability and speed
-        1. created separate structure for mini-DK (base for library)
-        2. Removed wr_dat_only routine (uses 8 bit transfer = slow) in SPI_TFT
-           Replaced each wr_dat_only with
-             _spi.format(16,3);
-             .....
-             _spi.write(...);
-             .....
-             _spi.format(8,3);
-        3. Creation of Mini-DK.h with all declarations specific to the mini-DK board.
-
-
-      Removed reset pin from SPI_TFT (not needed - pin is connected to main reset).
-
-      Separated SPI_TFT from TouchADS7843
-      
-      In main.cpp
-      ----------- 
-
-      TouchScreenADS7843 initialisation: pointer to SPI_TFT needed for calibration, drawcross and drawpoint routines.
-      
-      Moved following global touch var declarations from main.cpp back to touch.cpp/.h
-        Matrix      matrix;
-        Coordinate  display;
-        Coordinate  screen;
-        NOTE : i did not create a class with var readback, just used plain C notation.
-               These vars can be accessed from other code through <classname>.<varname>
-               example : TP.display.x
-               Only drawback : Each element of these vars needs to be initialised separately.
-                               (initialisation of these vars is not possible with array notation).
-
-      In Touch.cpp/.h
-      ---------------
-      TouchScreenADS7843 constructor: added pointer to SPI_TFT - needed for calibration, drawcross and drawpoint routines.
-                                      If LCD calls are not needed, initialise TouchScreenADS7843 with NULL pointer for LCD.
-
-      Removed TP_Init - moved TP_init code to constructor.
-
-      Variables in call to TouchPanel_Calibrate, Read_Ads7846, getDisplayPoint are no longer needed.
-      Modified these routines accordingly in touch.cpp/.h (pointers no longer needed)
-      *** TouchPanel_Calibrate and getDisplayPoint already modified.
-
-      Read_Ads7846: is also called in TouchPanel_Calibrate (Touch.cpp) with other var.
-                    Modified Read_Ads7846 to allow call with/without (parameter).
-                    If called without  (parameter) - screen variable is used, otherwise (parameter) is used.
-                    in Touch.h - unsigned char Read_Ads7846(Coordinate * screenPtr); replaced with
-                                 unsigned char Read_Ads7846(Coordinate * screenPtr = NULL);
-                    in Touch.cpp - if (screenPtr == NULL) screenPtr = &screen; added.
-      
-      
-      
-      General cleaning:
-      SPI_TFT::window function changed to use ints instead of unsigned ints, and made virtual to remove warnings.
-      In SPI_TFT.cpp GraphicsDiplay initialization moved to front to remove warnings
-      In Touch.cpp TFT pointer initialization moved to front to remove warnings
-      
-      In Mini_DK.h
-      ------------
-      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
--------------
-lpc1768 SPI port - problem when using SD and TFT simultaneously - solution provided by Erik Olieman
-see note http://mbed.org/comments/cr/83/2654/#c4768
-Even faster SPI write : http://mbed.org/users/Sissors/code/BurstSPI/docs/600eecd89a78/BurstSPI_8cpp_source.html
-*/
\ No newline at end of file