This program present workng library/class implementation/driver for touch panel controler xpt2046 or ads7843. Calbration in the future. I use in this program TFTLCD Library http://developer.mbed.org/users/ttodorov/. Thank You Todor
Dependencies: MyTouch TFTLCD mbed
main.cpp@1:ea35f77decd1, 2014-11-29 (annotated)
- Committer:
- micchassek
- Date:
- Sat Nov 29 19:17:13 2014 +0000
- Revision:
- 1:ea35f77decd1
- Parent:
- 0:a6a47eb54f87
This program present workng library/class implementation/driver for touch panel controler xpt2046 or ads7843. Calbration in the future. I use in this program TFTLCD Library http://developer.mbed.org/users/ttodorov/. Thank You Todor; ; ver 1.01
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
micchassek | 0:a6a47eb54f87 | 1 | #include "mbed.h" |
micchassek | 0:a6a47eb54f87 | 2 | #include "ssd1289.h" |
micchassek | 0:a6a47eb54f87 | 3 | #include "MyTouch.h" |
micchassek | 0:a6a47eb54f87 | 4 | |
micchassek | 0:a6a47eb54f87 | 5 | // ********************************************************************** |
micchassek | 0:a6a47eb54f87 | 6 | // make bus for lcd data |
micchassek | 0:a6a47eb54f87 | 7 | //* // prepare the data bus for writing commands and pixel data |
micchassek | 0:a6a47eb54f87 | 8 | BusOut lcdDataBus( PC_0, PC_1, PC_2, PC_3, PC_4, PC_5, PC_6, PC_7, PC_8, PC_9, PC_10, PC_11, PC_12, PC_13, PC_14, PC_15 ); // 16 pins pc13-pb7 |
micchassek | 0:a6a47eb54f87 | 9 | |
micchassek | 1:ea35f77decd1 | 10 | void mytouch_irq_handler(void) ; |
micchassek | 0:a6a47eb54f87 | 11 | volatile unsigned int x, y ; |
micchassek | 0:a6a47eb54f87 | 12 | |
micchassek | 0:a6a47eb54f87 | 13 | // create LCD class instance |
micchassek | 0:a6a47eb54f87 | 14 | SSD1289_LCD lcd( PA_11, PA_12, PB_13, PB_14, &lcdDataBus ); //CS, RESET, RS, WR, DATA_PORT |
micchassek | 0:a6a47eb54f87 | 15 | // create MYTOUCH class instance |
micchassek | 0:a6a47eb54f87 | 16 | MYTOUCH MyTouch( PA_7, PA_6, PA_5, PB_6, PB_8, USE_12BITS, &mytouch_irq_handler); // mosi, miso, sck, cs, irq pin, mode, pointer to touch panel irq handler |
micchassek | 0:a6a47eb54f87 | 17 | |
micchassek | 0:a6a47eb54f87 | 18 | void mytouch_irq_handler(void) |
micchassek | 0:a6a47eb54f87 | 19 | { |
micchassek | 0:a6a47eb54f87 | 20 | float xf, yf ; |
micchassek | 0:a6a47eb54f87 | 21 | x = MyTouch.TP_GetX(); |
micchassek | 0:a6a47eb54f87 | 22 | y = MyTouch.TP_GetY(); |
micchassek | 0:a6a47eb54f87 | 23 | xf = x ; |
micchassek | 0:a6a47eb54f87 | 24 | yf = y ; |
micchassek | 0:a6a47eb54f87 | 25 | xf = (xf/1024)*320 ; |
micchassek | 0:a6a47eb54f87 | 26 | yf = (yf/1024)*240 ; |
micchassek | 0:a6a47eb54f87 | 27 | x = (int)xf ; |
micchassek | 0:a6a47eb54f87 | 28 | y = (int)yf ; |
micchassek | 0:a6a47eb54f87 | 29 | lcd.DrawCircle(x,y,2, COLOR_GREEN) ; |
micchassek | 0:a6a47eb54f87 | 30 | wait(0.2); |
micchassek | 0:a6a47eb54f87 | 31 | } |
micchassek | 0:a6a47eb54f87 | 32 | // ********************************************************************** |
micchassek | 0:a6a47eb54f87 | 33 | |
micchassek | 0:a6a47eb54f87 | 34 | |
micchassek | 0:a6a47eb54f87 | 35 | int main() { |
micchassek | 0:a6a47eb54f87 | 36 | char text[24] ; |
micchassek | 0:a6a47eb54f87 | 37 | x = 0 ; |
micchassek | 0:a6a47eb54f87 | 38 | y = 0 ; |
micchassek | 0:a6a47eb54f87 | 39 | // initialize display - place it in standard portrait mode and set background to black and |
micchassek | 0:a6a47eb54f87 | 40 | // foreground to white color. |
micchassek | 0:a6a47eb54f87 | 41 | lcd.Initialize(LANDSCAPE, RGB16); |
micchassek | 0:a6a47eb54f87 | 42 | lcd.ClearScreen() ; |
micchassek | 0:a6a47eb54f87 | 43 | lcd.FillScreen(COLOR_BLACK) ; |
micchassek | 0:a6a47eb54f87 | 44 | lcd.SetForeground(COLOR_YELLOW); |
micchassek | 0:a6a47eb54f87 | 45 | lcd.SetBackground(COLOR_BLACK) ; |
micchassek | 0:a6a47eb54f87 | 46 | |
micchassek | 0:a6a47eb54f87 | 47 | // set current font to the smallest 8x12 pixels font. |
micchassek | 0:a6a47eb54f87 | 48 | lcd.SetFont(&TerminusFont ) ; // print something on the screen |
micchassek | 0:a6a47eb54f87 | 49 | while(1) |
micchassek | 0:a6a47eb54f87 | 50 | { |
micchassek | 0:a6a47eb54f87 | 51 | sprintf(text,"X%d Y%d ", x, y ) ; |
micchassek | 0:a6a47eb54f87 | 52 | lcd.Print(text, 15, 15 ) ; |
micchassek | 0:a6a47eb54f87 | 53 | wait(0.5) ; |
micchassek | 0:a6a47eb54f87 | 54 | } |
micchassek | 0:a6a47eb54f87 | 55 | } |