Created
December 3, 2015 21:24
-
-
Save AndyA/32cd1b909d760ea0ad6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor | |
from txosc import osc | |
from txosc import dispatch | |
from txosc import async | |
import time | |
import piglow | |
def pulse(): | |
for x in range(100): | |
piglow.leg_bar(0, x / 100.0) | |
piglow.leg_bar(1, x / 100.0) | |
piglow.leg_bar(2, x / 100.0) | |
piglow.white(0) | |
piglow.show() | |
time.sleep(0.01) | |
for x in reversed(range(100)): | |
piglow.leg_bar(0, x / 100.0) | |
piglow.leg_bar(1, x / 100.0) | |
piglow.leg_bar(2, x / 100.0) | |
piglow.white(0) | |
piglow.show() | |
time.sleep(0.01) | |
def glow_handler(message, address): | |
pulse() | |
class UDPReceiverApplication(object): | |
def __init__(self, port): | |
self.port = port | |
self.receiver = dispatch.Receiver() | |
self._server_port = reactor.listenUDP(self.port, async.DatagramServerProtocol(self.receiver)) | |
print("Listening on osc.udp://localhost:%s" % (self.port)) | |
self.receiver.addCallback("/cue/1/start", glow_handler) | |
# fallback: | |
self.receiver.fallback = self.fallback | |
def fallback(self, message, address): | |
print(" Got %s from %s" % (message, address)) | |
if __name__ == "__main__": | |
app = UDPReceiverApplication(17779) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment