Get one here: https://shop.pimoroni.com/products/zx-distance-and-gesture-sensor
Run make
if you have it, to install for Python 2 and 3.
Alternatively:
sudo python3 setup.py install
gesture_available
- ReturnsTrue
if a gesture is availableposition_available
- ReturnsTrue
if a position ( Z and X coordinates ) is availableget_x
- Returns the X positionget_z
- Returns the Z positionget_position
- Returns the Z and X position, use like so:Z, X = zx.get_position()
get_gesture
- Returns a gesture, if there is one, otherwise returns none. Available gestures are:- zx.SWIPE_LEFT
- zx.SWIPE_RIGHT
- zx.SWIPE_UP
get_speed
- Returns the speed of the gesturegesture_name( gesture )
- Accepts a gesture number and returns the text name of a gesture ( ie: "Swipe Left" )
Here's a simple example that prints out the Z and X positions:
import zx
import time
while True:
if zx.position_available():
z, x = zx.get_position()
print("z: {}, x: {}".format(z,x))
time.sleep(0.01)