00001
00002 import freenect
00003 import time
00004 import threading
00005 import random
00006
00007 dev = None
00008
00009
00010 def tilt_and_sense():
00011 global dev
00012 while not dev:
00013 time.sleep(1)
00014 while 1:
00015 time.sleep(3)
00016 led = random.randint(0, 6)
00017 tilt = random.randint(0, 30)
00018 print('Led[%d] Tilt[%d]' % (led, tilt))
00019 freenect.set_led(dev, led)
00020 freenect.set_tilt_degs(dev, tilt)
00021 print(freenect.raw_accel(dev))
00022 print(freenect.mks_accel(dev))
00023 threading.Thread(target=tilt_and_sense).start()
00024
00025
00026 def dev_getter(my_dev, *_):
00027 global dev
00028 dev = my_dev
00029 freenect.runloop(depth=lambda *x: dev_getter(*freenect.depth_cb_np(*x)))