test for the SPI_TFT Lib
Dependencies: SPI_TFT TFT_fonts mbed
Fork of TFT by
Diff: main.cpp
- Revision:
- 1:b295f3228ea2
- Parent:
- 0:f5b62bef3680
- Child:
- 3:0d07cf37bc00
diff -r f5b62bef3680 -r b295f3228ea2 main.cpp --- a/main.cpp Tue Mar 13 19:50:20 2012 +0000 +++ b/main.cpp Sat Apr 07 14:28:58 2012 +0000 @@ -1,5 +1,5 @@ - // example to test the TFT Display - // Thanks to the GraphicsDisplay and TextDisplay classes from +// example to test the TFT Display +// Thanks to the GraphicsDisplay and TextDisplay classes from #include "stdio.h" #include "mbed.h" @@ -11,40 +11,40 @@ #include "font_big.h" extern unsigned char p1[]; // the mbed logo +DigitalOut xx(p6); // debug !! +Serial pc(USBTX, USBRX); // tx, rx +DigitalOut myled(LED1); -// the TFT is connected to SPI pin 11-14 +// the TFT is connected to SPI pin 11-14 SPI_TFT TFT(p11, p12, p13, p14, p15,"TFT"); // mosi, miso, sclk, cs, reset -DigitalOut myled(LED1); -Serial pc(USBTX, USBRX); // tx, rx - -LocalFileSystem local("local"); +//LocalFileSystem local("local"); int main() { + + //pc.printf("start main \n\r"); int i; - TFT.claim(stdout); // send stdout to the TFT display + TFT.claim(stdout); // send stdout to the TFT display //TFT.claim(stderr); // send stderr to the TFT display - + TFT.set_orientation(0); TFT.background(Black); // set background to black TFT.foreground(White); // set chars to white TFT.cls(); // clear the screen - - - - - - - - - // first show the 4 directions - // mbed logo - TFT.set_orientation(0); - TFT.background(Black); - TFT.cls(); + // first show the 4 directions + // mbed logo + //TFT.set_orientation(0); + //TFT.background(Black); + //TFT.cls(); + + //do{} while(1); + TFT.set_font((unsigned char*) Arial12x12); TFT.locate(0,0); printf(" Hello Mbed 0"); + + // do{} while(1); + TFT.set_orientation(1); TFT.locate(0,0); printf(" Hello Mbed 1"); @@ -58,23 +58,28 @@ TFT.set_font((unsigned char*) Arial24x23); TFT.locate(50,100); TFT.printf("TFT orientation"); - - wait(5); // wait two seconds - - // draw some graphics - TFT.cls(); + + 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,0,Green); + TFT.line(0,0,0,200,Green); 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); - + TFT.fillcircle(160,190,20,Yellow); + wait(5); // wait two seconds - + // bigger text TFT.foreground(White); TFT.background(Blue); @@ -82,10 +87,10 @@ 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("He"); //ello Mbed 1"); + TFT.printf("Hello Mbed 1"); TFT.set_font((unsigned char*) Arial24x23); TFT.locate(20,80); TFT.printf("Hello Mbed 2"); @@ -93,11 +98,22 @@ TFT.locate(35,120); TFT.printf("Hello Mbed 3"); wait(5); - - // mbed logo + + // mbed logo TFT.set_orientation(1); TFT.background(Black); TFT.cls(); + + TFT.locate(10,10); + TFT.printf("Graphic from Flash"); + TFT.Bitmap(90,90,172,55,p1); + + wait(5); + TFT.cls(); + TFT.locate(10,10); + TFT.printf("Graphic from File System"); + int err = TFT.BMP_16(20,50,"test.bmp"); + if (err != 1) TFT.printf(" - Err: %d",err); }