Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:a31069f27cd5, committed 2013-09-14
- Comitter:
- vcraciun
- Date:
- Sat Sep 14 13:03:33 2013 +0000
- Parent:
- 1:e7ae315a1ceb
- Commit message:
- added experimental calibration method
Changed in this revision
TouchPanel.cpp | Show annotated file Show diff for this revision Revisions of this file |
TouchPanel.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TouchPanel.cpp Sat Sep 14 11:48:46 2013 +0000 +++ b/TouchPanel.cpp Sat Sep 14 13:03:33 2013 +0000 @@ -1,11 +1,15 @@ #include "TouchPanel.h" +#define DEBUG_TOUCH_CALIBRATED //chestia asta ar trebui sa afiseze punctele de calibrare a touchului pe seriala + Matrix matrix ; Coordinate display ; Coordinate ScreenSample[3]; Coordinate DisplaySample[3] = {{30, 45}, {250, 70}, {160,210}}; + +extern Serial debug; Touch::Touch(SSD1289_LCD *lcd,SPI *spi, DigitalOut *cs, DigitalIn *irq) { @@ -198,7 +202,25 @@ return( retTHRESHOLD ) ; } -void Touch::TouchPanel_Calibrate(void) +bool Touch::getDisplayPoint(Coordinate * displayPtr,Coordinate * screenPtr,Matrix * matrixPtr ) +{ + bool retTHRESHOLD =true ; + + if( matrixPtr->Divider != 0 ) + { + displayPtr->x = ( (matrixPtr->An * screenPtr->x) + (matrixPtr->Bn * screenPtr->y) + matrixPtr->Cn ) / matrixPtr->Divider ; + displayPtr->y = ( (matrixPtr->Dn * screenPtr->x) + (matrixPtr->En * screenPtr->y) + matrixPtr->Fn ) / matrixPtr->Divider ; + } + else + { + retTHRESHOLD = false; + } + + return(retTHRESHOLD); +} + + +void Touch::TouchPanelCalibrate(void) { uint8_t i; Coordinate * Ptr; @@ -212,10 +234,26 @@ DrawCross(DisplaySample[i].x,DisplaySample[i].y); do { - Ptr=ReadAds7846(); + Ptr=ReadAds7846(); } while( Ptr == (void*)0 ); - ScreenSample[i].x= Ptr->x; ScreenSample[i].y= Ptr->y; + ScreenSample[i].x= Ptr->x; + ScreenSample[i].y= Ptr->y; + #ifdef DEBUG_TOUCH_CALIBRATED + debug.printf("Touch-Point: x=[%d] | y=[%d]\r\n",Ptr->x,Ptr->y); + #endif } setCalibrationMatrix( &DisplaySample[0],&ScreenSample[0],&matrix ); } + +void Touch::TouchPanelExperimentalCalibrate(int *values) +{ + int i; + + for (i=0;i<3;i++) + { + ScreenSample[i].x = values[i*2]; + ScreenSample[i].y = values[i*2+1]; + } + setCalibrationMatrix( &DisplaySample[0],&ScreenSample[0],&matrix ); +}
--- a/TouchPanel.h Sat Sep 14 11:48:46 2013 +0000 +++ b/TouchPanel.h Sat Sep 14 13:03:33 2013 +0000 @@ -35,7 +35,9 @@ Touch(SSD1289_LCD *lcd,SPI *spi, DigitalOut *cs, DigitalIn *irq); void InitializeTouch(); Coordinate *ReadAds7846(void); - void TouchPanel_Calibrate(void); + void TouchPanelCalibrate(void); + void TouchPanelExperimentalCalibrate(int *values); //values must be in order (x y) topleft, (x y) topright, (x y) midbottom + bool getDisplayPoint(Coordinate * displayPtr,Coordinate * screenPtr,Matrix * matrixPtr ); protected: int RDAD(void);