A simple demonstration program for the Seeed Studio TFT Touch Shield V2.0
Dependencies: SeeedStudioTFTv2 TFT_fonts mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SeeedStudioTFTv2.h" 00003 #include "Arial12x12.h" 00004 #include "Arial24x23.h" 00005 #include "Arial28x28.h" 00006 #include "font_big.h" 00007 00008 SeeedStudioTFTv2 TFT(PTB3, PTB1, PTB2, PTB0, PTD2, PTD3, PTD1, PTA5, PTC8, PTC9, PTA4); 00009 00010 int main() 00011 { 00012 //Configure the display driver 00013 TFT.background(Black); 00014 TFT.foreground(White); 00015 TFT.cls(); 00016 00017 //Print a welcome message 00018 TFT.set_font((unsigned char*) Arial12x12); 00019 TFT.locate(0,0); 00020 TFT.printf("Hello Mbed"); 00021 00022 //Wait for 5 seconds 00023 wait(5.0); 00024 00025 //Draw some graphics 00026 TFT.cls(); 00027 TFT.set_font((unsigned char*) Arial24x23); 00028 TFT.locate(100,100); 00029 TFT.printf("Graphic"); 00030 00031 TFT.line(0,0,100,0,Green); 00032 TFT.line(0,0,0,200,Green); 00033 TFT.line(0,0,100,200,Green); 00034 00035 TFT.rect(100,50,150,100,Red); 00036 TFT.fillrect(180,25,220,70,Blue); 00037 00038 TFT.circle(80,150,33,White); 00039 TFT.fillcircle(160,190,20,Yellow); 00040 00041 double s; 00042 for (int i = 0; i < 320; i++) { 00043 s = 20 * sin((long double)i / 10); 00044 TFT.pixel(i, 100 + (int)s, Red); 00045 } 00046 00047 //Wait for 5 seconds 00048 wait(5.0); 00049 00050 //Multiple fonts 00051 TFT.foreground(White); 00052 TFT.background(Blue); 00053 TFT.cls(); 00054 TFT.set_font((unsigned char*) Arial24x23); 00055 TFT.locate(0,0); 00056 TFT.printf("Different Fonts :"); 00057 TFT.set_font((unsigned char*) Neu42x35); 00058 TFT.locate(0,30); 00059 TFT.printf("Hello Mbed 1"); 00060 TFT.set_font((unsigned char*) Arial24x23); 00061 TFT.locate(20,80); 00062 TFT.printf("Hello Mbed 2"); 00063 TFT.set_font((unsigned char*) Arial12x12); 00064 TFT.locate(35,120); 00065 TFT.printf("Hello Mbed 3"); 00066 }
Generated on Sun Jul 17 2022 13:26:42 by 1.7.2