Advertisement
here2share

# XYZirkle.py

Nov 29th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # XYZirkle.py
  2.  
  3. import appuifw
  4. import sensor
  5.  
  6. xyz=(0,0,0)
  7.  
  8. def draw(rect):
  9.     canvas.clear(0x000000)
  10.     point_size = (xyz[2]*6)-400
  11.     point_x = (-xyz[0]+60) * canvas.size[0] / 120
  12.     point_y = (xyz[1]+60) * canvas.size[1] / 120
  13.     point = (point_x, point_y)
  14.     canvas.point(point,outline=0xffffff,width=point_size,fill=0xffffff)
  15.  
  16. def redraw():
  17.     global xyz
  18.     xyz=(sens.x,sens.y,sens.z)
  19.     draw(canvas.size)
  20.  
  21. appuifw.app.orientation='portrait'
  22. appuifw.app.title=u'XYZirkle'
  23. appuifw.app.directional_pad=False
  24. canvas=appuifw.Canvas(redraw_callback=draw)
  25. appuifw.app.body=canvas
  26. sens=sensor.AccelerometerXYZAxisData(data_filter=sensor.LowPassFilter())
  27. sens.set_callback(data_callback=redraw)
  28. sens.start_listening()
  29.  
  30. def forLight():
  31.     appuifw.e32.reset_inactivity()
  32.     timer.after(10,forLight)
  33.  
  34. def exit():
  35.     app_lock.signal()
  36. appuifw.app.exit_key_handler=exit
  37.  
  38. timer=appuifw.e32.Ao_timer()
  39. forLight()
  40. app_lock=appuifw.e32.Ao_lock()
  41. app_lock.wait()
  42. sens.stop_listening()
  43. timer.cancel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement