Sample program to use ILI9225_TFT library
Dependencies: ILI9225_SPI_TFT mbed
main.cpp
00001 #include "mbed.h" 00002 #include "TFT_22_ILI9225.h" 00003 #include "DefaultFonts.h" 00004 00005 00006 const unsigned char str[] = 00007 { 00008 0x28, 0x06, 0x47, 0x06, 0x20, 0x00, 0x46, 0x06, 0x27, 0x06, 0x45, 0x06, 0x20, 0x00, 00009 0x2E, 0x06, 0x2F, 0x06, 0x27, 0x06, 0x00 00010 }; 00011 char lcd_buf[100]; 00012 TFT_22_ILI9225 tft(PB_13, PB_14, PB_15, SPI_MOSI, SPI_SCK, PB_1); // RST, RS, CS, SDI (MOSI), CLK (SCK), LED 00013 uint16_t x, y; 00014 bool flag = false; 00015 00016 int main() 00017 { 00018 00019 tft.begin(); 00020 00021 tft.fill(COLOR_BLACK); 00022 tft.setOrientation(1); 00023 00024 00025 00026 tft.setFontColor(COLOR_BLUEVIOLET); 00027 tft.setFontEffect(2); 00028 tft.goToXY(0, 16 * 0); 00029 00030 tft.unicode2ascii((char *)str, lcd_buf); // Supporting Persian Language, you can ignore it if you don't use persian 00031 tft.putMixedEnAndFaString((unsigned char*)lcd_buf, 3); // Supporting Persian Language, you can ignore it if you don't use persian 00032 00033 00034 tft.roundRectangle(10, 16 * 4 - 5, tft.maxX() - 10, 16*4 + 40, 20, true, COLOR_LIGHTBLUE); // Supporting Persian Language, you can ignore it if you don't use persian 00035 tft.goToXY(30, 16 * 4); // Supporting Persian Language, you can ignore it if you don't use persian 00036 char *ss = "سلام";// Supporting Persian Language, you can ignore it if you don't use persian 00037 tft.putMixedEnAndFaString((unsigned char *)ss, 2); // Supporting Persian Language, you can ignore it if you don't use persian 00038 00039 00040 wait_ms(2000); 00041 00042 tft.drawRectangle(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_WHITE); 00043 tft.setFont(Terminal6x8); 00044 tft.drawText(10, 10, "hello!"); 00045 wait_ms(1000); 00046 00047 tft.clear(); 00048 tft.drawText(10, 20, "clear"); 00049 wait_ms(1000); 00050 00051 tft.drawText(10, 30, "text small"); 00052 tft.setBackgroundColor(COLOR_YELLOW); 00053 tft.setFont(Terminal11x16); 00054 tft.drawText(90, 30, "BIG", COLOR_RED); 00055 tft.setBackgroundColor(COLOR_BLACK); 00056 tft.setFont(Terminal6x8); 00057 wait_ms(1000); 00058 00059 tft.drawText(10, 40, "setBacklight off"); 00060 wait_ms(500); 00061 tft.setBacklight(false); 00062 wait_ms(500); 00063 tft.setBacklight(true); 00064 tft.drawText(10, 50, "setBacklight on"); 00065 wait_ms(1000); 00066 00067 tft.drawRectangle(10, 10, 110, 110, COLOR_BLUE); 00068 tft.drawText(10, 60, "rectangle"); 00069 wait_ms(1000); 00070 00071 tft.fillRectangle(20, 20, 120, 120, COLOR_RED); 00072 tft.drawText(10, 70, "solidRectangle"); 00073 wait_ms(1000); 00074 00075 tft.drawCircle(80, 80, 50, COLOR_YELLOW); 00076 tft.drawText(10, 80, "circle"); 00077 wait_ms(1000); 00078 00079 tft.fillCircle(90, 90, 30, COLOR_GREEN); 00080 tft.drawText(10, 90, "solidCircle"); 00081 wait_ms(1000); 00082 00083 tft.drawLine(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_CYAN); 00084 tft.drawText(10, 100, "line"); 00085 wait_ms(1000); 00086 00087 wait_ms(1000); 00088 00089 for (uint8_t i = 0; i < 4; i++) { 00090 tft.clear(); 00091 tft.setOrientation(i); 00092 tft.drawRectangle(0, 0, tft.maxX() - 1, tft.maxY() - 1, COLOR_WHITE); 00093 tft.drawRectangle(10, 20, 50, 60, COLOR_GREEN); 00094 tft.drawCircle(70, 80, 10, COLOR_BLUE); 00095 tft.drawLine(30, 40, 70, 80, COLOR_YELLOW); 00096 wait_ms(1000); 00097 } 00098 00099 tft.setOrientation(0); 00100 tft.clear(); 00101 tft.setFont(Terminal12x16); 00102 tft.setBackgroundColor(COLOR_YELLOW); 00103 tft.drawText(10, 40, "bye!", COLOR_RED); 00104 tft.setBackgroundColor(COLOR_BLACK); 00105 tft.setFont(Terminal12x16); 00106 wait_ms(1000); 00107 00108 tft.drawText(10, 60, "off"); 00109 wait_ms(1000); 00110 00111 tft.setBacklight(false); 00112 tft.setDisplay(false); 00113 00114 00115 while (true) { 00116 00117 } 00118 00119 00120 }
Generated on Fri Jul 15 2022 17:51:49 by 1.7.2