apds-gesture-uid uses the gesture recognition of a APDS-9960 to simulate keyboard input by using the Linux uinput kernel module. This small script uses python-apds9960 and python-uinput to allow to control your GUI with gestures.
The APDS-9960 is able to detect 4 directions which will trigger a virtual keypress. The default config maps:
Direction | Key |
---|---|
UP | Page Up |
DOWN | Page Down |
LEFT | Left |
RIGHT | Right |
The python configuration file is /etc/gesture-ui.conf
. The following settings are recognized:
- I2C_PORT - the SMBus port number
- GMAPPINGS - defines which gesture direction should trigger which key presses
- POLLING_SLEEP - sleep between polling for new gesture recognition events
If the MQTT bridge modus is used, apds-gesture-uid-pub and apds-gesture-uid-sub are using the following MQTT settings:
- MQTT_HOST - the MQTT broker hostname or ip address
- MQTT_OPTS - connection options (see also connect method of the Paho MQTT python client)
- MQTT_TOPIC - the MQTT topic used for publish and subscribe
On Raspberry Pi you need to enable the I²C bus. See also the documentation at the the python-apds9960 module.
Install git, python-smbus and virtualenv:
# apt-get install git python-smbus virtualenv
# git clone --recursive https://github.com/liske/apds-gesture-ui.git /opt/apds-gesture-ui
The apds-gesture-ui and the apds-gesture-ui-sub scripts require the kernel module uinput.ko to be loaded:
# modprobe uinput
Put uinput
into /etc/modules
to load the module during system boot automaticly.
It is recommended to create a dedicated virtualenv where the python modules required by apds-gesture-uid will be installed:
- create new virtualenv
# virtualenv --system-site-packages /opt/apds-gesture-ui/venv
- enter the virtualenv
# . /opt/apds-gesture-ui/venv/bin/activate
- install Python-uinput
# pip install python-uinput
- install Paho MQTT python client (optional)
# pip install paho-mqtt
Copy the example default config file and customize it:
# cp /opt/apds-gesture-ui/ex/apds-gesture-ui.conf /etc/
This project contains example systemd.service files (see ex/). For activation copy the service file to
/etc/systemd/system/
and change the containing paths to match you environment:
# cp /opt/apds-gesture-ui/ex/apds-gesture-ui.service /etc/systemd/system/
# systemctl daemon-reload
# systemctl start apds-gesture-ui.service
# systemctl status apds-gesture-ui.service