Erik -
/
Mini_DK_clk
Simple clock program for LPC1768 Mini-DK
Mini_DK/TouchADS7843/Touch.h@0:ab0aec01b38e, 2012-12-30 (annotated)
- Committer:
- Sissors
- Date:
- Sun Dec 30 21:31:56 2012 +0000
- Revision:
- 0:ab0aec01b38e
v0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 0:ab0aec01b38e | 1 | |
Sissors | 0:ab0aec01b38e | 2 | #ifndef MBED_Touch_H |
Sissors | 0:ab0aec01b38e | 3 | #define MBED_Touch_H |
Sissors | 0:ab0aec01b38e | 4 | |
Sissors | 0:ab0aec01b38e | 5 | #include "SPI_TFT.h" |
Sissors | 0:ab0aec01b38e | 6 | #include "mbed.h" |
Sissors | 0:ab0aec01b38e | 7 | |
Sissors | 0:ab0aec01b38e | 8 | typedef struct |
Sissors | 0:ab0aec01b38e | 9 | { |
Sissors | 0:ab0aec01b38e | 10 | int x; |
Sissors | 0:ab0aec01b38e | 11 | int y; |
Sissors | 0:ab0aec01b38e | 12 | } Coordinate; |
Sissors | 0:ab0aec01b38e | 13 | |
Sissors | 0:ab0aec01b38e | 14 | typedef struct |
Sissors | 0:ab0aec01b38e | 15 | { |
Sissors | 0:ab0aec01b38e | 16 | int An, |
Sissors | 0:ab0aec01b38e | 17 | Bn, |
Sissors | 0:ab0aec01b38e | 18 | Cn, |
Sissors | 0:ab0aec01b38e | 19 | Dn, |
Sissors | 0:ab0aec01b38e | 20 | En, |
Sissors | 0:ab0aec01b38e | 21 | Fn, |
Sissors | 0:ab0aec01b38e | 22 | Divider ; |
Sissors | 0:ab0aec01b38e | 23 | } Matrix; |
Sissors | 0:ab0aec01b38e | 24 | |
Sissors | 0:ab0aec01b38e | 25 | class TouchScreenADS7843 : public SPI_TFT |
Sissors | 0:ab0aec01b38e | 26 | { |
Sissors | 0:ab0aec01b38e | 27 | public: |
Sissors | 0:ab0aec01b38e | 28 | // (To be modified) C code below works on KEIL compiler but NOT on LPCXpresso/mbed |
Sissors | 0:ab0aec01b38e | 29 | // extern Coordinate ScreenSample[3]; |
Sissors | 0:ab0aec01b38e | 30 | // extern Coordinate DisplaySample[3]; |
Sissors | 0:ab0aec01b38e | 31 | // extern Matrix matrix ; |
Sissors | 0:ab0aec01b38e | 32 | // extern Coordinate display ; |
Sissors | 0:ab0aec01b38e | 33 | |
Sissors | 0:ab0aec01b38e | 34 | TouchScreenADS7843(PinName tp_mosi,PinName tp_miso,PinName tp_sclk,PinName tp_cs,PinName tp_irq,PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset,const char* name ="TFT"); |
Sissors | 0:ab0aec01b38e | 35 | |
Sissors | 0:ab0aec01b38e | 36 | void TP_Init(void); |
Sissors | 0:ab0aec01b38e | 37 | void TP_GetAdXY(int *x,int *y); |
Sissors | 0:ab0aec01b38e | 38 | void TP_DrawPoint(unsigned int Xpos,unsigned int Ypos,unsigned int color); |
Sissors | 0:ab0aec01b38e | 39 | // Coordinate Read_Ads7846(void); |
Sissors | 0:ab0aec01b38e | 40 | unsigned char Read_Ads7846(Coordinate * screenPtr); |
Sissors | 0:ab0aec01b38e | 41 | void TouchPanel_Calibrate(Matrix * matrixPtr); |
Sissors | 0:ab0aec01b38e | 42 | unsigned char getDisplayPoint(Coordinate * displayPtr,Coordinate * screenPtr,Matrix * matrixPtr ); |
Sissors | 0:ab0aec01b38e | 43 | |
Sissors | 0:ab0aec01b38e | 44 | SPI _tp_spi; |
Sissors | 0:ab0aec01b38e | 45 | DigitalOut _tp_cs; |
Sissors | 0:ab0aec01b38e | 46 | DigitalIn _tp_irq; |
Sissors | 0:ab0aec01b38e | 47 | |
Sissors | 0:ab0aec01b38e | 48 | protected: |
Sissors | 0:ab0aec01b38e | 49 | |
Sissors | 0:ab0aec01b38e | 50 | #define SPI_RD_DELAY 1 |
Sissors | 0:ab0aec01b38e | 51 | #define CHX 0xd0 // 12 bit mode |
Sissors | 0:ab0aec01b38e | 52 | #define CHY 0x90 |
Sissors | 0:ab0aec01b38e | 53 | |
Sissors | 0:ab0aec01b38e | 54 | int Read_XY(unsigned char XY); |
Sissors | 0:ab0aec01b38e | 55 | void DrawCross(unsigned int Xpos,unsigned int Ypos); |
Sissors | 0:ab0aec01b38e | 56 | unsigned char setCalibrationMatrix( Coordinate * displayPtr,Coordinate * screenPtr,Matrix * matrixPtr); |
Sissors | 0:ab0aec01b38e | 57 | |
Sissors | 0:ab0aec01b38e | 58 | }; |
Sissors | 0:ab0aec01b38e | 59 | #endif |