rekumar
I am trying to implement a 35mm trackpad in relative mode. I have no issue reading positive dx/dys, but when making negative movements the values are extremely jumpy. I assume this has to do with the way the deltax/deltay bits "roll over" on negative values, but even following the documentation and example code on the github im not able to figure this out. If i print the "negative movement" values to console, i see the jumps are in bit multiples (ie i'll get values of ~64, ~128, ~255, etc.).

Any insight or full-fledged examples of code using relative mode would be greatly appreciated!
Quote
Scott
Hello rekumar;

There is a document that has this information. I have added it as attachment. Here is a snapshot of the relevant information (I think).
  RelativeCapture.jpg 
I see the sign bits (flags) are in a separate packet byte. I assume that if it is set, the number is considered negative. However, from your description it sounds like for some reason the data is shifted. I have no idea off the top of my head why that would be.

See if this helps. If not, please come back and ask.

Scott
Quote
Scott
I was told that the sample code here:

https://github.com/cirque-corp/Cirque_Pinnacle_1CA027/tree/master/Additional_Examples/Pinnacle_Command_Panel

has a struc, relData_t

That should show how it is done.

Scott
Quote
rekumar
Hi Scott,

These are the (very helpful) docs I was following. Turns out that the jumping at random bits was the clue... my SPI timing was not set correctly.

I needed to initialize my SPI connection with the timing edges explicitly stated (SPIC_SCK_LEAD_RISING, SPI_SAMPLE_TRAILING).

For future reference to anyone using the LUFA SPI driver, my working command looked like this:
SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_RISING | SPI_SAMPLE_TRAILING | SPI_ORDER_MSB_FIRST | SPI_MODE_MASTER);


I think the SPI_SPEED_FCPU_DIV_XXX can be set differently if necessary, but I'll defer to someone with a better understanding of SPI.
Quote