From 82dbef4c8d961f5bb3f95667a2c8fe0ddfd6ba22 Mon Sep 17 00:00:00 2001 From: Tectu Date: Wed, 8 Aug 2012 23:41:18 +0200 Subject: [PATCH 01/10] added touchpad XPT2046 driver dummy --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 269 ++---------------- .../touchpadXPT2046/touchpad_lld_config.h | 4 +- 2 files changed, 26 insertions(+), 247 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 44431e30..f3211633 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -28,9 +28,9 @@ #include "ch.h" #include "hal.h" -#include "gdisp.h" +#include "touchpad.h" -#if HAL_USE_GDISP || defined(__DOXYGEN__) +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver local definitions. */ @@ -50,7 +50,7 @@ /*===========================================================================*/ #if !defined(__DOXYGEN__) - GDISPDriver GDISP; + TOUCHPADDriver TOUCHPAD; #endif /*===========================================================================*/ @@ -70,267 +70,48 @@ /*===========================================================================*/ /* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ /** * @brief Low level GDISP driver initialization. * * @notapi */ -void gdisp_lld_init(void) { - /* Initialise the GDISP structure */ - GDISP.Width = 128; - GDISP.Height = 128; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOff; +void touchpad_lld_init(void) { + /* Initialise the TOUCHPAD structure */ } /** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel + * @brief Reads out the X direction. * * @notapi */ -void gdisp_lld_drawpixel(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { +uint16_t touchpad_lld_read_x(void) { + /* ToDo */ + return 0; +} + +/* + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t touchpad_lld_read_y(void) { + /* ToDo */ + return 0; } /* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If gdisp_lld_fillarea() is defined there is little - point in defining gdisp_lld_clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - gdisp_lld_fillarea() and gdisp_lld_blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel +#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) + /* + * @brief Reads out the Z direction / pressure. * * @notapi */ - void gdisp_lld_clear(color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void gdisp_lld_drawline(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void gdisp_lld_fillarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void gdisp_lld_blitarea(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), pixel_t *UNUSED(buffer)) { - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_drawcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void gdisp_lld_fillcircle(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_drawellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void gdisp_lld_fillellipse(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void gdisp_lld_drawchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void gdisp_lld_fillchar(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t gdisp_lld_getpixelcolor(coord_t UNUSED(x), coord_t UNUSED(y)) { + uint16_t toucpad_lld_read_y(void) { + /* ToDo */ return 0; } #endif -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void gdisp_lld_verticalscroll(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void gdisp_lld_control(int UNUSED(what), void *UNUSED(value)) { - } -#endif - -#endif /* HAL_USE_GDISP */ +#endif /* HAL_USE_TOUCHPAD */ /** @} */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 675d997a..6c491e27 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,9 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHPAD_X_DIRECTION TRUE -#define TOUCHPAD_Y_DIRECTION TRUE -#define TOUCHPAD_Z_DIRECTION TRUE /* pressure measurement */ +#define TOUCHPAD_PRESSURE_DIRECTION TRUE #endif /* HAL_USE_TOUCHPAD */ From 308184ead1c6071a739c7a233287a4c0412ca817 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 00:43:52 +0200 Subject: [PATCH 02/10] some more touchpad stuff --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 15 +++++++++------ .../touchpadXPT2046/touchpad_lld_config.h | 2 +- halext/halext.mk | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index f3211633..2f280169 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -50,7 +50,7 @@ /*===========================================================================*/ #if !defined(__DOXYGEN__) - TOUCHPADDriver TOUCHPAD; + TOUCHPADDriver Touchpad; #endif /*===========================================================================*/ @@ -72,12 +72,15 @@ /* ---- Required Routines ---- */ /** - * @brief Low level GDISP driver initialization. + * @brief Low level Touchpad driver initialization. * * @notapi */ -void touchpad_lld_init(void) { +void tp_lld_init(TOUCHPADDriver *tp) { /* Initialise the TOUCHPAD structure */ + + /* ToDo */ + (void)tp; } /** @@ -85,7 +88,7 @@ void touchpad_lld_init(void) { * * @notapi */ -uint16_t touchpad_lld_read_x(void) { +uint16_t tp_lld_read_x(void) { /* ToDo */ return 0; } @@ -95,7 +98,7 @@ uint16_t touchpad_lld_read_x(void) { * * @notapi */ -uint16_t touchpad_lld_read_y(void) { +uint16_t tp_lld_read_y(void) { /* ToDo */ return 0; } @@ -107,7 +110,7 @@ uint16_t touchpad_lld_read_y(void) { * * @notapi */ - uint16_t toucpad_lld_read_y(void) { + uint16_t tp_lld_read_y(void) { /* ToDo */ return 0; } diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 6c491e27..52493836 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,7 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHPAD_PRESSURE_DIRECTION TRUE +#define TOUCHPAD_PRESSURE TRUE #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/halext.mk b/halext/halext.mk index 5afb24b0..80ddf666 100644 --- a/halext/halext.mk +++ b/halext/halext.mk @@ -3,7 +3,8 @@ HALSRC += $(LCDLIB)/halext/src/gdisp.c \ $(LCDLIB)/halext/src/gdisp_fonts.c \ - $(LCDLIB)/halext/src/gdisp_emulation.c + $(LCDLIB)/halext/src/gdisp_emulation.c \ + $(LCDLIB)/halext/src/touchpad.c # Required include directories HALINC += $(LCDLIB)/halext/include From ebcc53e8e7e124d3e96af95c9f64b4be79cbcae1 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 00:44:12 +0200 Subject: [PATCH 03/10] some more touchpad stuff --- halext/include/touchpad.h | 86 ++++++++++++++++++++++ halext/include/touchpad_lld.h | 88 +++++++++++++++++++++++ halext/src/touchpad.c | 130 ++++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 halext/include/touchpad.h create mode 100644 halext/include/touchpad_lld.h create mode 100644 halext/src/touchpad.c diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h new file mode 100644 index 00000000..bf17edf0 --- /dev/null +++ b/halext/include/touchpad.h @@ -0,0 +1,86 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad.h + * @brief TOUCHPAD Touchpad Driver subsystem header file. + * + * @addgroup TOUCHPAD + * @{ + */ +#ifndef _TOUCHPAD_H +#define _TOUCHPAD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Low Level Driver details and error checks. */ +/*===========================================================================*/ + +/* Include the low level driver information */ +#include "touchpad_lld.h" + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#if TOUCHPAD_NEED_MULTITHREAD + + void tpInit(TOUCHPADDriver *tp); + uint16_t tpReadX(void); + uint16_t tpReadY(void); + +#else + + #define tpInit(tp) tp_lld_init(tp) + #define tpReadX() tp_lld_read_x() + #define tpReadY() tp_lld_read_y() + +#endif + + + +#if TOUCHPAD_PRESSURE + + uint16_t tpReadZ(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_H */ +/** @} */ + diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h new file mode 100644 index 00000000..e659803c --- /dev/null +++ b/halext/include/touchpad_lld.h @@ -0,0 +1,88 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad_lld.h + * @brief TOUCHPAD Driver subsystem low level driver header. + * + * @addgroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_H +#define _TOUCHPAD_LLD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Include the low level driver configuration information */ +/*===========================================================================*/ + +#include "gdisp_lld_config.h" + +/*===========================================================================*/ +/* Error checks. */ +/*===========================================================================*/ + +#ifndef TOUCHPAD_PRESSURE + #define TOUCHPAD_PRESSURE FALSE +#endif + +/*===========================================================================*/ +/* Driver types. */ +/*===========================================================================*/ + +/** + * @brief Structure representing a Touchpad driver. + */ +struct TOUCHPADDriver { + /* ToDo */ +}; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + extern TOUCHPADDriver Touchpad; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* Core functions */ + void tp_lld_init(void); + uint16_t tp_lld_read_x(void); + uint16_t tp_lld_read_y(void); + + #if TOUCHPAD_PRESSURE + uint16_t tp_lld_read_z(void); + #endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_H */ +/** @} */ + diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c new file mode 100644 index 00000000..69d47f42 --- /dev/null +++ b/halext/src/touchpad.c @@ -0,0 +1,130 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad.c + * @brief Touchpad Driver code. + * + * @addgroup TOUCHPAD + * @{ + */ +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +#if GDISP_NEED_MULTITHREAD + #warning "GDISP: Multithread support not complete" + #define MUTEX_INIT /* Not defined yet */ + #define MUTEX_ENTER /* Not defined yet */ + #define MUTEX_EXIT /* Not defined yet */ +#endif + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Touchpad Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @init + */ + void tpInit(TOUCHPADDriver * UNUSED(tp)) { + /* Initialise Mutex */ + MUTEX_INIT + + /* Initialise driver */ + MUTEX_ENTER + tp_lld_init(tp); + MUTEX_EXIT + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The X position in pixels. + * + * @api + */ + uint16_t tpReadX(void) { + return (tp_lld_read_x()); + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The Y position in pixels. + * + * @api + */ + uint16_t tpReadY(void) { + return (tp_lld_read_y()); + } +#endif + +#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Get the pressure. + * + * @return The pressure. + * + * @api + */ + uint16_t tpReadZ(void) { + return (tp_lld_read_z()); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + From ed29707da6ba034db1fe7fbf11abe98f530b3647 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:00:09 +0200 Subject: [PATCH 04/10] fixed a few TOUCHPAD_MULTITHREAD stuffs --- halext/include/touchpad.h | 15 ++++++++++----- halext/include/touchpad_lld.h | 4 +++- halext/src/touchpad.c | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index bf17edf0..5991b6ae 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -59,22 +59,27 @@ extern "C" { uint16_t tpReadX(void); uint16_t tpReadY(void); + #if TOUCHPAD_PRESSURE + + uint16_t tpReadZ(void); + + #endif + #else #define tpInit(tp) tp_lld_init(tp) #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() -#endif + #if TOUCHPAD_PRESSURE + #define tpReadZ() tp_lld_read_z() - -#if TOUCHPAD_PRESSURE - - uint16_t tpReadZ(void); + #endif #endif + #ifdef __cplusplus } #endif diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index e659803c..ccff7d4d 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -35,7 +35,7 @@ /* Include the low level driver configuration information */ /*===========================================================================*/ -#include "gdisp_lld_config.h" +#include "touchpad_lld_config.h" /*===========================================================================*/ /* Error checks. */ @@ -49,6 +49,8 @@ /* Driver types. */ /*===========================================================================*/ +typedef struct TOUCHPADDriver TOUCHPADDriver; + /** * @brief Structure representing a Touchpad driver. */ diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 69d47f42..29ff9eb5 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -32,7 +32,7 @@ #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) #if GDISP_NEED_MULTITHREAD - #warning "GDISP: Multithread support not complete" + #warning "TOUCHPAD: Multithread support not complete" #define MUTEX_INIT /* Not defined yet */ #define MUTEX_ENTER /* Not defined yet */ #define MUTEX_EXIT /* Not defined yet */ From 384529af26a27ef7500b4ff97fbcd85e50385f7b Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:07:04 +0200 Subject: [PATCH 05/10] a few more touchpad things --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 2 + .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 2f280169..03f04203 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -61,6 +61,8 @@ /* Driver local functions. */ /*===========================================================================*/ +#include "xpt2046_lld.c.h" + /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h new file mode 100644 index 00000000..2e891684 --- /dev/null +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -0,0 +1,40 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _XPT2046_H +#define _XPT2046_H + +void tp_lld_init(TOUCHPADDriver *tp) { + +} + +uint16_t tp_lld_read_x(void) { + return 42; +} + +uint16_t tp_lld_read_y(void) { + return 42; +} + +uint16_t tp_lld_read_z(void) { + return 42; +} + +#endif /* _XPT2046_H */ From 640b7473935bea33102187a2833dae940b345576 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:20:15 +0200 Subject: [PATCH 06/10] more touchpad stuff --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 14 +++++++------- halext/include/touchpad.h | 2 +- halext/readme.txt | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 03f04203..8a2de34e 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -19,10 +19,10 @@ */ /** - * @file gdispTestStub/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source (stub). + * @file touchpadXPT2046/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. * - * @addtogroup GDISP + * @addtogroup TOUCHPAD * @{ */ @@ -78,7 +78,7 @@ * * @notapi */ -void tp_lld_init(TOUCHPADDriver *tp) { +void tp_lld_init(void) { /* Initialise the TOUCHPAD structure */ /* ToDo */ @@ -92,7 +92,7 @@ void tp_lld_init(TOUCHPADDriver *tp) { */ uint16_t tp_lld_read_x(void) { /* ToDo */ - return 0; + return 42; } /* @@ -102,7 +102,7 @@ uint16_t tp_lld_read_x(void) { */ uint16_t tp_lld_read_y(void) { /* ToDo */ - return 0; + return 42; } /* ---- Optional Routines ---- */ @@ -114,7 +114,7 @@ uint16_t tp_lld_read_y(void) { */ uint16_t tp_lld_read_y(void) { /* ToDo */ - return 0; + return 42; } #endif diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 5991b6ae..12b462fd 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -67,7 +67,7 @@ extern "C" { #else - #define tpInit(tp) tp_lld_init(tp) + #define tpInit(tp) tp_lld_init() #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() diff --git a/halext/readme.txt b/halext/readme.txt index 5983635a..1123e827 100644 --- a/halext/readme.txt +++ b/halext/readme.txt @@ -6,14 +6,14 @@ To include any of these functions/drivers in your project... include $(LCDLIB)/lcd.mk 3/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk 4/ In your project halconf.h turn on the support you want eg. /** - * @brief Enables the GDISP subsystem. + * @brief Enables the Touchpad subsystem. */ - #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) - #define HAL_USE_GDISP TRUE + #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) + #define HAL_USE_TOUCHPAD TRUE #endif 5/ Do a make clean. From 79c053567816521b601e44981bf3af5b0e40f752 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 01:31:24 +0200 Subject: [PATCH 07/10] more touchpad stuff --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk | 2 +- halext/src/touchpad.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk index e97deff8..9409795b 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HLSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c # Required include directories HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046 diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 29ff9eb5..f65ca0cd 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -77,12 +77,12 @@ */ void tpInit(TOUCHPADDriver * UNUSED(tp)) { /* Initialise Mutex */ - MUTEX_INIT + //MUTEX_INIT /* Initialise driver */ - MUTEX_ENTER - tp_lld_init(tp); - MUTEX_EXIT + //MUTEX_ENTER + tp_lld_init(); + //MUTEX_EXIT } #endif From 19bb3b15dd368b019cdab1b12565156b84f9d32a Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:03:26 +0200 Subject: [PATCH 08/10] tpInit() --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 16 ++++--- .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 46 +++++++++++++++---- halext/include/touchpad.h | 6 +-- halext/include/touchpad_lld.h | 8 +++- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 8a2de34e..4dc29dbe 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -56,6 +56,12 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ +static const SPIConfig spicfg = { + NULL, + TP_CS_PORT, + TP_CS, + SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; /*===========================================================================*/ /* Driver local functions. */ @@ -78,11 +84,8 @@ * * @notapi */ -void tp_lld_init(void) { - /* Initialise the TOUCHPAD structure */ - - /* ToDo */ - (void)tp; +void tp_lld_init(TOUCHPADDriver *tp) { + spiStart(tp->spid, &spicfg); } /** @@ -112,7 +115,7 @@ uint16_t tp_lld_read_y(void) { * * @notapi */ - uint16_t tp_lld_read_y(void) { + uint16_t tp_lld_read_z(void) { /* ToDo */ return 42; } @@ -120,3 +123,4 @@ uint16_t tp_lld_read_y(void) { #endif /* HAL_USE_TOUCHPAD */ /** @} */ + diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h index 2e891684..97adc1ad 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -21,20 +21,50 @@ #ifndef _XPT2046_H #define _XPT2046_H -void tp_lld_init(TOUCHPADDriver *tp) { +#include "ch.h" +#include "hal.h" +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +__inline uint16_t lld_tpReadX(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t x; + + txbuf[0] = 0xd0; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + x = rxbuf[0] << 4; + x |= rxbuf[1] >> 4; + + return x; } -uint16_t tp_lld_read_x(void) { - return 42; +__inline uint16_t lld_tpReadY(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; } -uint16_t tp_lld_read_y(void) { - return 42; +__inline uint16_t lld_tpReadZ(void) { + return 0; } -uint16_t tp_lld_read_z(void) { - return 42; -} #endif /* _XPT2046_H */ + diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 12b462fd..c6e44b55 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -60,21 +60,17 @@ extern "C" { uint16_t tpReadY(void); #if TOUCHPAD_PRESSURE - uint16_t tpReadZ(void); - #endif #else - #define tpInit(tp) tp_lld_init() + #define tpInit(tp) tp_lld_init(tp) #define tpReadX() tp_lld_read_x() #define tpReadY() tp_lld_read_y() #if TOUCHPAD_PRESSURE - #define tpReadZ() tp_lld_read_z() - #endif #endif diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index ccff7d4d..ab2e54d6 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -55,7 +55,11 @@ typedef struct TOUCHPADDriver TOUCHPADDriver; * @brief Structure representing a Touchpad driver. */ struct TOUCHPADDriver { - /* ToDo */ + /* + * @brief Pointer to SPI driver. + * @note SPI driver must be enabled in mcu- and halconf.h + */ + SPIDriver *spid; }; /*===========================================================================*/ @@ -71,7 +75,7 @@ extern "C" { #endif /* Core functions */ - void tp_lld_init(void); + void tp_lld_init(TOUCHPADDriver *tp); uint16_t tp_lld_read_x(void); uint16_t tp_lld_read_y(void); From 4c3e1847dede93bf3f1671a00e86c57c0c1387ac Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:22:10 +0200 Subject: [PATCH 09/10] removed TOUCHPAD_NEED_MULTITASKING --- .../touchpad/touchpadXPT2046/xpt2046_lld.c.h | 2 + halext/include/touchpad.h | 35 +++--- halext/src/touchpad.c | 105 ++++++++++-------- 3 files changed, 73 insertions(+), 69 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h index 97adc1ad..2b33034a 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h +++ b/halext/drivers/touchpad/touchpadXPT2046/xpt2046_lld.c.h @@ -62,6 +62,8 @@ __inline uint16_t lld_tpReadY(void) { } __inline uint16_t lld_tpReadZ(void) { + /* ToDo */ + return 0; } diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index c6e44b55..222411cf 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -45,6 +45,16 @@ /* Type definitions */ /*===========================================================================*/ +/** + * @brief Struct used for calibration + */ +struct cal { + float xm; + float ym; + float xn; + float yn; +}; + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -53,29 +63,14 @@ extern "C" { #endif -#if TOUCHPAD_NEED_MULTITHREAD - - void tpInit(TOUCHPADDriver *tp); - uint16_t tpReadX(void); - uint16_t tpReadY(void); - - #if TOUCHPAD_PRESSURE - uint16_t tpReadZ(void); - #endif - -#else - - #define tpInit(tp) tp_lld_init(tp) - #define tpReadX() tp_lld_read_x() - #define tpReadY() tp_lld_read_y() - - #if TOUCHPAD_PRESSURE - #define tpReadZ() tp_lld_read_z() - #endif +void tpInit(TOUCHPADDriver *tp); +uint16_t tpReadX(void); +uint16_t tpReadY(void); +#if TOUCHPAD_PRESSURE + uint16_t tpReadZ(void); #endif - #ifdef __cplusplus } #endif diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index f65ca0cd..4adb25fe 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -27,17 +27,11 @@ */ #include "ch.h" #include "hal.h" +#include "gdisp.h" #include "touchpad.h" #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) -#if GDISP_NEED_MULTITHREAD - #warning "TOUCHPAD: Multithread support not complete" - #define MUTEX_INIT /* Not defined yet */ - #define MUTEX_ENTER /* Not defined yet */ - #define MUTEX_EXIT /* Not defined yet */ -#endif - /*===========================================================================*/ /* Driver local definitions. */ /*===========================================================================*/ @@ -58,6 +52,9 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ +volatile static struct cal cal = { + 1, 1, 0, 0 +}; /*===========================================================================*/ /* Driver local functions. */ @@ -67,52 +64,62 @@ /* Driver exported functions. */ /*===========================================================================*/ -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Touchpad Driver initialization. - * @note This function is NOT currently implicitly invoked by @p halInit(). - * It must be called manually. - * - * @init - */ - void tpInit(TOUCHPADDriver * UNUSED(tp)) { - /* Initialise Mutex */ - //MUTEX_INIT +/** + * @brief Touchpad Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @init + */ +void tpInit(TOUCHPADDriver *tp) { + /* Initialise Mutex */ + //MUTEX_INIT - /* Initialise driver */ - //MUTEX_ENTER - tp_lld_init(); - //MUTEX_EXIT - } -#endif + /* Initialise driver */ + //MUTEX_ENTER + tp_lld_init(tp); + //MUTEX_EXIT +} -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The X position in pixels. - * - * @api - */ - uint16_t tpReadX(void) { - return (tp_lld_read_x()); - } -#endif +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The X position in pixels. + * + * @api + */ +uint16_t tpReadX(void) { + uint16_t x, y; -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The Y position in pixels. - * - * @api - */ - uint16_t tpReadY(void) { - return (tp_lld_read_y()); - } -#endif + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; -#if TOUCHPAD_NEED_MULTITHREAD || defined(__DOXYGEN__) + //switch(gdispGetOrientation()) { + switch(portrait) { // implement gdispGetOrientation() + case portrait: + return x; + case landscape: + return SCREEN_HEIGHT - y; + case portraitInv: + return SCREEN_WIDTH - x; + case landscapeInv: + return y; + } + return x; +} + +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The Y position in pixels. + * + * @api + */ +uint16_t tpReadY(void) { + return (tp_lld_read_y()); +} + +#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) /** * @brief Get the pressure. * From 55c8323950397d7bb6829f9fbd1a50a61d4913ce Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 02:31:42 +0200 Subject: [PATCH 10/10] more touchpad stuff --- halext/include/touchpad.h | 7 +++++ halext/src/touchpad.c | 61 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 222411cf..21e71a97 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -30,6 +30,13 @@ #if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) +/** + * @brief specifies how many conversions are made for a readout. + * + * @note higher is more accurate, but takes more time + */ +#define CONVERSIONS 3 + /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 4adb25fe..912e2256 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -60,6 +60,44 @@ volatile static struct cal cal = { /* Driver local functions. */ /*===========================================================================*/ +/** + * @brief returns the uncalibrated readout of the X direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealX(void) { + uint32_t results = 0; + uint16_t i, x; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_x(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_x(); + } + + x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); + + return x; +} + +/** + * @brief return the uncalibrated readout of the Y-direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealY(void) { + uint32_t results = 0; + uint16_t i, y; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_y(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_y(); + } + + y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); + + return y; +} + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ @@ -105,7 +143,8 @@ uint16_t tpReadX(void) { case landscapeInv: return y; } - return x; + + return x; } /** @@ -116,7 +155,24 @@ uint16_t tpReadX(void) { * @api */ uint16_t tpReadY(void) { - return (tp_lld_read_y()); + uint16_t x, y; + + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; + + //switch(gdispGetOrientation()) { + switch(portrait) { // implement gdispGetOrientation() + case portrait: + return y; + case landscape: + return x; + case portraitInv: + return SCREEN_HEIGHT - y; + case landscapeInv: + return SCREEN_WIDTH - x; + } + + return y; } #if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) @@ -128,6 +184,7 @@ uint16_t tpReadY(void) { * @api */ uint16_t tpReadZ(void) { + /* ToDo */ return (tp_lld_read_z()); } #endif