aitendo TFT2P0327 (driver:S6D0151 Sumsung)

Dependencies:   S6D0151 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "stdio.h"
00002 #include "stdlib.h"
00003 #include "math.h"
00004 #include "mbed.h"
00005 #include "S6D0151_TFT.h"
00006 #include "Consolas10.h"
00007 #include "Consolas12.h"
00008 #include "Prototype33x38.h"
00009 #include "Prototype29x28.h"
00010 #include "aimasu_80x103.h"
00011 
00012 S6D0151_TFT TFT(PTD2, PTD3, PTD1, PTA13, PTD5,"TFT"); // mosi, miso, sclk, cs, reset
00013 
00014 //Serial pc(USBTX, USBRX); // tx, rx
00015 Ticker tt;
00016 
00017 void start_display(void);
00018 
00019 int main() {
00020 
00021     TFT.claim(stdout);      // send stdout to the TFT display 
00022     TFT.background(Black);    // set background to black
00023     TFT.foreground(White);    // set chars to white
00024 
00025     TFT.set_orientation( 0 );
00026     TFT.cls();
00027     TFT.locate(0,0);
00028 
00029     TFT.set_font((unsigned char*) Consolas7x13);  // select the font
00030 
00031     TFT.background(Black);    // set background to black
00032     TFT.foreground(Green);    // set chars to white
00033     
00034     start_display();            // 
00035     wait(3);
00036 
00037     TFT.set_font((unsigned char*) Consolas7x13);  // select the font
00038 
00039     while(1){
00040         TFT.set_orientation( 2 );
00041         TFT.background(White);
00042         TFT.cls();
00043         wait(0.5);
00044         TFT.foreground(Olive);
00045         TFT.Bitmap(  0,  0, 80,103,(unsigned char*)hibiki_80x103);
00046         TFT.foreground(Maroon);
00047         TFT.set_font((unsigned char*) Consolas7x13);  // select the font
00048         
00049         wait(3);
00050         TFT.set_orientation( 0 );
00051         TFT.background(Black);
00052         TFT.foreground(White);
00053         TFT.cls();
00054         TFT.locate(0,0);
00055         TFT.printf("TFT2P0327-E\n");
00056         TFT.printf("driver=S6D0151\n");
00057         
00058         TFT.locate(10,50);TFT.foreground(Cyan);
00059         TFT.printf("TEST!!");
00060         TFT.locate(15,62);
00061         TFT.set_font((unsigned char *)Prototype29x28);
00062         TFT.printf("mbed");TFT.foreground(Magenta);
00063         TFT.locate(5,90);
00064         TFT.set_font((unsigned char*) Consolas9x16);  // select the font
00065         TFT.printf("FRDM-KL2Z");TFT.foreground(GreenYellow);
00066         
00067         wait(3);
00068         // draw some graphics
00069         TFT.cls();
00070         TFT.set_font((unsigned char*) Consolas7x13);
00071         TFT.locate(5,5);
00072         TFT.printf("Graphic");
00073 
00074         TFT.line(0,0,100,0,Green);
00075         TFT.line(0,0,0,150,Green);
00076         TFT.line(0,0,100,150,Green);
00077 
00078         TFT.rect(50,100,100,150,Red);
00079         TFT.fillrect(30,25,80,70,Blue);
00080 
00081         TFT.circle(40,50,10,White);
00082         TFT.fillcircle2(50,60,8,Yellow);
00083 
00084         double s;
00085 
00086         for (int i=0; i<128; i++) {
00087             s =20 * sin((long double) i / 10 );
00088             TFT.pixel(i,100 + (int)s ,Red);
00089         }
00090         wait(3);
00091     } // for while()
00092    
00093 }
00094 
00095 
00096 void start_display(){
00097     TFT.cls();
00098     TFT.foreground(Green);
00099     TFT.background(Black);
00100     TFT.set_font((unsigned char*) Prototype33x38);
00101     TFT.locate( 48,  5);
00102     TFT._putc(135); // TAKA
00103     TFT.locate( 14, 38);
00104     for(char i=136;i<139;i++)TFT._putc(i); // BO C CHI
00105     TFT.locate( 14, 76);
00106     for(char i=139;i<142;i++)TFT._putc(i); // TAN KEN TAI
00107 }
00108