j3nsykes I've read in your documentation it is best to wire the Craft pins consecutively to the capacitive pads. Does this still apply when trying to re-create an X, Y grid for knowing location of touch?
No. The firmware on Trill Craft is essentially the same as Trill Bar, so it's only if you were to try and recreate the latter that it would work simply by connecting the pads in order.
j3nsykes Am I best just trying to write my own code to calculate location with this different design? I notice you mention using a weighted average algorithm to do so - do you have further documentation of this?
Yes that's probably the solution: set the craft to the default (DIFF) mode and read the pads. Then on the host (Arduino or even Processing) you can parse those to compute the location and size of the touches.
The calculateCentroids()
function that computes the touch location and size on the Trill Bar/Square/Hex/Ring is this one: https://github.com/BelaPlatform/Trill/blob/master/firmware/common/trill-main.h#L553-L676
For Bar/Ring, this is executed only once per set of reading. For Square/Hex (for which TWOD
is #define
d), it is called twice: once with the horizontal pads and once with the vertical pads. centroidBuffer
and sizeBuffer
are the output buffers where up to maxNumCentroids
centroids ("touch position") and size are written to, respectively. It assumes that readings from each pad have been stored in the global array CSD_waSnsDiff[]
. minSensor
is the first element of this array to be processed, and maxSensor
is the last element + 1. numSensors
in your case will just be maxSensor - minSensor
. It would be something else only on a circular interface, like Trill Ring, where the first few pads could be part of a touch whose peak is at the last few centroids, so it could be simplified slightly for your application, but also there is no real need for that.
Hope that's a good starting point. I think all your questions are answered, but let me know if they are not .