Setup for Adafruit 2.8" TFT with touch screen and SD card
Dependencies: SeeedStudioTFTv2 TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield by
main.cpp
00001 /* 00002 main.cpp 00003 2014 Copyright (c) Seeed Technology Inc. All right reserved. 00004 00005 Author:lawliet zou(lawliet.zou@gmail.com) 00006 2014-02-17 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #include "mbed.h" 00024 #include "SeeedStudioTFTv2.h" 00025 #include "Arial12x12.h" 00026 #include "Arial24x23.h" 00027 #include "Arial28x28.h" 00028 #include "font_big.h" 00029 00030 #define PIN_XP A3 00031 #define PIN_XM A1 00032 #define PIN_YP A2 00033 #define PIN_YM A0 00034 #define PIN_MOSI D11 00035 #define PIN_MISO D12 00036 #define PIN_SCLK D13 00037 #define PIN_CS_TFT D10 00038 #define PIN_DC_TFT D9 00039 #define PIN_BL_TFT D7 00040 #define PIN_CS_SD D4 00041 00042 SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD); 00043 00044 int main() 00045 { 00046 //Configure the display driver 00047 TFT.background(Black); 00048 TFT.foreground(White); 00049 TFT.cls(); 00050 00051 //Print a welcome message 00052 TFT.set_font((unsigned char*) Arial12x12); 00053 TFT.locate(0,0); 00054 TFT.printf("Hello Mbed"); 00055 00056 //Wait for 5 seconds 00057 wait(5.0); 00058 00059 //Draw some graphics 00060 TFT.cls(); 00061 TFT.set_font((unsigned char*) Arial24x23); 00062 TFT.locate(100,100); 00063 TFT.printf("Graphic"); 00064 00065 TFT.line(0,0,100,0,Green); 00066 TFT.line(0,0,0,200,Green); 00067 TFT.line(0,0,100,200,Green); 00068 00069 TFT.rect(100,50,150,100,Red); 00070 TFT.fillrect(180,25,220,70,Blue); 00071 00072 TFT.circle(80,150,33,White); 00073 TFT.fillcircle(160,190,20,Yellow); 00074 00075 double s; 00076 for (int i = 0; i < 320; i++) { 00077 s = 20 * sin((long double)i / 10); 00078 TFT.pixel(i, 100 + (int)s, Red); 00079 } 00080 00081 //Wait for 5 seconds 00082 wait(5.0); 00083 00084 //Multiple fonts 00085 TFT.foreground(White); 00086 TFT.background(Blue); 00087 TFT.cls(); 00088 TFT.set_font((unsigned char*) Arial24x23); 00089 TFT.locate(0,0); 00090 TFT.printf("Different Fonts:"); 00091 TFT.set_font((unsigned char*) Neu42x35); 00092 TFT.locate(0,30); 00093 TFT.printf("Hello Mbed 1"); 00094 TFT.set_font((unsigned char*) Arial24x23); 00095 TFT.locate(20,80); 00096 TFT.printf("Hello Mbed 2"); 00097 TFT.set_font((unsigned char*) Arial12x12); 00098 TFT.locate(35,120); 00099 TFT.printf("Hello Mbed 3"); 00100 }
Generated on Sat Jul 30 2022 14:05:30 by 1.7.2