Advertisement
here2share

# s60_360dict.py

Jul 28th, 2017
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # s60_360dict.py
  2.  
  3. import e32,audio,appuifw,os,sys,key_codes,time,math,random,graphics,copy,sysinfo
  4. from appuifw import *
  5.  
  6. Deg = {'-----' : '-----'#
  7.  
  8. def draw(rect): # >>> draw(())
  9.     if img:
  10.         canvas.blit(img)
  11. #
  12. def fr_sp(z=0.05):
  13.     if time.time() > cv.wait:
  14.         cv.wait=time.time()+z
  15.         return True
  16. #
  17. class cv():
  18.     go=1
  19.     wait=0
  20. cv=cv()
  21.  
  22. app.screen = 'large'
  23. app.directional_pad = False
  24. app.orientation='portrait'
  25. img=None
  26. app.body = canvas = Canvas(redraw_callback=draw) #
  27. X,Y=canvas.size
  28. img=graphics.Image.new((X,Y))
  29.  
  30. def oExit(): cv.go=False
  31. def exit_btn(): app.exit_key_handler=oExit
  32.  
  33. import sensor
  34. def xyzsens():
  35.     try:
  36.         cv.xyz=(sens.x,sens.y,sens.z)
  37.     except: pass
  38. sens=sensor.AccelerometerXYZAxisData(data_filter=sensor.LowPassFilter())
  39. sens.set_callback(data_callback=xyzsens)
  40. sens.start_listening()
  41.  
  42. def up_event(event):
  43.     cv.x,cv.y=0,0
  44. def dn_event(event):
  45.     cv.x,cv.y=event
  46. def mv_event(event):
  47.     cv.x,cv.y=event
  48. #
  49. canvas.bind(key_codes.EButton1Up,   up_event, ((0,0), (X,Y)))
  50. canvas.bind(key_codes.EButton1Down, dn_event, ((0,0), (X,Y)))
  51. canvas.bind(key_codes.EDrag,        mv_event, ((0,0), (X,Y)))
  52.  
  53. exit_btn()
  54.  
  55. c=100
  56. cv.go = 1
  57. while cv.go:
  58.     if fr_sp(0.03):
  59.         img.clear(0)
  60.         x,y = degrad(c*5,c**2/5000)
  61.         sz=c**2/6000
  62.         img.point((int(X/2+x),int(Y/2+y)),0x00ffff,width=sz)
  63.         if x-sz/2 > X/2:
  64.             c=100
  65.         c+=1
  66.         draw(())
  67.     e32.ao_yield()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement