#!/usr/bin/env python
SCREEN_SIZE = (1366, 768)
video1 = 'c:\\video\\newtest1.mpg'
video2 = 'c:\\video\\newtest2.mpg'
still1 = 'c:\\video\\red.tga'
still2 = 'c:\\video\\blue.tga'
import pygame
from pygame.locals import *
from sys import exit
pygame.init()
screen = pygame.display.set_mode((SCREEN_SIZE), FULLSCREEN, 32)
surface = pygame.display.set_mode((SCREEN_SIZE), FULLSCREEN, 32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
if event.type == KEYDOWN:
if event.key == K_LEFT:
movie = pygame.movie.Movie(video1)
movie.play()
pygame.display.update()
elif event.key == K_RIGHT:
movie = pygame.movie.Movie(video2)
movie.play()
pygame.display.update()
elif event.key == K_UP:
surface = pygame.image.load(still1).convert()
screen.blit(surface, (10, 10))
pygame.display.flip()
elif event.key == K_DOWN:
surface = pygame.image.load(still2).convert()
screen.blit(surface, (10, 10))
pygame.display.flip()
from ola.ClientWrapper import ClientWrapper which I assume is from ClientWrapper.py? Do I need any other files to communicate with OLA?event.type == KEYDOWN
and event.key == K_LEFT with the relevant code to listen for DMX values
but I just not sure what to look for.It some thing I understand and think I should be able too do quite easily.
While I figure out the more elegant option of using the python api.
But any help would be greatly appreciated.
Thank you
Tim
If it possible when / if you have a moment could you right the most basic python script to print the DMX value for a given channel.
Just wanted to strip it down to the barebones and work up from there.
Thank you
Tim
Thank you it much appreciated I will have a look at this as soon as I have a moment works gone a bit crazy.
Thanks again
Tim
#!/usr/bin/env python
SCREEN_SIZE = (1920, 1080)
black = '/home/pi/media/HD_black.jpg'
video1 = '/home/pi/media/newtest1.mpg'
video2 = '/home/pi/media/newtest2.mpg'
still1 = '/home/pi/media/red.tga'
still2 = '/home/pi/media/blue.tga'
import sys
import select
import array
import random
import pygame
from ola import OlaClient
# let OlaClient create the socket itself
ola_client = OlaClient.OlaClient()
sock = ola_client.GetSocket()
# defining custom events for pygame
DMX_RECEIVE_EVENT = pygame.USEREVENT + 1
SEND_DMX_EVENT_TIMER = pygame.USEREVENT + 2
""" receive the dmx """
def on_dmx(dmx):
print ("received!")
# create a pygame event with the dmx values attached
ev = pygame.event.Event(DMX_RECEIVE_EVENT, {'dmx': dmx})
# posting the event
pygame.event.post(ev)
UNIVERSE = 1
# listening for dmx frames
ola_client.RegisterUniverse(UNIVERSE, ola_client.REGISTER, on_dmx)
pygame.init()
screen = pygame.display.set_mode((SCREEN_SIZE), 0, 32)
surface = pygame.display.set_mode((SCREEN_SIZE), 0, 32)
# background color
background = (0, 0, 0)
# dmx frame with 4 channels
DMX_FRAME = array.array('B', [0, 0, 0, 0])
while True:
# check for pygame events
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == DMX_RECEIVE_EVENT:
# first channel
if event.dmx[0] == 000:
pygame.mouse.set_visible(0)
screen = pygame.display.set_mode((SCREEN_SIZE), $
surface = pygame.image.load(black).convert()
screen.blit(surface, (10, 10))
pygame.display.flip()
elif event.dmx[0] == 001:
surface = pygame.image.load(still1).convert()
screen.blit(surface, (10, 10))
pygame.display.flip()
elif event.dmx[0] == 002:
surface = pygame.image.load(still2).convert()
screen.blit(surface, (10, 10))
pygame.display.flip()
# check if there is something to do