![](/media/cache/profiles/529d9389360a999c01709fe11a082bd2.jpg.50x50_q85.jpg)
UTFT with ITDB02 modules i use STM32F401RE
Dependencies: TFTLCD UTouch mbed
Fork of UTFT_SSD1289 by
main.cpp@0:d9da52df8532, 2016-03-14 (annotated)
- Committer:
- Irfan
- Date:
- Mon Mar 14 18:32:57 2016 +0000
- Revision:
- 0:d9da52df8532
my first demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Irfan | 0:d9da52df8532 | 1 | /** \file main.cpp |
Irfan | 0:d9da52df8532 | 2 | * \brief mbed UTFT demo for 3.2 TFT LCD Touch Shield module with SSD1289 and XPT2046 touchscreen. |
Irfan | 0:d9da52df8532 | 3 | * \example shield http://wiki.iteadstudio.com/3.2_TFT_LCD_Touch_Shield |
Irfan | 0:d9da52df8532 | 4 | ***************************************************************************************/ |
Irfan | 0:d9da52df8532 | 5 | |
Irfan | 0:d9da52df8532 | 6 | #include "mbed.h" |
Irfan | 0:d9da52df8532 | 7 | #include "ssd1289.h" |
Irfan | 0:d9da52df8532 | 8 | #include "UTouch.h" |
Irfan | 0:d9da52df8532 | 9 | |
Irfan | 0:d9da52df8532 | 10 | |
Irfan | 0:d9da52df8532 | 11 | |
Irfan | 0:d9da52df8532 | 12 | BusOut lcdDataBus(PC_9,PA_9,PB_9,PA_8,PB_10,PB_4,PB_5,PC_7,PA_12,PA_11,PB_12,PB_2,PB_1,PB_15,PB_14,PB_13); // 16 D0-D15 |
Irfan | 0:d9da52df8532 | 13 | |
Irfan | 0:d9da52df8532 | 14 | SSD1289_LCD myGLCD(PC_4,PA_10,PC_8,PC_6, &lcdDataBus ); //CS, RESET, RS, WR, DATA_PORT |
Irfan | 0:d9da52df8532 | 15 | |
Irfan | 0:d9da52df8532 | 16 | UTouch myTouch ( PB_6, PA_7, PA_6, PA_5, PB_8); //T_CLK T_CS T_DIN T_DOUT T_IRQ |
Irfan | 0:d9da52df8532 | 17 | |
Irfan | 0:d9da52df8532 | 18 | |
Irfan | 0:d9da52df8532 | 19 | int main() { |
Irfan | 0:d9da52df8532 | 20 | myGLCD.Initialize(); |
Irfan | 0:d9da52df8532 | 21 | myGLCD.SetBackground(COLOR_BLACK); |
Irfan | 0:d9da52df8532 | 22 | myGLCD.SetForeground(COLOR_BLACK); |
Irfan | 0:d9da52df8532 | 23 | myGLCD.FillScreen(COLOR_GREEN); |
Irfan | 0:d9da52df8532 | 24 | myGLCD.SetFont(&TerminusFont); |
Irfan | 0:d9da52df8532 | 25 | myTouch.InitTouch(); |
Irfan | 0:d9da52df8532 | 26 | myTouch.SetPrecision(PREC_HI); |
Irfan | 0:d9da52df8532 | 27 | |
Irfan | 0:d9da52df8532 | 28 | |
Irfan | 0:d9da52df8532 | 29 | while(1==1) { |
Irfan | 0:d9da52df8532 | 30 | int buf[318]; |
Irfan | 0:d9da52df8532 | 31 | int x; |
Irfan | 0:d9da52df8532 | 32 | int y; |
Irfan | 0:d9da52df8532 | 33 | |
Irfan | 0:d9da52df8532 | 34 | |
Irfan | 0:d9da52df8532 | 35 | myGLCD.ClearScreen(); |
Irfan | 0:d9da52df8532 | 36 | myGLCD.DrawLine(159, 15, 159, 224); |
Irfan | 0:d9da52df8532 | 37 | myGLCD.DrawLine(1, 119, 318, 119); |
Irfan | 0:d9da52df8532 | 38 | for (int i=9; i<310; i+=10) |
Irfan | 0:d9da52df8532 | 39 | myGLCD.DrawLine(i, 117, i, 121); |
Irfan | 0:d9da52df8532 | 40 | for (int i=19; i<220; i+=10) |
Irfan | 0:d9da52df8532 | 41 | myGLCD.DrawLine(157, i, 161, i); |
Irfan | 0:d9da52df8532 | 42 | |
Irfan | 0:d9da52df8532 | 43 | // Draw sin-, cos- and tan-lines |
Irfan | 0:d9da52df8532 | 44 | |
Irfan | 0:d9da52df8532 | 45 | myGLCD.Print("Sin", 5, 15, COLOR_RED); |
Irfan | 0:d9da52df8532 | 46 | for (int i=1; i<318; i++) |
Irfan | 0:d9da52df8532 | 47 | { |
Irfan | 0:d9da52df8532 | 48 | myGLCD.DrawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95), COLOR_RED); |
Irfan | 0:d9da52df8532 | 49 | } |
Irfan | 0:d9da52df8532 | 50 | |
Irfan | 0:d9da52df8532 | 51 | myGLCD.Print("Cos", 5, 27, COLOR_YELLOW); |
Irfan | 0:d9da52df8532 | 52 | for (int i=1; i<318; i++) |
Irfan | 0:d9da52df8532 | 53 | { |
Irfan | 0:d9da52df8532 | 54 | myGLCD.DrawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95), COLOR_YELLOW); |
Irfan | 0:d9da52df8532 | 55 | } |
Irfan | 0:d9da52df8532 | 56 | |
Irfan | 0:d9da52df8532 | 57 | |
Irfan | 0:d9da52df8532 | 58 | myGLCD.Print("Tan", 5, 39); |
Irfan | 0:d9da52df8532 | 59 | for (int i=1; i<318; i++) |
Irfan | 0:d9da52df8532 | 60 | { |
Irfan | 0:d9da52df8532 | 61 | myGLCD.DrawPixel(i,119+(tan(((i*1.13)*3.14)/180)),COLOR_BLUE); |
Irfan | 0:d9da52df8532 | 62 | } |
Irfan | 0:d9da52df8532 | 63 | wait(3); |
Irfan | 0:d9da52df8532 | 64 | myGLCD.ClearScreen(); |
Irfan | 0:d9da52df8532 | 65 | |
Irfan | 0:d9da52df8532 | 66 | // Draw a moving sinewave |
Irfan | 0:d9da52df8532 | 67 | x=1; |
Irfan | 0:d9da52df8532 | 68 | for (int i=1; i<(318*20); i++) |
Irfan | 0:d9da52df8532 | 69 | { |
Irfan | 0:d9da52df8532 | 70 | x++; |
Irfan | 0:d9da52df8532 | 71 | if (x==319) |
Irfan | 0:d9da52df8532 | 72 | x=1; |
Irfan | 0:d9da52df8532 | 73 | if (i>319) |
Irfan | 0:d9da52df8532 | 74 | { |
Irfan | 0:d9da52df8532 | 75 | if ((x==159)||(buf[x-1]==119)) |
Irfan | 0:d9da52df8532 | 76 | myGLCD.SetForeground(COLOR_RED); |
Irfan | 0:d9da52df8532 | 77 | else |
Irfan | 0:d9da52df8532 | 78 | |
Irfan | 0:d9da52df8532 | 79 | myGLCD.DrawPixel(x,buf[x-1], COLOR_BLUE); |
Irfan | 0:d9da52df8532 | 80 | } |
Irfan | 0:d9da52df8532 | 81 | |
Irfan | 0:d9da52df8532 | 82 | y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100))); |
Irfan | 0:d9da52df8532 | 83 | myGLCD.DrawPixel(x,y); |
Irfan | 0:d9da52df8532 | 84 | buf[x-1]=y; |
Irfan | 0:d9da52df8532 | 85 | } |
Irfan | 0:d9da52df8532 | 86 | |
Irfan | 0:d9da52df8532 | 87 | wait(2); |
Irfan | 0:d9da52df8532 | 88 | myGLCD.ClearScreen(); |
Irfan | 0:d9da52df8532 | 89 | |
Irfan | 0:d9da52df8532 | 90 | // Draw some lines in a pattern |
Irfan | 0:d9da52df8532 | 91 | |
Irfan | 0:d9da52df8532 | 92 | for (int i=15; i<224; i+=5) |
Irfan | 0:d9da52df8532 | 93 | { |
Irfan | 0:d9da52df8532 | 94 | myGLCD.DrawLine(1, i, (i*1.44)-10, 224, COLOR_BLUE); |
Irfan | 0:d9da52df8532 | 95 | } |
Irfan | 0:d9da52df8532 | 96 | |
Irfan | 0:d9da52df8532 | 97 | for (int i=224; i>15; i-=5) |
Irfan | 0:d9da52df8532 | 98 | { |
Irfan | 0:d9da52df8532 | 99 | myGLCD.DrawLine(318, i, (i*1.44)-11, 15,COLOR_GREEN); |
Irfan | 0:d9da52df8532 | 100 | } |
Irfan | 0:d9da52df8532 | 101 | |
Irfan | 0:d9da52df8532 | 102 | for (int i=224; i>15; i-=5) |
Irfan | 0:d9da52df8532 | 103 | { |
Irfan | 0:d9da52df8532 | 104 | myGLCD.DrawLine(1, i, 331-(i*1.44), 15, COLOR_RED); |
Irfan | 0:d9da52df8532 | 105 | } |
Irfan | 0:d9da52df8532 | 106 | |
Irfan | 0:d9da52df8532 | 107 | for (int i=15; i<224; i+=5) |
Irfan | 0:d9da52df8532 | 108 | { |
Irfan | 0:d9da52df8532 | 109 | myGLCD.DrawLine(318, i, 330-(i*1.44),224, COLOR_CYAN); |
Irfan | 0:d9da52df8532 | 110 | } |
Irfan | 0:d9da52df8532 | 111 | wait(3); |
Irfan | 0:d9da52df8532 | 112 | myGLCD.ClearScreen(); |
Irfan | 0:d9da52df8532 | 113 | } |
Irfan | 0:d9da52df8532 | 114 | } |