input/touchscreen: Translate raw X/Y data into pixel coordinates

This commit is contained in:
Nicolas Caramelli 2023-07-03 10:47:50 +02:00 committed by Alan Carvalho de Assis
parent de5c35382a
commit e82b762fb7
3 changed files with 60 additions and 0 deletions

View File

@ -415,6 +415,22 @@ config STMPE811_SWAPXY
---help---
Reverse the meaning of X and Y to handle different LCD orientations.
config STMPE811_OFFSETX
int "X offset"
default 0
depends on !STMPE811_TSC_DISABLE
---help---
Horizontal offset between the left edge of the touchscreen and
the left edge of the display area.
config STMPE811_OFFSETY
int "Y offset"
default 0
depends on !STMPE811_TSC_DISABLE
---help---
Vertical offset between the top edge of the touchscreen and
the top edge of the display area.
config STMPE811_THRESHX
int "X threshold"
default 12

View File

@ -573,6 +573,38 @@ static int stmpe811_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break;
case TSIOC_GETOFFSETX: /* arg: Pointer to int offsetx config value */
{
FAR int *ptr = (FAR int *)((uintptr_t)arg);
DEBUGASSERT(ptr != NULL);
*ptr = CONFIG_STMPE811_OFFSETX;
}
break;
case TSIOC_GETOFFSETY: /* arg: Pointer to int offsety config value */
{
FAR int *ptr = (FAR int *)((uintptr_t)arg);
DEBUGASSERT(ptr != NULL);
*ptr = CONFIG_STMPE811_OFFSETY;
}
break;
case TSIOC_GETTHRESHX: /* arg: Pointer to int threshx config value */
{
FAR int *ptr = (FAR int *)((uintptr_t)arg);
DEBUGASSERT(ptr != NULL);
*ptr = CONFIG_STMPE811_THRESHX;
}
break;
case TSIOC_GETTHRESHY: /* arg: Pointer to int threshy config value */
{
FAR int *ptr = (FAR int *)((uintptr_t)arg);
DEBUGASSERT(ptr != NULL);
*ptr = CONFIG_STMPE811_THRESHY;
}
break;
default:
ret = -ENOTTY;
break;

View File

@ -76,6 +76,18 @@
* struct g_tscaldata_s
*/
#define TSIOC_USESCALED _TSIOC(0x0009) /* arg: bool, yes/no */
#define TSIOC_GETOFFSETX _TSIOC(0x000a) /* arg: Pointer to
* int X offset value
*/
#define TSIOC_GETOFFSETY _TSIOC(0x000b) /* arg: Pointer to
* int Y offset value
*/
#define TSIOC_GETTHRESHX _TSIOC(0x000c) /* arg: Pointer to
* int X threshold value
*/
#define TSIOC_GETTHRESHY _TSIOC(0x000d) /* arg: Pointer to
* int Y threshold value
*/
#define TSC_FIRST 0x0001 /* First common command */
#define TSC_NCMDS 6 /* Six common commands */