touchscreen sampling

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at
Thu Jun 19 02:03:28 CEST 2008

On 19.06.2008 01:14, Andy Green wrote:
> Somebody in the thread at some point said:
> | On 18.06.2008 22:46, Dale Schumacher wrote:
> |> The averaging scheme seems overly complicated.  Using a "median"
> instead of
> |> a "mean" (average) would automatically reject outliers and would also
> track
> |> the mid-point of a moving signal.  There should also be less math
> involved
> |> since you would only be sorting 2 sets of 32 values.
> | Exactly what I suggested as well. I don't understand why people
> | absolutely want to use averages and throw away outliers based on average
> | calculations. Maybe because the concept of "mean" is easier to grasp
> | than the concept of "median". A median solves all these problems of data
> | having outliers with less math and better accuracy.
> It's not a bad idea at all.  You're quite right it "automatically
> rejects outliers".  But, it's going to get a bit slow as the number of
> samples held in whatever the sorting structure is increases,

The secret is to keep the number of samples exactly at 5. You remove the
oldest sample (~2.5 reads, ~2.5 moves), insert the new sample (~2 reads,
~2 moves), pick the median (1 read). Done. Using larger sets of samples
is possible, but unless you expect more than 40% wrong samples in the
same direction per set of 5 samples, 5 samples are good enough.

> and I doubt an efficient implementation will be less "complicated"...

The suggestion above should result in a reasonably efficient
implementation with probably less than 15 readable lines of code.

> but if someone wants to send patches I'll be happy to be wrong.

As I indicated before, I won't have time in the next 3 weeks, but if
there is something to be done afterwards, why not? I lack the hardware
to test, though, so I can only send untested patches.


More information about the openmoko-kernel mailing list