Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed TFT_fonts_old
main.cpp
00001 // example to test the TFT Display 00002 // Thanks to the GraphicsDisplay and TextDisplay classes from 00003 00004 #include "stdio.h" 00005 #include "mbed.h" 00006 #include "SPI_TFT.h" 00007 #include "string" 00008 #include "Arial12x12.h" 00009 #include "Arial24x23.h" 00010 #include "Arial28x28.h" 00011 #include "font_big.h" 00012 00013 extern unsigned char p1[]; // the mbed logo 00014 00015 // the TFT is connected to SPI pin 5-7 00016 SPI_TFT TFT(p11, p12, p13, p14, p15,"TFT"); // mosi, miso, sclk, cs, reset 00017 00018 int main() { 00019 int i; 00020 TFT.claim(stdout); // send stdout to the TFT display 00021 //TFT.claim(stderr); // send stderr to the TFT display 00022 00023 TFT.background(Black); // set background to black 00024 TFT.foreground(White); // set chars to white 00025 TFT.cls(); // clear the screen 00026 TFT.set_font((unsigned char*) Arial12x12); // select the font 00027 00028 // first show the 4 directions 00029 TFT.set_orientation(0); 00030 TFT.locate(0,0); 00031 printf(" Hello Mbed 0"); 00032 TFT.set_orientation(1); 00033 TFT.locate(0,0); 00034 printf(" Hello Mbed 1"); 00035 TFT.set_orientation(2); 00036 TFT.locate(0,0); 00037 printf(" Hello Mbed 2"); 00038 TFT.set_orientation(3); 00039 TFT.locate(0,0); 00040 printf(" Hello Mbed 3"); 00041 TFT.set_orientation(1); 00042 TFT.set_font((unsigned char*) Arial24x23); 00043 TFT.locate(50,100); 00044 TFT.printf("TFT orientation"); 00045 00046 wait(5); // wait two seconds 00047 00048 // draw some graphics 00049 TFT.cls(); 00050 TFT.set_orientation(1); 00051 TFT.set_font((unsigned char*) Arial24x23); 00052 TFT.locate(100,100); 00053 TFT.printf("Graphic"); 00054 00055 TFT.line(0,0,100,200,Green); 00056 TFT.rect(100,50,150,100,Red); 00057 TFT.fillrect(180,25,220,70,Blue); 00058 TFT.circle(80,150,33,White); 00059 00060 wait(5); // wait two seconds 00061 00062 // bigger text 00063 TFT.foreground(White); 00064 TFT.background(Blue); 00065 TFT.cls(); 00066 TFT.set_font((unsigned char*) Arial24x23); 00067 TFT.locate(0,0); 00068 TFT.printf("Different Fonts :"); 00069 00070 TFT.set_font((unsigned char*) Neu42x35); 00071 TFT.locate(0,30); 00072 TFT.printf("Hello Mbed 1"); 00073 TFT.set_font((unsigned char*) Arial24x23); 00074 TFT.locate(20,80); 00075 TFT.printf("Hello Mbed 2"); 00076 TFT.set_font((unsigned char*) Arial12x12); 00077 TFT.locate(35,120); 00078 TFT.printf("Hello Mbed 3"); 00079 wait(5); 00080 00081 // mbed logo 00082 TFT.set_orientation(1); 00083 TFT.background(Black); 00084 TFT.cls(); 00085 TFT.Bitmap(90,90,172,55,p1); 00086 } 00087
Generated on Sat Jul 23 2022 05:58:59 by
1.7.2