fh
Hello all,
are there any examples / references available for simply convert trackpad based touch events (x coordinates / y coordinates / z) to a rotation in degrees?

Best Regards,
flo
Quote
Cirque-Ethan
Hi Flo,

Depending on the generation and model of trackpad there are a few different ways to accomplish this. Can you let me know which of our products you are using? 

Ethan@Cirque
Quote
fh
Hello Ethan,
we are using a TM040040 Trackpad (IC 1CA027).

Best Regards,
flo
Quote
vadim

Hi Flo,

Could you please explain what you are trying to do? If you are trying to convert Cartesian coordinates into polar coordinates, it’s simple math (trigonometry) that is not related to the trackpad. You can find sample code here:

https://stackoverflow.com/questions/15994194/how-to-convert-x-y-coordinates-to-an-angle


Vadim

Quote
fh
Hello Vadim,
thanks for your reply. That's what I have tried in the first place without getting reliable / good results.

flo
Quote
Cirque-Ethan
Hi Flo,

I misinterpreted your original request (I thought you were wanting to just rotate the orientation of the touchpad), but for converting coordinates to rotation, the sample code from Vadim is probably best. This functionality is not native to the touchpad, so it would need to be developed.  Can you share a little more specifics about your application and what is not working well using the sample code? 

Ethan @ Cirque
Quote
mdl
There are a couple of issues that you need to work out to make this work well.  One is how you are going to center your data.  Really this means choosing the origin of your angles within your XY coordinates.  Another is smoothing.  It is relatively straight-forward to apply a low pass filter to a stream of data.  But if your data has discontinuities (eg when you wrap from 259 degrees back to 0) you will have to take that into account.  As far as the trigonometry, arctan is easy to approximate.
If this is all in the context of eg controlling a rotate gesture you would want to take into account the quantization of the finger data, and make sure you aren't relying on bits that aren't being reported, eg for a second finger.
Quote
Patrick
I'm late to the party, but we did exactly this for our Christmas tree LED controller, which used a TM040040:

double ComputeAngle(absData_t * touchData)
{
  double x = (double) touchData->xValue;
  double y = (double) touchData->yValue * 4 / 3;
  double angle = atan2 ((1024-y), (x-1024)) * 180 / PI;     
  angle  = angle > 0 ? angle : (360 + angle);
  return angle;
}

In this example, we scale Y by 4/3 because our circle sensors have differing resolution in the X and Y axes (Xmax = 2048, Ymax = 1536). This results in new resolution of 2048x2048. We subtract 1024 from each axis so that we are calculating the angle relative to the center of the touch pad.

I hope this helps.
Quote