demo_tilt.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import freenect
3 import time
4 import random
5 import signal
6 
7 keep_running = True
8 last_time = 0
9 
10 
11 def body(dev, ctx):
12  global last_time
13  if not keep_running:
14  raise freenect.Kill
15  if time.time() - last_time < 3:
16  return
17  last_time = time.time()
18  led = random.randint(0, 6)
19  tilt = random.randint(0, 30)
20  freenect.set_led(dev, led)
21  freenect.set_tilt_degs(dev, tilt)
22  print('led[%d] tilt[%d] accel[%s]' % (led, tilt, freenect.get_accel(dev)))
23 
24 
25 def handler(signum, frame):
26  """Sets up the kill handler, catches SIGINT"""
27  global keep_running
28  keep_running = False
29 print('Press Ctrl-C in terminal to stop')
30 signal.signal(signal.SIGINT, handler)
31 freenect.runloop(body=body)
def body(dev, ctx)
Definition: demo_tilt.py:11
def handler(signum, frame)
Definition: demo_tilt.py:25


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Mon Jun 10 2019 13:46:42