From 5a5db64288414162a31a7e755757c32ddf55bf6c Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 16:46:02 +0100 Subject: [PATCH 01/10] renamed tsIRQ() into tsPressed() --- drivers/gdisp/Win32/gdisp_lld.c | 2 +- drivers/touchscreen/ADS7843/touchscreen_lld.c | 4 ++-- drivers/touchscreen/XPT2046/touchscreen_lld.c | 2 +- include/touchscreen.h | 2 +- include/touchscreen_lld.h | 2 +- src/touchscreen.c | 12 ++++++------ 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gdisp/Win32/gdisp_lld.c b/drivers/gdisp/Win32/gdisp_lld.c index 4cf69b0e..69e90e89 100644 --- a/drivers/gdisp/Win32/gdisp_lld.c +++ b/drivers/gdisp/Win32/gdisp_lld.c @@ -546,7 +546,7 @@ uint16_t ts_lld_read_z(void) { * * @notapi */ -uint8_t ts_lld_irq(void) { +uint8_t ts_lld_pressed(void) { return (uint8_t)mousedn; } diff --git a/drivers/touchscreen/ADS7843/touchscreen_lld.c b/drivers/touchscreen/ADS7843/touchscreen_lld.c index 98e25383..15b1d907 100644 --- a/drivers/touchscreen/ADS7843/touchscreen_lld.c +++ b/drivers/touchscreen/ADS7843/touchscreen_lld.c @@ -213,13 +213,13 @@ uint16_t ts_lld_read_y(void) { /* ---- Optional Routines ---- */ #if TOUCHSCREEN_HAS_IRQ || defined(__DOXYGEN__) /* - * @brief for checking if touchpad is pressed or not. + * @brief for checking if touchscreen is pressed or not. * * @return 1 if pressed / 0 if not pressed * * @notapi */ - uint8_t ts_lld_irq(void) { + uint8_t ts_lld_pressed(void) { return (!palReadPad(tsDriver->tsIRQPort, tsDriver->tsIRQPin)); } #endif diff --git a/drivers/touchscreen/XPT2046/touchscreen_lld.c b/drivers/touchscreen/XPT2046/touchscreen_lld.c index 90bf0032..ef410b0d 100644 --- a/drivers/touchscreen/XPT2046/touchscreen_lld.c +++ b/drivers/touchscreen/XPT2046/touchscreen_lld.c @@ -219,7 +219,7 @@ uint16_t ts_lld_read_y(void) { * * @notapi */ - uint8_t ts_lld_irq(void) { + uint8_t ts_lld_pressed(void) { return (!palReadPad(tsDriver->tsIRQPort, tsDriver->tsIRQPin)); } #endif diff --git a/include/touchscreen.h b/include/touchscreen.h index 4d48e38d..65c6400f 100644 --- a/include/touchscreen.h +++ b/include/touchscreen.h @@ -82,7 +82,7 @@ coord_t tsReadY(void); void tsCalibrate(void); #if TOUCHSCREEN_HAS_IRQ - bool_t tsIRQ(void); + bool_t tsPressed(void); #endif #if TOUCHSCREEN_HAS_PRESSURE diff --git a/include/touchscreen_lld.h b/include/touchscreen_lld.h index 53c66b53..ab035ae3 100644 --- a/include/touchscreen_lld.h +++ b/include/touchscreen_lld.h @@ -137,7 +137,7 @@ extern "C" { uint16_t ts_lld_read_y(void); #if TOUCHSCREEN_HAS_IRQ - uint8_t ts_lld_irq(void); + uint8_t ts_lld_pressed(void); #endif #if TOUCHSCREEN_HAS_PRESSURE diff --git a/src/touchscreen.c b/src/touchscreen.c index b6a1a0c3..7c2ec34f 100644 --- a/src/touchscreen.c +++ b/src/touchscreen.c @@ -270,8 +270,8 @@ coord_t tsReadY(void) { * @api */ #if TOUCHSCREEN_HAS_IRQ || defined(__DOXYGEN__) - bool_t tsIRQ(void) { - return ts_lld_irq(); + bool_t tsPressed(void) { + return ts_lld_pressed(); } #endif @@ -311,7 +311,7 @@ calibrate: #endif _tsDrawCross(cross[i][0], cross[i][1]); - while(!tsIRQ()) + while(!tsPressed()) chThdSleepMilliseconds(2); /* Be nice to other threads*/ chThdSleepMilliseconds(20); /* Allow screen to settle */ @@ -321,8 +321,8 @@ calibrate: px = py = 0; j = 0; - while (j < MAX_CAL_SAMPLES) { - if (tsIRQ()) { + while(j < MAX_CAL_SAMPLES) { + if(tsPressed()) { /* We have valid pointer data */ px += _tsReadRealX(); py += _tsReadRealY(); @@ -336,7 +336,7 @@ calibrate: chThdSleepMilliseconds(100); - while(tsIRQ()) + while(tsPressed()) chThdSleepMilliseconds(2); /* Be nice to other threads*/ gdispFillArea(cross[i][0] - 15, cross[i][1] - 15, 42, 42, Blue); From 8231e9738c20bd676943638830fedeb71ca1195d Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 16:49:03 +0100 Subject: [PATCH 02/10] removed unused RGB565CONVERT. Please use RGB2COLOR instead --- demos/mandelbrot/main.c | 1 - include/gdisp.h | 1 - 2 files changed, 2 deletions(-) diff --git a/demos/mandelbrot/main.c b/demos/mandelbrot/main.c index 0c8dc47d..92f4aaa2 100644 --- a/demos/mandelbrot/main.c +++ b/demos/mandelbrot/main.c @@ -43,7 +43,6 @@ void mandelbrot(float x1, float y1, float x2, float y2) { x = xx - yy + cx; } color = ((iter << 8) | (iter&0xFF)); - //color = RGB565CONVERT(iter*4, iter*13, iter*10); gdispDrawPixel(i, j, color); } } diff --git a/include/gdisp.h b/include/gdisp.h index db865284..9be97a12 100644 --- a/include/gdisp.h +++ b/include/gdisp.h @@ -293,7 +293,6 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); /* Now obsolete functions */ #define gdispBlitArea(x, y, cx, cy, buffer) gdispBlitAreaEx(x, y, cx, cy, 0, 0, cx, buffer) -#define RGB565CONVERT(r,g,b) RGB2COLOR(r,g,b) /* Macro definitions for common gets and sets */ #define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode)) From 5f903622616a2f1686f3124bf56dd69479fd9454 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 17:04:20 +0100 Subject: [PATCH 03/10] touchscreen fixes --- demos/notepad/main.c | 3 --- include/touchscreen.h | 8 ++++++++ include/touchscreen_lld.h | 8 -------- src/touchscreen.c | 10 +++++----- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/demos/notepad/main.c b/demos/notepad/main.c index 5d9e5ffc..7fec864f 100644 --- a/demos/notepad/main.c +++ b/demos/notepad/main.c @@ -53,8 +53,6 @@ TouchscreenDriver TOUCHPADD1 = { void drawScreen(void) { char *msg = "ChibiOS/GFX"; - uint16_t colorsize = COLOR_SIZE; - uint16_t pensize = PEN_SIZE; gdispSetOrientation(GDISP_ROTATE_90); gdispClear(White); @@ -86,7 +84,6 @@ int main(void) { gdispInit(); tsInit(&TOUCHPADD1); - tsCalibrate(); drawScreen(); diff --git a/include/touchscreen.h b/include/touchscreen.h index 65c6400f..a6673cbd 100644 --- a/include/touchscreen.h +++ b/include/touchscreen.h @@ -31,6 +31,14 @@ #if GFX_USE_TOUCHSCREEN || defined(__DOXYGEN__) +#ifndef TOUCHSCREEN_STORE_CALIBRATION + #define TOUCHSCREEN_STORE_CALIBRATION FALSE +#endif + +#ifndef TOUCHSCREEN_VERIFY_CALIBRATION + #define TOUCHSCREEN_VERIFY_CALIBRATION FALSE +#endif + /** * @brief specifies how many conversions are made for a readout. * diff --git a/include/touchscreen_lld.h b/include/touchscreen_lld.h index ab035ae3..3053b0e5 100644 --- a/include/touchscreen_lld.h +++ b/include/touchscreen_lld.h @@ -49,14 +49,6 @@ #define TOUCHSCREEN_XY_INVERTED FALSE #endif -#ifndef TOUCHSCREEN_STORE_CALIBRATION - #define TOUCHSCREEN_STORE_CALIBRATION FALSE -#endif - -#ifndef TOUCHSCREEN_VERIFY_CALIBRATION - #define TOUCHSCREEN_VERIFY_CALIBRATION FALSE -#endif - #ifndef TOUCHSCREEN_HAS_IRQ #define TOUCHSCREEN_HAS_IRQ FALSE #endif diff --git a/src/touchscreen.c b/src/touchscreen.c index 7c2ec34f..d7abbe30 100644 --- a/src/touchscreen.c +++ b/src/touchscreen.c @@ -159,7 +159,6 @@ static void _tsDo3PointCalibration(const coord_t (*cross)[2], coord_t (*points)[ * @api */ void tsInit(const TouchscreenDriver *ts) { - /* Initialise Mutex */ //MUTEX_INIT @@ -177,6 +176,7 @@ void tsInit(const TouchscreenDriver *ts) { cal = (struct cal_t*)chHeapAlloc(NULL, sizeof(struct cal_t)); if(cal == NULL) return; + tsCalibrate(); } @@ -206,9 +206,9 @@ coord_t tsReadX(void) { case GDISP_ROTATE_90: return y; case GDISP_ROTATE_180: - return gdispGetWidth() - x - 1; + return GDISP_SCREEN_WIDTH - x - 1; case GDISP_ROTATE_270: - return gdispGetHeight() - y - 1; + return GDISP_SCREEN_HEIGHT - y - 1; } return 0; @@ -238,9 +238,9 @@ coord_t tsReadY(void) { case GDISP_ROTATE_0: return y; case GDISP_ROTATE_90: - return gdispGetWidth() - x - 1; + return GDISP_SCREEN_WIDTH - x - 1; case GDISP_ROTATE_180: - return gdispGetHeight() - y - 1; + return GDISP_SCREEN_HEIGHT - y - 1; case GDISP_ROTATE_270: return x; } From 1ba2539b6c11402835e4f8554678f0c0e64dfbc1 Mon Sep 17 00:00:00 2001 From: mobyfab Date: Sat, 10 Nov 2012 17:10:19 +0100 Subject: [PATCH 04/10] Adding TOUCHSCREEN_XY_INVERTED define to the calibration function. --- src/touchscreen.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/touchscreen.c b/src/touchscreen.c index d7abbe30..8f403d4e 100644 --- a/src/touchscreen.c +++ b/src/touchscreen.c @@ -324,9 +324,14 @@ calibrate: while(j < MAX_CAL_SAMPLES) { if(tsPressed()) { /* We have valid pointer data */ + +#if TOUCHSCREEN_XY_INVERTED == TRUE + py += _tsReadRealX(); + px += _tsReadRealY(); +#else px += _tsReadRealX(); py += _tsReadRealY(); - +#endif j++; } } From 37b5067de80d53cc13fce8475511857ad9c95780 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 17:37:44 +0100 Subject: [PATCH 05/10] small doxygen update --- src/touchscreen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/touchscreen.c b/src/touchscreen.c index d7abbe30..6694b391 100644 --- a/src/touchscreen.c +++ b/src/touchscreen.c @@ -151,8 +151,7 @@ static void _tsDo3PointCalibration(const coord_t (*cross)[2], coord_t (*points)[ /** * @brief Touchscreen Driver initialization. - * @note This function is NOT currently implicitly invoked by @p halInit(). - * It must be called manually. + * @note Calling this function automatically invokes a tsCalibration() * * @param[in] ts The touchscreen driver struct * @@ -285,6 +284,8 @@ coord_t tsReadY(void) { * the accuracy of the calibration coefficients obtained if the symbol * TOUCHSCREEN_VERIFY_CALIBRATION is defined in the configuration. * + * @note You don't have to call this function manually. It gets invoked by tsInit() + * * @api */ void tsCalibrate(void) { From ccf7fc30687e8c93e18171c2e77b1821f54c2633 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 18:39:00 +0100 Subject: [PATCH 06/10] cleanup --- src/touchscreen.c | 215 +++++++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 108 deletions(-) diff --git a/src/touchscreen.c b/src/touchscreen.c index eea6e273..4e90f3e4 100644 --- a/src/touchscreen.c +++ b/src/touchscreen.c @@ -85,64 +85,64 @@ static coord_t _tsReadRealY(void) { } static void _tsDrawCross(uint16_t x, uint16_t y) { - gdispDrawLine(x-15, y, x-2, y, White); - gdispDrawLine(x+2, y, x+15, y, White); - gdispDrawLine(x, y-15, x, y-2, White); - gdispDrawLine(x, y+2, x, y+15, White); + gdispDrawLine(x-15, y, x-2, y, White); + gdispDrawLine(x+2, y, x+15, y, White); + gdispDrawLine(x, y-15, x, y-2, White); + gdispDrawLine(x, y+2, x, y+15, White); - gdispDrawLine(x-15, y+15, x-7, y+15, RGB2COLOR(184,158,131)); - gdispDrawLine(x-15, y+7, x-15, y+15, RGB2COLOR(184,158,131)); + gdispDrawLine(x-15, y+15, x-7, y+15, RGB2COLOR(184,158,131)); + gdispDrawLine(x-15, y+7, x-15, y+15, RGB2COLOR(184,158,131)); - gdispDrawLine(x-15, y-15, x-7, y-15, RGB2COLOR(184,158,131)); - gdispDrawLine(x-15, y-7, x-15, y-15, RGB2COLOR(184,158,131)); + gdispDrawLine(x-15, y-15, x-7, y-15, RGB2COLOR(184,158,131)); + gdispDrawLine(x-15, y-7, x-15, y-15, RGB2COLOR(184,158,131)); - gdispDrawLine(x+7, y+15, x+15, y+15, RGB2COLOR(184,158,131)); - gdispDrawLine(x+15, y+7, x+15, y+15, RGB2COLOR(184,158,131)); + gdispDrawLine(x+7, y+15, x+15, y+15, RGB2COLOR(184,158,131)); + gdispDrawLine(x+15, y+7, x+15, y+15, RGB2COLOR(184,158,131)); - gdispDrawLine(x+7, y-15, x+15, y-15, RGB2COLOR(184,158,131)); - gdispDrawLine(x+15, y-15, x+15, y-7, RGB2COLOR(184,158,131)); + gdispDrawLine(x+7, y-15, x+15, y-15, RGB2COLOR(184,158,131)); + gdispDrawLine(x+15, y-15, x+15, y-7, RGB2COLOR(184,158,131)); } static void _tsTransform(coord_t *x, coord_t *y) { - *x = (coord_t) (cal->ax * (*x) + cal->bx * (*y) + cal->cx); - *y = (coord_t) (cal->ay * (*x) + cal->by * (*y) + cal->cy); + *x = (coord_t) (cal->ax * (*x) + cal->bx * (*y) + cal->cx); + *y = (coord_t) (cal->ay * (*x) + cal->by * (*y) + cal->cy); } static void _tsDo3PointCalibration(const coord_t (*cross)[2], coord_t (*points)[2], cal_t *c) { - float dx, dx0, dx1, dx2, dy0, dy1, dy2; + float dx, dx0, dx1, dx2, dy0, dy1, dy2; - /* Compute all the required determinants */ - dx = ((float)(points[0][0] - points[2][0])) * ((float)(points[1][1] - points[2][1])) - - ((float)(points[1][0] - points[2][0])) * ((float)(points[0][1] - points[2][1])); + /* Compute all the required determinants */ + dx = ((float)(points[0][0] - points[2][0])) * ((float)(points[1][1] - points[2][1])) + - ((float)(points[1][0] - points[2][0])) * ((float)(points[0][1] - points[2][1])); - dx0 = ((float)(cross[0][0] - cross[2][0])) * ((float)(points[1][1] - points[2][1])) - - ((float)(cross[1][0] - cross[2][0])) * ((float)(points[0][1] - points[2][1])); + dx0 = ((float)(cross[0][0] - cross[2][0])) * ((float)(points[1][1] - points[2][1])) + - ((float)(cross[1][0] - cross[2][0])) * ((float)(points[0][1] - points[2][1])); - dx1 = ((float)(points[0][0] - points[2][0])) * ((float)(cross[1][0] - cross[2][0])) - - ((float)(points[1][0] - points[2][0])) * ((float)(cross[0][0] - cross[2][0])); + dx1 = ((float)(points[0][0] - points[2][0])) * ((float)(cross[1][0] - cross[2][0])) + - ((float)(points[1][0] - points[2][0])) * ((float)(cross[0][0] - cross[2][0])); - dx2 = cross[0][0] * ((float)points[1][0] * (float)points[2][1] - (float)points[2][0] * (float)points[1][1]) - - cross[1][0] * ((float)points[0][0] * (float)points[2][1] - (float)points[2][0] * (float)points[0][1]) + - cross[2][0] * ((float)points[0][0] * (float)points[1][1] - (float)points[1][0] * (float)points[0][1]); + dx2 = cross[0][0] * ((float)points[1][0] * (float)points[2][1] - (float)points[2][0] * (float)points[1][1]) - + cross[1][0] * ((float)points[0][0] * (float)points[2][1] - (float)points[2][0] * (float)points[0][1]) + + cross[2][0] * ((float)points[0][0] * (float)points[1][1] - (float)points[1][0] * (float)points[0][1]); - dy0 = ((float)(cross[0][1] - cross[2][1])) * ((float)(points[1][1] - points[2][1])) - - ((float)(cross[1][1] - cross[2][1])) * ((float)(points[0][1] - points[2][1])); + dy0 = ((float)(cross[0][1] - cross[2][1])) * ((float)(points[1][1] - points[2][1])) + - ((float)(cross[1][1] - cross[2][1])) * ((float)(points[0][1] - points[2][1])); - dy1 = ((float)(points[0][0] - points[2][0])) * ((float)(cross[1][1] - cross[2][1])) - - ((float)(points[1][0] - points[2][0])) * ((float)(cross[0][1] - cross[2][1])); + dy1 = ((float)(points[0][0] - points[2][0])) * ((float)(cross[1][1] - cross[2][1])) + - ((float)(points[1][0] - points[2][0])) * ((float)(cross[0][1] - cross[2][1])); - dy2 = cross[0][1] * ((float)points[1][0] * (float)points[2][1] - (float)points[2][0] * (float)points[1][1]) - - cross[1][1] * ((float)points[0][0] * (float)points[2][1] - (float)points[2][0] * (float)points[0][1]) + - cross[2][1] * ((float)points[0][0] * (float)points[1][1] - (float)points[1][0] * (float)points[0][1]); + dy2 = cross[0][1] * ((float)points[1][0] * (float)points[2][1] - (float)points[2][0] * (float)points[1][1]) - + cross[1][1] * ((float)points[0][0] * (float)points[2][1] - (float)points[2][0] * (float)points[0][1]) + + cross[2][1] * ((float)points[0][0] * (float)points[1][1] - (float)points[1][0] * (float)points[0][1]); - /* Now, calculate all the required coefficients */ - c->ax = dx0 / dx; - c->bx = dx1 / dx; - c->cx = dx2 / dx; + /* Now, calculate all the required coefficients */ + c->ax = dx0 / dx; + c->bx = dx1 / dx; + c->cx = dx2 / dx; - c->ay = dy0 / dx; - c->by = dy1 / dx; - c->cy = dy2 / dx; + c->ay = dy0 / dx; + c->by = dy1 / dx; + c->cy = dy2 / dx; } /*===========================================================================*/ @@ -187,17 +187,17 @@ void tsInit(const TouchscreenDriver *ts) { * @api */ coord_t tsReadX(void) { - coord_t x, y; + coord_t x, y; -#if TOUCHSCREEN_XY_INVERTED == TRUE - x = _tsReadRealY(); - y = _tsReadRealX(); +#if TOUCHSCREEN_XY_INVERTED + x = _tsReadRealY(); + y = _tsReadRealX(); #else - x = _tsReadRealX(); - y = _tsReadRealY(); + x = _tsReadRealX(); + y = _tsReadRealY(); #endif - _tsTransform(&x, &y); + _tsTransform(&x, &y); switch(gdispGetOrientation()) { case GDISP_ROTATE_0: @@ -223,7 +223,7 @@ coord_t tsReadX(void) { coord_t tsReadY(void) { coord_t x, y; -#if TOUCHSCREEN_XY_INVERTED == TRUE +#if TOUCHSCREEN_XY_INVERTED x = _tsReadRealY(); y = _tsReadRealX(); #else @@ -289,90 +289,89 @@ coord_t tsReadY(void) { * @api */ void tsCalibrate(void) { - const uint16_t height = gdispGetHeight(); - const uint16_t width = gdispGetWidth(); - const coord_t cross[][2] = {{(width / 4), (height / 4)}, + const uint16_t height = gdispGetHeight(); + const uint16_t width = gdispGetWidth(); + const coord_t cross[][2] = {{(width / 4), (height / 4)}, {(width - (width / 4)) , (height / 4)}, {(width - (width / 4)) , (height - (height / 4))}, {(width / 2), (height / 2)}}; /* Check point */ - coord_t points[4][2]; - int32_t px, py; - uint8_t i, j; + coord_t points[4][2]; + int32_t px, py; + uint8_t i, j; - gdispSetOrientation(GDISP_ROTATE_0); - gdispClear(Blue); + gdispSetOrientation(GDISP_ROTATE_0); + gdispClear(Blue); - gdispFillStringBox(0, 5, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Blue, justifyCenter); + gdispFillStringBox(0, 5, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Blue, justifyCenter); #if TOUCHSCREEN_VERIFY_CALIBRATION calibrate: - for(i = 0; i < 4; i++) { + for(i = 0; i < 4; i++) { #else - for(i = 0; i < 3; i++) { + for(i = 0; i < 3; i++) { #endif - _tsDrawCross(cross[i][0], cross[i][1]); + _tsDrawCross(cross[i][0], cross[i][1]); - while(!tsPressed()) - chThdSleepMilliseconds(2); /* Be nice to other threads*/ + while(!tsPressed()) + chThdSleepMilliseconds(2); /* Be nice to other threads*/ + + chThdSleepMilliseconds(20); /* Allow screen to settle */ - chThdSleepMilliseconds(20); /* Allow screen to settle */ + /* Take a little more samples per point and their average + * for precise calibration */ + px = py = 0; + j = 0; - /* Take a little more samples per point and their average - * for precise calibration */ - px = py = 0; + while(j < MAX_CAL_SAMPLES) { + if(tsPressed()) { /* We have valid pointer data */ + #if TOUCHSCREEN_XY_INVERTED + py += _tsReadRealX(); + px += _tsReadRealY(); + #else + px += _tsReadRealX(); + py += _tsReadRealY(); + #endif - j = 0; - while(j < MAX_CAL_SAMPLES) { - if(tsPressed()) { - /* We have valid pointer data */ - -#if TOUCHSCREEN_XY_INVERTED == TRUE - py += _tsReadRealX(); - px += _tsReadRealY(); -#else - px += _tsReadRealX(); - py += _tsReadRealY(); -#endif - j++; - } - } + j++; + } + } + + points[i][0] = px / j; + points[i][1] = py / j; - points[i][0] = px / j; - points[i][1] = py / j; + chThdSleepMilliseconds(100); - chThdSleepMilliseconds(100); + while(tsPressed()) + chThdSleepMilliseconds(2); /* Be nice to other threads*/ - while(tsPressed()) - chThdSleepMilliseconds(2); /* Be nice to other threads*/ + gdispFillArea(cross[i][0] - 15, cross[i][1] - 15, 42, 42, Blue); + } - gdispFillArea(cross[i][0] - 15, cross[i][1] - 15, 42, 42, Blue); - } + /* Apply 3 point calibration algorithm */ + _tsDo3PointCalibration(cross, points, cal); - /* Apply 3 point calibration algorithm */ - _tsDo3PointCalibration(cross, points, cal); + #if TOUCHSCREEN_VERIFY_CALIBRATION + /* Verification of correctness of calibration (optional) : + * See if the 4th point (Middle of the screen) coincides with the calibrated + * result. If point is with +/- 2 pixel margin, then successful calibration + * Else, start from the beginning. + */ -#if TOUCHSCREEN_VERIFY_CALIBRATION - /* Verification of correctness of calibration (optional) : - * See if the 4th point (Middle of the screen) coincides with the calibrated - * result. If point is with +/- 2 pixel margin, then successful calibration - * Else, start from the beginning. - */ + /* Transform the co-ordinates */ + _tpTransform(&points[3][0], &points[3][1]); - /* Transform the co-ordinates */ - _tpTransform(&points[3][0], &points[3][1]); + /* Calculate the delta */ + px = (points[3][0] - cross[3][0]) * (points[3][0] - cross[3][0]) + + (points[3][1] - cross[3][1]) * (points[3][1] - cross[3][1]); - /* Calculate the delta */ - px = (points[3][0] - cross[3][0]) * (points[3][0] - cross[3][0]) + - (points[3][1] - cross[3][1]) * (points[3][1] - cross[3][1]); + if(px > 4) + goto calibrate; + #endif - if(px > 4) - goto calibrate; -#endif - - /* If enabled, serialize the calibration values for storage */ - #if TOUCHSCREEN_STORE_CALIBRATION - ts_store_calibration_lld(cal); - #endif + /* If enabled, serialize the calibration values for storage */ + #if TOUCHSCREEN_STORE_CALIBRATION + ts_store_calibration_lld(cal); + #endif } #endif /* GFX_USE_TOUCHSCREEN */ From 43a1300f13e56ce666fc0ad0c688da339f058150 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 10 Nov 2012 18:42:32 +0100 Subject: [PATCH 07/10] docs --- releases.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/releases.txt b/releases.txt index be897571..7002405d 100644 --- a/releases.txt +++ b/releases.txt @@ -8,6 +8,7 @@ current stable: 1.4 *** changes after 1.4 *** FEATURE: Added three point calibration FIX: Touchpad renamed into Touchscreen +FIX: tsIRQ() renamed into tsPressed() *** changes after 1.3 *** From b6c5a0882e0deda081dabac39994a18211ca7fb9 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 11 Nov 2012 04:41:59 +0100 Subject: [PATCH 08/10] GWIN doxygen fix --- src/gwin.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/gwin.c b/src/gwin.c index 8d893887..1a19bb1e 100644 --- a/src/gwin.c +++ b/src/gwin.c @@ -125,7 +125,7 @@ void gwinDestroyWindow(GHandle gh) { } } -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Set the current font for this window. * @@ -255,7 +255,7 @@ void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coor gdispBlitAreaEx(gh->x+x, gh->y+y, cx, cy, srcx, srcy, srccx, buffer); } -#if GDISP_NEED_CIRCLE +#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__) /** * @brief Draw a circle in the window. * @note Uses the current foreground color to draw the circle @@ -275,7 +275,7 @@ void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) { } #endif -#if GDISP_NEED_CIRCLE +#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__) /** * @brief Draw a filled circle in the window. * @note Uses the current foreground color to draw the filled circle @@ -295,7 +295,7 @@ void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) { } #endif -#if GDISP_NEED_ELLIPSE +#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__) /** * @brief Draw an ellipse. * @note Uses the current foreground color to draw the ellipse @@ -315,7 +315,7 @@ void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b) { } #endif -#if GDISP_NEED_ELLIPSE +#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__) /** * @brief Draw an filled ellipse. * @note Uses the current foreground color to draw the filled ellipse @@ -335,7 +335,7 @@ void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b) { } #endif -#if GDISP_NEED_ARC +#if GDISP_NEED_ARC || defined(__DOXYGEN__) /* * @brief Draw an arc in the window. * @note Uses the current foreground color to draw the arc @@ -357,7 +357,7 @@ void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t start } #endif -#if GDISP_NEED_ARC +#if GDISP_NEED_ARC || defined(__DOXYGEN__) /* * @brief Draw a filled arc in the window. * @note Uses the current foreground color to draw the filled arc @@ -379,7 +379,7 @@ void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t start } #endif -#if GDISP_NEED_PIXELREAD +#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__) /** * @brief Get the color of a pixel in the window. * @return The color of the pixel. @@ -398,7 +398,7 @@ color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y) { } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text character at the specified position in the window. * @pre The font must have been set. @@ -420,7 +420,7 @@ void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c) { } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text character with a filled background at the specified position in the window. * @pre The font must have been set. @@ -442,7 +442,7 @@ void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c) { } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text string in the window * @pre The font must have been set. @@ -464,7 +464,7 @@ void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str) { } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text string with a filled background in the window * @pre The font must have been set. @@ -486,7 +486,7 @@ void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str) { } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text string verticly centered within the specified box. * @pre The font must have been set. @@ -496,6 +496,7 @@ void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str) { * * @param[in] gh The window handle * @param[in] x,y The position for the text (need to define top-right or base-line - check code) + * @param[in] cx,cy The width and height of the box * @param[in] str The string to draw * @param[in] justify Justify the text left, center or right within the box * @@ -510,7 +511,7 @@ void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, } #endif -#if GDISP_NEED_TEXT +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) /** * @brief Draw a text string verticly centered within the specified filled box. * @pre The font must have been set. @@ -520,6 +521,7 @@ void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, * * @param[in] gh The window handle * @param[in] x,y The position for the text (need to define top-right or base-line - check code) + * @param[in] cx,cy The width and height of the box * @param[in] str The string to draw * @param[in] justify Justify the text left, center or right within the box * @@ -536,7 +538,7 @@ void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, /*------------------------------------------------------------------------------------------------------------------------*/ -#if GWIN_NEED_CONSOLE +#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__) /* * Stream interface implementation. The interface is write only @@ -704,7 +706,7 @@ void gwinPutCharArray(GHandle gh, const char *str, size_t n) { /*------------------------------------------------------------------------------------------------------------------------*/ -#if GWIN_NEED_BUTTON +#if GWIN_NEED_BUTTON || defined(__DOXYGEN__) static const GButtonStyle GButtonDefaultStyle = { GBTN_3D, From f05315e0c068e3761f3dc2d4fe3e55d109901ea6 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 11 Nov 2012 05:11:00 +0100 Subject: [PATCH 09/10] small doxygen fix --- src/gdisp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gdisp.c b/src/gdisp.c index 35d778d3..81c06599 100644 --- a/src/gdisp.c +++ b/src/gdisp.c @@ -321,8 +321,8 @@ * * @param[in] x,y The start position * @param[in] cx,cy The size of the filled area - * @param[in] srcx,srcy I've no idea - * @param[in] srccx Really, I've no fucking idea + * @param[in] srcx,srcy The bitmap position to start the fill form + * @param[in] srccx The width of a line in the bitmap * @param[in] buffer The bitmap in the driver's pixel format * * @api From 44bb28ed9259633d48bb526a681d0e6057c4da86 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 11 Nov 2012 05:31:48 +0100 Subject: [PATCH 10/10] small doxygen fix --- src/gwin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gwin.c b/src/gwin.c index 1a19bb1e..dfc4b1e0 100644 --- a/src/gwin.c +++ b/src/gwin.c @@ -722,7 +722,7 @@ static const GButtonStyle GButtonDefaultStyle = { * @brief Create a button window. * @return NULL if there is no resultant drawing area, otherwise a window handle. * - * @param[in] gb The GConsoleWindow structure to initialise + * @param[in] gb The GConsoleWindow structure to initialise. If this is NULL the structure is dynamically allocated. * @param[in] x,y The screen co-ordinates for the bottom left corner of the window * @param[in] width The width of the window * @param[in] height The height of the window