mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
drivers/input/ft5x06.c: Fix a problem was was causing missing reports when the touch ends.
This commit is contained in:
@@ -68,14 +68,10 @@ STATUS
|
|||||||
based poll instead of interrupts. This is very inefficient in that it
|
based poll instead of interrupts. This is very inefficient in that it
|
||||||
will introduce delays in touchscreen response and will consume more CPU
|
will introduce delays in touchscreen response and will consume more CPU
|
||||||
bandwidth. The driver appears to be functional. Added the nxwm
|
bandwidth. The driver appears to be functional. Added the nxwm
|
||||||
configuration to do some integrated testing. It does not yet work and
|
configuration to do some integrated testing. NxWM seems to be fully
|
||||||
I have not yet looked into the cause of the problem:
|
functional. However, the action of the touchscreen could use some
|
||||||
|
human factors improvements. I imagine that this is a consequence of
|
||||||
Initialize the NSH library
|
the polled solution.
|
||||||
createTaskbar: Create CTaskbar instance
|
|
||||||
createTaskbar: Connect CTaskbar instance to the NX server
|
|
||||||
createTaskbar: ERROR: Failed to connect CTaskbar instance to the NX server
|
|
||||||
nxwm_main: ERROR: Failed to create the task bar
|
|
||||||
|
|
||||||
Configurations
|
Configurations
|
||||||
==============
|
==============
|
||||||
|
|||||||
+33
-16
@@ -212,7 +212,7 @@ static const struct file_operations ft5x06_fops =
|
|||||||
static const uint8_t g_event_map[4] =
|
static const uint8_t g_event_map[4] =
|
||||||
{
|
{
|
||||||
(TOUCH_DOWN | TOUCH_ID_VALID | TOUCH_POS_VALID), /* FT5x06_DOWN */
|
(TOUCH_DOWN | TOUCH_ID_VALID | TOUCH_POS_VALID), /* FT5x06_DOWN */
|
||||||
(TOUCH_UP | TOUCH_ID_VALID | TOUCH_POS_VALID), /* FT5x06_UP */
|
(TOUCH_UP | TOUCH_ID_VALID), /* FT5x06_UP */
|
||||||
(TOUCH_MOVE | TOUCH_ID_VALID | TOUCH_POS_VALID), /* FT5x06_CONTACT */
|
(TOUCH_MOVE | TOUCH_ID_VALID | TOUCH_POS_VALID), /* FT5x06_CONTACT */
|
||||||
TOUCH_ID_VALID /* FT5x06_INVALID */
|
TOUCH_ID_VALID /* FT5x06_INVALID */
|
||||||
};
|
};
|
||||||
@@ -321,7 +321,9 @@ static void ft5x06_data_worker(FAR void *arg)
|
|||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* In polled mode, we may read invalid touch data. If there is
|
/* In polled mode, we may read invalid touch data. If there is
|
||||||
* no touch data, the FT5x06 returns all 0xff.
|
* no touch data, the FT5x06 returns all 0xff the very first time.
|
||||||
|
* After that, it returns the same old stale data when there is
|
||||||
|
* no touch data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sample = (FAR struct ft5x06_touch_data_s *)priv->touchbuf;
|
sample = (FAR struct ft5x06_touch_data_s *)priv->touchbuf;
|
||||||
@@ -347,7 +349,9 @@ static void ft5x06_data_worker(FAR void *arg)
|
|||||||
}
|
}
|
||||||
else if (priv->delay < POLL_MAXDELAY)
|
else if (priv->delay < POLL_MAXDELAY)
|
||||||
{
|
{
|
||||||
/* Let it rise gradually to the maximum if there is no touch */
|
/* Otherwise, let the poll rate rise gradually up to the maximum
|
||||||
|
* if there is no touch.
|
||||||
|
*/
|
||||||
|
|
||||||
priv->delay += POLL_INCREMENT;
|
priv->delay += POLL_INCREMENT;
|
||||||
}
|
}
|
||||||
@@ -467,17 +471,10 @@ static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
|||||||
/* Raw data pointers (source) */
|
/* Raw data pointers (source) */
|
||||||
|
|
||||||
raw = (FAR struct ft5x06_touch_data_s *)priv->touchbuf;
|
raw = (FAR struct ft5x06_touch_data_s *)priv->touchbuf;
|
||||||
|
touch = raw->touch;
|
||||||
if (raw->tdstatus != 1)
|
|
||||||
{
|
|
||||||
priv->valid = false;
|
|
||||||
return 0; /* No touches read. */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the reported X and Y positions */
|
/* Get the reported X and Y positions */
|
||||||
|
|
||||||
touch = raw->touch;
|
|
||||||
|
|
||||||
#ifdef CONFIG_FT5X06_SWAPXY
|
#ifdef CONFIG_FT5X06_SWAPXY
|
||||||
y = TOUCH_POINT_GET_X(touch[0]);
|
y = TOUCH_POINT_GET_X(touch[0]);
|
||||||
x = TOUCH_POINT_GET_Y(touch[0]);
|
x = TOUCH_POINT_GET_Y(touch[0]);
|
||||||
@@ -491,14 +488,28 @@ static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
|||||||
event = TOUCH_POINT_GET_EVENT(touch[0]);
|
event = TOUCH_POINT_GET_EVENT(touch[0]);
|
||||||
id = TOUCH_POINT_GET_ID(touch[0]);
|
id = TOUCH_POINT_GET_ID(touch[0]);
|
||||||
|
|
||||||
|
if (event == FT5x06_INVALID)
|
||||||
|
{
|
||||||
|
priv->lastevent = FT5x06_INVALID;
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
if (id == priv->lastid && event == priv->lastevent)
|
if (id == priv->lastid && event == priv->lastevent)
|
||||||
|
{
|
||||||
|
/* Same ID and event.. Is there positional data? */
|
||||||
|
|
||||||
|
if (raw->tdstatus == 0 || event == FT5x06_UP)
|
||||||
|
{
|
||||||
|
/* No... no new touch data */
|
||||||
|
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int16_t deltax;
|
int16_t deltax;
|
||||||
int16_t deltay;
|
int16_t deltay;
|
||||||
|
|
||||||
/* Same ID and event.. Compare the change in position from the last
|
/* Compare the change in position from the last report. */
|
||||||
* report.
|
|
||||||
*/
|
|
||||||
|
|
||||||
deltax = (x - priv->lastx);
|
deltax = (x - priv->lastx);
|
||||||
if (deltax < 0)
|
if (deltax < 0)
|
||||||
@@ -520,8 +531,8 @@ static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
|||||||
{
|
{
|
||||||
/* Ignore... no significant change in Y either */
|
/* Ignore... no significant change in Y either */
|
||||||
|
|
||||||
priv->valid = false;
|
goto drop;
|
||||||
return 0; /* No new touches read. */
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,6 +562,12 @@ static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
|||||||
|
|
||||||
priv->valid = false;
|
priv->valid = false;
|
||||||
return SIZEOF_TOUCH_SAMPLE_S(1);
|
return SIZEOF_TOUCH_SAMPLE_S(1);
|
||||||
|
|
||||||
|
drop:
|
||||||
|
priv->lastx = 0;
|
||||||
|
priv->lasty = 0;
|
||||||
|
priv->valid = false;
|
||||||
|
return 0; /* No new touches read. */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
static ssize_t ft5x06_sample(FAR struct ft5x06_dev_s *priv, FAR char *buffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user