diff options
author | inmarket <andrewh@inmarket.com.au> | 2015-02-28 16:22:09 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2015-02-28 16:22:09 +1000 |
commit | fe980847d4d85cb7a4cd1f93de9b441337c20404 (patch) | |
tree | 2073c28bbb50a8fb12233030384fdcd8d4125aae /drivers/ginput/touch | |
parent | cd3a87f2d4c5738d823e893b89d56000ad7fc62f (diff) | |
download | uGFX-fe980847d4d85cb7a4cd1f93de9b441337c20404.tar.gz uGFX-fe980847d4d85cb7a4cd1f93de9b441337c20404.tar.bz2 uGFX-fe980847d4d85cb7a4cd1f93de9b441337c20404.zip |
Fix self calibration for touch devices FT5x06 and STMPE610
Diffstat (limited to 'drivers/ginput/touch')
-rw-r--r-- | drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c | 21 | ||||
-rw-r--r-- | drivers/ginput/touch/STMPE610/gmouse_lld_STMPE610.c | 9 |
2 files changed, 23 insertions, 7 deletions
diff --git a/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c index ba3db50b..0359ecf3 100644 --- a/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c +++ b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c @@ -72,10 +72,25 @@ static bool_t MouseXYZ(GMouse* m, GMouseReading* pdr) pdr->y = (coord_t)read_word(m, FT5x06_TOUCH1_YH); pdr->z = 1; + // Rescale X,Y if we are using self-calibration #if GMOUSE_FT5x06_SELF_CALIBRATE - // Rescale X,Y,Z - If we are using self-calibration - pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); - pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + #if GDISP_NEED_CONTROL + switch(gdispGGetOrientation(m->display)) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); + pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + pdr->x = gdispGGetHeight(m->display) - pdr->x / (4096/gdispGGetHeight(m->display)); + pdr->y = pdr->y / (4096/gdispGGetWidth(m->display)); + break; + } + #else + pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); + pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + #endif #endif } diff --git a/drivers/ginput/touch/STMPE610/gmouse_lld_STMPE610.c b/drivers/ginput/touch/STMPE610/gmouse_lld_STMPE610.c index 2175da94..6458c87d 100644 --- a/drivers/ginput/touch/STMPE610/gmouse_lld_STMPE610.c +++ b/drivers/ginput/touch/STMPE610/gmouse_lld_STMPE610.c @@ -207,7 +207,6 @@ static bool_t read_xyz(GMouse* m, GMouseReading* pdr) #endif // Rescale X,Y if we are using self-calibration - // Not working currently. #if GMOUSE_STMPE610_SELF_CALIBRATE #if GDISP_NEED_CONTROL switch(gdispGGetOrientation(m->display)) { @@ -215,14 +214,16 @@ static bool_t read_xyz(GMouse* m, GMouseReading* pdr) case GDISP_ROTATE_180: default: pdr->x = pdr->x / (4096/gdispGGetWidth(m->display)); - pdr->y = gdispGGetHeight(m->display) - pdr->y / (4096/gdispGGetHeight(m->display)); + pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + break; case GDISP_ROTATE_90: case GDISP_ROTATE_270: pdr->x = pdr->x / (4096/gdispGGetHeight(m->display)); - pdr->y = gdispGGetWidth(m->display) - pdr->y / (4096/gdispGGetWidth(m->display)); + pdr->y = pdr->y / (4096/gdispGGetWidth(m->display)); + break; } #else - pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); + pdr->x = pdr->x / (4096/gdispGGetWidth(m->display)); pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); #endif #endif |