Convert several capsense nodes result to slider position
08/214/2017 | 06:26 AM
Question
I have used the capsense library, the slider was composed of several sensors. do you have any suggestion how to convert the sensor data to slider position?
Answer
You could refer to our example CapsenseCircleSlider for EFM8SB1 device. You could get the example code in folder like below for default installation:
The example use centroid algorithm to interpolate the 3 nodes data to get the slider position. The bin for the 3 sensors was [20, 40, 60]. the weight 40 was for the sensor with max value captured.
Let us assume the sensor value for the 3 sensors was x, y and z. Then
centroid = (x * 20 + y * 40 + z * 60) / (x + y + z)
This would give a result with range [30 50].
The max value 50 was getten when y equals z.
The min result 30 was getten when y equals x.
You should choose suitable bin parameter based on your sensor layout and target slider range.
Convert several capsense nodes result to slider position