Commit 0bd6f714 authored by Imre Deak's avatar Imre Deak Committed by Juha Yrjola

ads7846: filtering based on pressure value

Limit the pressure value to the maximum specified in the board-
specific file. Samples with pressure values beyond the maximum are
considered non-reliable. Report the previously measured X and Y
values samples instead of the non-reliable ones.
Signed-off-by: default avatarImre Deak <imre.deak@nokia.com>
Signed-off-by: default avatarJuha Yrjola <juha.yrjola@nokia.com>
parent af573a5b
...@@ -80,10 +80,14 @@ struct ads7846 { ...@@ -80,10 +80,14 @@ struct ads7846 {
u16 model; u16 model;
u16 vref_delay_usecs; u16 vref_delay_usecs;
u16 x_plate_ohms; u16 x_plate_ohms;
u16 pressure_max;
u8 read_x, read_y, read_z1, read_z2, pwrdown; u8 read_x, read_y, read_z1, read_z2, pwrdown;
u16 dummy; /* for the pwrdown read */ u16 dummy; /* for the pwrdown read */
struct ts_event tc; struct ts_event tc;
u16 last_x;
u16 last_y;
u16 last_pressure;
struct spi_transfer xfer[10]; struct spi_transfer xfer[10];
struct spi_message msg[5]; struct spi_message msg[5];
...@@ -344,6 +348,18 @@ static void ads7846_rx(void *ads) ...@@ -344,6 +348,18 @@ static void ads7846_rx(void *ads)
} else } else
Rt = 0; Rt = 0;
if (Rt > ts->pressure_max) {
if (ts->last_pressure) {
x = ts->last_x;
y = ts->last_y;
}
Rt = ts->pressure_max;
}
ts->last_x = x;
ts->last_y = y;
ts->last_pressure = Rt;
/* NOTE: "pendown" is inferred from pressure; we don't rely on /* NOTE: "pendown" is inferred from pressure; we don't rely on
* being able to check nPENIRQ status, or "friendly" trigger modes * being able to check nPENIRQ status, or "friendly" trigger modes
* (both-edges is much better than just-falling or low-level). * (both-edges is much better than just-falling or low-level).
...@@ -593,6 +609,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) ...@@ -593,6 +609,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
ts->model = pdata->model ? : 7846; ts->model = pdata->model ? : 7846;
ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
ts->pressure_max = pdata->pressure_max ? : ~0;
ts->debounce_max = pdata->debounce_max ? : 1; ts->debounce_max = pdata->debounce_max ? : 1;
ts->debounce_tol = pdata->debounce_tol ? : 10; ts->debounce_tol = pdata->debounce_tol ? : 10;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment