I am thinking about using a permanent magnet as an input device for my smartphone. I have been reading some papers about it, but I really want to understand how things work. Using the integrated compass I can read the field strength along three axes. Given these readings, what property of the magnetic field could I use for gesture recognition?
To do anything I have to save the magnetic field strength along the three axes when no magnets are close to the smartphone. Then compare it with other readings.
When I place a magnet close to the smartphone in a particular position the readings will change. I can tell if the magnet is in that position when I read the same values along the three axes. This is because the magnet changes the "overall" magnetic field read by the magnetometer.
I can simulate a click when a magnet in a particular position is twisted/curled because the angle of the polar coordinates changes of about 180 degrees. This is because magnets have a north and south pole, so twisting it changes the pole and as a consequence the angle of the polar coordinates.
I would like to simulate a movement along an axis (like a slider). I can tell if I am at the beginning or at the end of it by comparing the magnetic field strength to the ones previously detected in those positions. How can I tell if I am in the middle or in any other point? The obvious solution would be to save the readings in all those points but I hope there is something about the magnetic field I am missing. Is there a law or a correlation between the points I can use?
These are some readings I recorded of seven equidistant points along the x axis:
x, y, z
-39.55, -51.19, -32.67
-26.01, -41.83, -32.95
-19.94, -34.08, -33.28
-16.43, -26.62, -32.72
-15.98, -22.6, -33.07
-15.93, -20.72, -32.96
-16.85, -18.87, -33.11
The best thing I have thought so far is to approximate the movement with a linear function but things doesn't work that well (for example the 4th and 7th position have almost the same value along x but they are in two different positions so I can't tell which one is the end and which the middle). This is one example, depending on where I am I can find myself with very different problems. How should I cope with it? Magnetic field is less strong as the magnet gets away from the magnetometer; what kind of function can describe this situation?