def sub_beat(self, beat, sub_beat): beat_event = beat_event_pb2.BeatEvent() beat_event.beat = beat beat_event.type = beat_event_pb2.SUB_BEAT beat_event.sub_beat = sub_beat self.publisher.send_multipart( ['s', beat_event.SerializeToString()], zmq.NOBLOCK)
def set_color(self, r = 0, g = 0, b = 0): beat_event = beat_event_pb2.BeatEvent() beat_event.r = max(abs(r), 255) beat_event.g = max(abs(g), 255) beat_event.b = max(abs(b), 255) beat_event.type = beat_event_pb2.COLOR self.publisher.send_multipart(['C', beat_event.SerializeToString()], zmq.NOBLOCK)
def run(self): self.running = True beat_event = beat_event_pb2.BeatEvent() print "BeatReceiver running." while self.running: tag, message = self.sub.recv_multipart() beat_event.ParseFromString(message) if self.callback: self.callback(beat_event) else: if beat_event.type == beat_event_pb2.BEAT: print "Beat" elif beat_event.type == beat_event_pb2.COLOR: print "COLOR", str( (beat_event.r, beat_event.g, beat_event.b))
def change_scene(self, scene_number=0): beat_event = beat_event_pb2.BeatEvent() beat_event.type = beat_event_pb2.CHANGE_SCENE self.publisher.send_multipart( ['c', beat_event.SerializeToString()], zmq.NOBLOCK)