test for the SPI_TFT Lib

Dependencies:   SPI_TFT TFT_fonts mbed

Fork of TFT by Peter Drescher

Revision:
2:64fbd5e91109
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 16 22:32:10 2011 +0000
@@ -0,0 +1,87 @@
+ // example to test the TFT Display
+ // Thanks to the GraphicsDisplay and TextDisplay classes from 
+
+#include "stdio.h"
+#include "mbed.h"
+#include "SPI_TFT.h"
+#include "string"
+#include "Arial12x12.h"
+#include "Arial24x23.h"
+#include "Arial28x28.h"
+#include "font_big.h"
+
+extern unsigned char p1[];  // the mbed logo
+
+// the TFT is connected to SPI pin 5-7 
+SPI_TFT TFT(p11, p12, p13, p14, p15,"TFT"); // mosi, miso, sclk, cs, reset
+
+int main() {
+    int i;
+    TFT.claim(stdout);      // send stdout to the TFT display 
+    //TFT.claim(stderr);      // send stderr to the TFT display
+
+    TFT.background(Black);    // set background to black
+    TFT.foreground(White);    // set chars to white
+    TFT.cls();                // clear the screen
+    TFT.set_font((unsigned char*) Arial12x12);  // select the font
+      
+    // first show the 4 directions  
+    TFT.set_orientation(0);
+    TFT.locate(0,0);
+    printf("  Hello Mbed 0");
+    TFT.set_orientation(1);
+    TFT.locate(0,0);
+    printf("  Hello Mbed 1");
+    TFT.set_orientation(2);
+    TFT.locate(0,0);
+    printf("  Hello Mbed 2");
+    TFT.set_orientation(3);
+    TFT.locate(0,0);
+    printf("  Hello Mbed 3");
+    TFT.set_orientation(1);
+    TFT.set_font((unsigned char*) Arial24x23);
+    TFT.locate(50,100);
+    TFT.printf("TFT orientation");
+       
+    wait(5);        // wait two seconds 
+    
+    // draw some graphics 
+    TFT.cls();          
+    TFT.set_orientation(1);
+    TFT.set_font((unsigned char*) Arial24x23);
+    TFT.locate(100,100);
+    TFT.printf("Graphic");
+     
+    TFT.line(0,0,100,200,Green);
+    TFT.rect(100,50,150,100,Red);
+    TFT.fillrect(180,25,220,70,Blue);
+    TFT.circle(80,150,33,White);
+    
+    wait(5);        // wait two seconds
+    
+    // bigger text
+    TFT.foreground(White);
+    TFT.background(Blue);
+    TFT.cls();
+    TFT.set_font((unsigned char*) Arial24x23);
+    TFT.locate(0,0);
+    TFT.printf("Different Fonts :");
+    
+    TFT.set_font((unsigned char*) Neu42x35);
+    TFT.locate(0,30);
+    TFT.printf("Hello Mbed 1");
+    TFT.set_font((unsigned char*) Arial24x23);
+    TFT.locate(20,80);
+    TFT.printf("Hello Mbed 2");
+    TFT.set_font((unsigned char*) Arial12x12);
+    TFT.locate(35,120);
+    TFT.printf("Hello Mbed 3");
+    wait(5);
+  
+    // mbed logo  
+    TFT.set_orientation(1);
+    TFT.background(Black);
+    TFT.cls();
+    TFT.Bitmap(90,90,172,55,p1);
+}
+