vpu_live.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import pygame
  2. import pygame.gfxdraw
  3. import math
  4. import random
  5. import os
  6. os.environ['SDL_VIDEO_WINDOW_POS'] = '%i,%i' % (200,200)
  7. os.environ['SDL_VIDEO_CENTERED'] = '0'
  8. pg = pygame
  9. pygame.init()
  10. main_size=(600,300)
  11. main_size=(1600,900)
  12. main_size=(600,300)
  13. #window = pygame.display.set_mode(main_size,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  14. #window = pygame.display.set_mode(main_size,pg.RESIZABLE|pygame.DOUBLEBUF,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  15. window = pygame.display.set_mode(main_size,pg.RESIZABLE)#,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  16. #window = pygame.display.set_mode(main_size,pg.NOFRAME,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  17. #window = pygame.display.set_mode(main_size,pg.NOFRAME,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  18. #window = pygame.display.set_mode(main_size,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  19. # pygame.display.set_mode((self.width, int(self.height+(self.height*0.15))) ,pygame.FULLSCREEN)
  20. #pg.display.set_mode(window,pg.DOUBLEBUF) #|pg.OPENGL)
  21. pg.display.set_caption('LibreLight Animation')
  22. import pygame
  23. import pygame.gfxdraw
  24. import math
  25. import random
  26. import os
  27. def event_read():
  28. inc = 1
  29. for event in pg.event.get():
  30. print("event",event)
  31. move_x = 0
  32. move_y = 0
  33. move_z = 0
  34. rot_x = 0
  35. rot_y = 0
  36. rot_z = 0
  37. if event.type== pg.QUIT:
  38. print("quit")
  39. pg.quit()
  40. quit()
  41. sys.exit()
  42. if "key" in dir(event):
  43. if event.key == 27: #ESC pg.KEYDOWN:
  44. print("quit")
  45. pg.quit()
  46. quit()
  47. sys.exit()
  48. pg = pygame
  49. pygame.init()
  50. main_size=(600,300)
  51. main_size=(1600,900)
  52. main_size=(600,300)
  53. #window = pygame.display.set_mode(main_size,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  54. #window = pygame.display.set_mode(main_size,pg.RESIZABLE|pygame.DOUBLEBUF,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  55. window = pygame.display.set_mode(main_size,pg.RESIZABLE)#,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  56. #window = pygame.display.set_mode(main_size,pg.NOFRAME,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  57. #window = pygame.display.set_mode(main_size,pg.NOFRAME,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  58. #window = pygame.display.set_mode(main_size,pygame.FULLSCREEN) #x left->right ,y top-> bottom
  59. # pygame.display.set_mode((self.width, int(self.height+(self.height*0.15))) ,pygame.FULLSCREEN)
  60. #pg.display.set_mode(window,pg.DOUBLEBUF) #|pg.OPENGL)
  61. pg.display.set_caption('LibreLight Animation')
  62. class FIX():
  63. def __init__(self,pos=[10,10]):
  64. self.rgb = [255,255,255]
  65. self.pos = pos
  66. def draw(self):
  67. pygame.draw.rect(window,self.rgb,[self.pos[0],self.pos[1],15,15])
  68. import memcache
  69. mc = memcache.Client(['127.0.0.1:11211'], debug=0)
  70. import time
  71. s=time.time()
  72. import math
  73. while 1:
  74. x=mc.get("index")#cmd)
  75. #for i,k in x.items():
  76. # print(i,k)
  77. t = int(math.sin(time.time() - s)*10)
  78. event_read()
  79. r=mc.get("10.10.10.13:2")
  80. #print(r)
  81. ch = 0
  82. dmx = 1-1
  83. rgb = [255,255,255]
  84. for x in range(12):
  85. for y in range(8):
  86. ch += 4
  87. #f = FIX(pos=[x*16,y*16])
  88. if ch+4 < len(r):
  89. rgb = [r[ch+1]*r[ch]/255,r[ch+2]*r[ch]/255,r[ch+3]*r[ch]/255]
  90. #print(rgb)
  91. pos=[x*16,y*16]
  92. pygame.draw.rect(window,rgb,[pos[0],pos[1],15,15])
  93. #f.draw()
  94. pygame.display.flip()
  95. pg.time.wait(10)