![](/media/cache/profiles/cd2a1086ae4e6f7b98a59dbe339c8f20.jpg.50x50_q85.jpg)
Helloworld program for TFT320_QVT Touchscreen module
Dependencies: TFTLCD UTouch mbed
Fork of TFT_320QVT_Window_Drag_Demo by
Revision 2:2f4024b1aefd, committed 2016-01-11
- Comitter:
- rpocc
- Date:
- Mon Jan 11 10:36:30 2016 +0000
- Parent:
- 1:3e5ca5f9f091
- Commit message:
- First release
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jan 11 09:44:14 2016 +0000 +++ b/main.cpp Mon Jan 11 10:36:30 2016 +0000 @@ -1,5 +1,5 @@ /** \file main.cpp - * \brief mbed Window Dragging demo for TFT-320QVT module with SSD1289 and XPT2046 touchscreen. + * \brief mbed Hello World demo for TFT-320QVT module with SSD1289 and XPT2046 touchscreen. * * \copyright GNU Public License, v2. or later * Creates a window, which can be dragged within the screen, and can be closed @@ -20,6 +20,7 @@ #define C_WINDOW_HIGHLIGHT 0xDDDDDD #define C_WINDOW_SHADOW 0xBBBBBB #define C_WINDOW_TITLE_BAR 0x0066DD +#define C_DESKTOP_BG 0x000000 #define WINDOW_WIDTH 150 #define WINDOW_HEIGHT 100 @@ -30,12 +31,13 @@ SSD1289_LCD myGLCD(PB_3, PB_4, PB_0, PB_1, &LCDPA, &LCDPC, NC, PB_2); UTouch myTouch(PB_9, PB_8, PB_7, PB_6, PB_5); - long x, y, oldx, oldy, wx = 100, wy = 100; + long x, y, oldx, oldy, wx, wy; float p; uint8_t av_cnt; int16_t rx, ry, rz1, rz2, pressure; char xc[10], yc[10], z1c[10], z2c[10], str[15]; bool drag = false; + bool loop = true; bool title(uint16_t xcur, uint16_t ycur, uint16_t xwin, uint16_t ywin) { if((xcur>xwin+2)&&(xcur<xwin+WINDOW_WIDTH-18)&&(ycur>ywin+2)&&(ycur<ywin+22)) return true; @@ -61,28 +63,35 @@ drawBox(xpos+xsize-21,ypos+3,18,18); myGLCD.DrawLine(xpos+xsize-18,ypos+6,xpos+xsize-7,ypos+17,COLOR_BLACK); myGLCD.DrawLine(xpos+xsize-18,ypos+17,xpos+xsize-7,ypos+6,COLOR_BLACK); + myGLCD.SetBackground(C_WINDOW_TITLE_BAR); + myGLCD.SetForeground(COLOR_WHITE); + myGLCD.Print("Hello World", xpos+6,ypos+6); } int main() { myGLCD.Initialize(); myGLCD.SetBackground(COLOR_WHITE); myGLCD.SetForeground(COLOR_BLACK); - myGLCD.FillScreen(COLOR_WHITE); + myGLCD.FillScreen(C_DESKTOP_BG); - drawWindow(wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT); - +while(1==1) +{ + wx = 85; + wy = 70; + loop = true; myGLCD.SetFont(&TerminusFont); myTouch.InitTouch(); myTouch.SetPrecision(PREC_HI); - -while(1==1) { - if (myTouch.DataAvailable() == true) + drawWindow(wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT); + while(loop) + { + if (myTouch.DataAvailable() == true) { if(myTouch.Read()) { x = myTouch.GetX(); y = myTouch.GetY(); if((oldx!=x)&&(oldy!=y)) { if(drag) { - myGLCD.FillRect(wx, wy, wx+WINDOW_WIDTH-1, wy+WINDOW_HEIGHT-1, COLOR_WHITE); + myGLCD.FillRect(wx, wy, wx+WINDOW_WIDTH-1, wy+WINDOW_HEIGHT-1, C_DESKTOP_BG); wx=wx+x-oldx; wy=wy+y-oldy; drawWindow(wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT); @@ -91,8 +100,8 @@ drag = true; } if(close(x, y, wx, wy)) { - myGLCD.FillRect(wx, wy, wx+WINDOW_WIDTH-1, wy+WINDOW_HEIGHT-1, COLOR_WHITE); - wx=320; wy=240; + myGLCD.FillRect(wx, wy, wx+WINDOW_WIDTH-1, wy+WINDOW_HEIGHT-1, C_DESKTOP_BG); + loop = false; } oldx = x; oldy = y; @@ -104,3 +113,4 @@ } } } +}