Looking under the hood of the Pi Supply Flick
We recently received our Flick designed by Pi Supply, which allows gesture sensing on any I2C capable device and will enable new possibilities for our Pis and with a little work, maybe even our PC and Arduino. Using the GestIC technology from Microchip, the Flick turns hand/limb movements into a sensory input.
While not the norm yet gesture based movement could soon be as common as swiping on your cell phone. For example, imagine swiping up or down, left or right, in the vicinity of your screen or keyboard to scroll a website and switch tasks without touching the screen — a thing of science fiction but not anymore.
Install and set-up
Once connected we booted up Raspbian on one of our Pi 3 boards and because this was an older device that hadn’t been used for a while, we did a “sudo apt-get update” and “sudo apt-get upgrade” before we started to bring the software up to date.
Once this was complete we followed the instructions on the wiki and executed the command “curl -sSL https://pisupp.ly/flickcode | sudo bash”, which installed the software for the Flick with ease. For those less versed in the arcane arts of Linux this command downloads a bash scrip (below) and pipes it to bash for execution.
#!/usr/bin/env bash set -euo pipefail #Check if script is being run as root if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" 1>&2 exit 1 fi if [ ! $? = 0 ]; then exit 1 else #Installs packages which might be missing apt-get install -y git whiptail # enable I2C raspi-config nonint do_i2c 0 git clone https://GitHub.com/PiSupply/Flick.git cd Flick/flick python setup.py install whiptail --msgbox "The system will now reboot" 8 40 reboot fi
flick bash script
As can be seen in the script the latest code is automatically pulled in from GitHub and installed. Note the reboot at the end of the script, so make sure you have nothing open that needs saving. If required all code related to the flick is provided via the same GitHub repository
Once installed running the demos was as simple as executing the examples:
- The flick-demo gives a good overview of the features available.
- The flick-snail is an example of how gesture control can be used to move items around in virtual space.
While at the time of writing the python API is “Coming soon”, looking at these demos it looks to be almost ready since the are using it successfully. Looking at how the code handles the flicking:
@flicklib.flick() def flick(start,finish): global flicktxt flicktxt = start + ' - ' + finish
Following the code into flicklib we can see it puts an array of the text strings when a gesture is detected:
('flick','west','east'), ('flick','east','west'), ('flick','south','north'), ('flick','north','south'),
From this, it’s not too much effort to join the dots and see the “start” and “finish” will be one of the outputs from flicklib and therefore flicktxt will be something like “west–east”. Altering a demo from here should be fairly straightforward.
Use with other devices
At the time of writing there were no provided Arduino libraries, however, the device is based upon a MGC3130 therefore there are libraries out there and getting it working should be possible. As use with a PC may be interesting to some this could prove to be the easiest way for HID integration into a PC environment, using the Arduino (or other micro) as a bridge.
Digging into the Flick we found the IC that makes everything work is a GestIC from Microchip but what does it actually do, how does it work?
Brace yourself, some science is required:
Whenever an electrical potential (voltage) is applied to anything it generates an electric field (if current flows magnetic too, but this can be ignored). Think of the classic capacitance parallel plate example: there will be a large DC electric field between the two plates and this is often shown in diagrams.
More over electric fields are everywhere — in fact, there will be an electric field around you while you read this article — near the surface of the earth there is a DC field of 100 to 150V/m (Volts/meter).
What the GestIC does is provide a field of a known type (an AC field of specific frequency), which comes from the central conductor to 4 surrounding pads. Think of these as the capacitor with the sensing area the gap between the plates. When you introduce an electrical conductor (e.g. your arm) into this gap the field changes (it is shorted across the conductor). By checking all 4 plates the GestIC can determine the position of this interception in 3d space. This is not too dissimilar to how capacitive touch can work, but such solutions generally constrain the field to a much shorter distance. This is a simplification but should give an idea of what is going on.
As an aside, you may be thinking: why can I not feel this field? First, let’s look at the fact that a 2m tall person will have up to 300V of potential difference from their head to toes!
The reason is that we don’t feel voltage, we feel current flow, and since the current flow is incredibly small and across the conductor (which is our 2m tall giant) it is so little, that there is nothing to feel. The same principles go for the Flick operation: there is no appreciable current flow so nothing to feel.
If this was a little deep then this article from Microchip has a few simple illustrations that may make things more clear.
Phew, that turned science up to 11, but hopefully has shed some light on how the Flick is doing its magic. The technology the Flick is based upon is very clever and having an electric field sensing-method in the Pi’s array of tools is a great feature. The software is still being worked upon at the time of writing and hopefully, some cool new demos and APIs will arrive within the coming months.