Merge pull request #2 from Tectu/master

Merge Tectu changes
ugfx_release_2.6
Andrew Hannam 2012-11-11 00:00:23 -08:00
commit e28a4dbd0e
12 changed files with 153 additions and 150 deletions

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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.
*
@ -82,7 +90,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

View File

@ -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
@ -137,7 +129,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

View File

@ -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 ***

View File

@ -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

View File

@ -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,
@ -720,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

View File

@ -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;
}
/*===========================================================================*/
@ -151,15 +151,13 @@ 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
*
* @api
*/
void tsInit(const TouchscreenDriver *ts) {
/* Initialise Mutex */
//MUTEX_INIT
@ -177,6 +175,7 @@ void tsInit(const TouchscreenDriver *ts) {
cal = (struct cal_t*)chHeapAlloc(NULL, sizeof(struct cal_t));
if(cal == NULL)
return;
tsCalibrate();
}
@ -188,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:
@ -206,9 +205,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;
@ -224,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
@ -238,9 +237,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;
}
@ -270,8 +269,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
@ -285,88 +284,94 @@ 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) {
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(!tsIRQ())
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 (tsIRQ()) {
/* We have valid pointer data */
px += _tsReadRealX();
py += _tsReadRealY();
j++;
}
}
points[i][0] = px / j;
points[i][1] = py / j;
j++;
}
}
chThdSleepMilliseconds(100);
points[i][0] = px / j;
points[i][1] = py / j;
while(tsPressed())
chThdSleepMilliseconds(2); /* Be nice to other threads*/
chThdSleepMilliseconds(100);
gdispFillArea(cross[i][0] - 15, cross[i][1] - 15, 42, 42, Blue);
}
while(tsIRQ())
chThdSleepMilliseconds(2); /* Be nice to other threads*/
/* Apply 3 point calibration algorithm */
_tsDo3PointCalibration(cross, points, cal);
gdispFillArea(cross[i][0] - 15, cross[i][1] - 15, 42, 42, Blue);
}
#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.
*/
/* Apply 3 point calibration algorithm */
_tsDo3PointCalibration(cross, points, cal);
/* Transform the co-ordinates */
_tpTransform(&points[3][0], &points[3][1]);
#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.
*/
/* 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]);
/* Transform the co-ordinates */
_tpTransform(&points[3][0], &points[3][1]);
if(px > 4)
goto calibrate;
#endif
/* 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 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 */