commit
e28a4dbd0e
12 changed files with 153 additions and 150 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ***
|
||||
|
|
|
@ -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
|
||||
|
|
36
src/gwin.c
36
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,
|
||||
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -190,7 +189,7 @@ void tsInit(const TouchscreenDriver *ts) {
|
|||
coord_t tsReadX(void) {
|
||||
coord_t x, y;
|
||||
|
||||
#if TOUCHSCREEN_XY_INVERTED == TRUE
|
||||
#if TOUCHSCREEN_XY_INVERTED
|
||||
x = _tsReadRealY();
|
||||
y = _tsReadRealX();
|
||||
#else
|
||||
|
@ -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,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) {
|
||||
|
@ -311,7 +312,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 */
|
||||
|
@ -319,13 +320,17 @@ calibrate:
|
|||
/* Take a little more samples per point and their average
|
||||
* for precise calibration */
|
||||
px = py = 0;
|
||||
|
||||
j = 0;
|
||||
while (j < MAX_CAL_SAMPLES) {
|
||||
if (tsIRQ()) {
|
||||
/* We have valid pointer data */
|
||||
|
||||
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++;
|
||||
}
|
||||
|
@ -336,7 +341,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);
|
||||
|
@ -345,7 +350,7 @@ calibrate:
|
|||
/* Apply 3 point calibration algorithm */
|
||||
_tsDo3PointCalibration(cross, points, cal);
|
||||
|
||||
#if TOUCHSCREEN_VERIFY_CALIBRATION
|
||||
#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
|
||||
|
@ -361,7 +366,7 @@ calibrate:
|
|||
|
||||
if(px > 4)
|
||||
goto calibrate;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If enabled, serialize the calibration values for storage */
|
||||
#if TOUCHSCREEN_STORE_CALIBRATION
|
||||
|
|
Loading…
Add table
Reference in a new issue