Permalink
Browse files

Add chase and chase fill dmx modes fixes # 5

  • Loading branch information...
1 parent 44c0a5f commit ed80b33656f38b20221ecc307b105d2ed38b5384 @scottjgibson scottjgibson committed Oct 29, 2012
Showing with 38 additions and 5 deletions.
  1. +1 −0 README.md
  2. +2 −3 controller.py
  3. +35 −2 ola_output_interface.py
View
@@ -3,6 +3,7 @@ PixelPi
RGB Pixel Array Driver for the Raspberry Pi; this provides a OLA output device which can display DMX data on LED pixels; or groups of pixels.
Project Page:
+http://thegreatgeekery.blogspot.ca/2012/10/pixelpi-update.html
http://thegreatgeekery.blogspot.ca/2012/08/raspberry-pi-and-ws2801.html
usage: pixelpi.py [-h] [-v] [--verbose] [--udp-ip UDP_IP]
View
@@ -64,7 +64,7 @@ def filter_pixel(self, input_pixel, brightness):
def run(self):
spidev = file(self.deviceName, "wb")
- print ("Start PixelInvaders listener " + self.UDP_IP + ":" + str(self.UDP_PORT))
+ print ("Start Raw RGB listener " + self.UDP_IP + ":" + str(self.UDP_PORT))
sock = socket.socket( socket.AF_INET, # Internet
socket.SOCK_DGRAM ) # UDP
sock.bind( (self.UDP_IP,self.UDP_PORT) )
@@ -117,8 +117,7 @@ def defineCliArguments(controller):
controller.chip_type = args.chip_type
if __name__ == '__main__':
- print "starting..."
-
+
controller = RGBController()
defineCliArguments(controller)
controller.run()
View
@@ -5,8 +5,10 @@
from ola.ClientWrapper import ClientWrapper
PIXEL_SIZE = 3
+WHITE = [255,255,255]
+BLACK = [0,0,0]
-def new_dmx_data(dmx_data):
+def new_dmx_data_rgb(dmx_data):
data = []
if ola_dmx_receiver.verbose:
print dmx_data
@@ -15,6 +17,30 @@ def new_dmx_data(dmx_data):
data.append(dmx_data[(group*PIXEL_SIZE):(group*PIXEL_SIZE)+PIXEL_SIZE])
ola_dmx_receiver.send(data)
+def new_dmx_data_chase_fill(dmx_data):
+ data = []
+ length = dmx_data[0]*ola_dmx_receiver.num_leds/255
+ if ola_dmx_receiver.verbose:
+ print length
+ for i in range(length):
+ data.append(WHITE)
+ for i in range(ola_dmx_receiver.num_leds - length):
+ data.append(BLACK)
+ ola_dmx_receiver.send(data)
+
+def new_dmx_data_chase(dmx_data):
+ data = []
+ position = dmx_data[0]*ola_dmx_receiver.num_leds/255
+ if ola_dmx_receiver.verbose:
+ print position
+ for i in range(position - 1):
+ data.append(BLACK)
+ data.append(WHITE)
+ for i in range(ola_dmx_receiver.num_leds - position):
+ data.append(BLACK)
+ ola_dmx_receiver.send(data)
+
+
class DMXReceiver:
def __init__(self):
@@ -53,7 +79,12 @@ def sendBytes(self, bytedata):
def run(self):
wrapper = ClientWrapper()
client = wrapper.Client()
- client.RegisterUniverse(self.universe, client.REGISTER, new_dmx_data)
+ if self.cmd == 'rgb':
+ client.RegisterUniverse(self.universe, client.REGISTER, new_dmx_data_rgb)
+ if self.cmd == 'chase':
+ client.RegisterUniverse(self.universe, client.REGISTER, new_dmx_data_chase)
+ if self.cmd == 'chase_fill':
+ client.RegisterUniverse(self.universe, client.REGISTER, new_dmx_data_chase_fill)
wrapper.Run()
# ==================================================================================================
@@ -68,6 +99,7 @@ def defineCliArguments(ola_dmx_receiver):
parser.add_argument('--universe', action='store', dest='universe', required=True, type=int, default='1', help='what dmx universe should we listen to')
parser.add_argument('--num_leds', action='store', dest='num_leds', required=True, default=50, type=int, help='Set the number of LEDs in the string')
parser.add_argument('--group_size', action='store', dest='group_size', required=True, default=1, type=int, help='Set the number of LEDs in a group')
+ parser.add_argument('--cmd', action='store', dest='cmd', required=True, default='rgb', choices = ['rgb', 'chase', 'chase_fill'], help='PixelPi ip to send RGB data to')
args = parser.parse_args()
ola_dmx_receiver.UDP_IP = args.UDP_IP
@@ -76,6 +108,7 @@ def defineCliArguments(ola_dmx_receiver):
ola_dmx_receiver.num_leds = args.num_leds
ola_dmx_receiver.universe = args.universe
ola_dmx_receiver.group_size = args.group_size
+ ola_dmx_receiver.cmd = args.cmd
print "Using UDP Client at ", ola_dmx_receiver.UDP_IP,":",ola_dmx_receiver.UDP_PORT

1 comment on commit ed80b33

fixes #5

Please sign in to comment.