Add Controller support for fader lives.

This commit is contained in:
Matthew Stratford 2021-06-22 18:20:18 +01:00
parent 3951a4b427
commit 639b82adf9
2 changed files with 14 additions and 4 deletions

View file

@ -58,6 +58,10 @@ class MattchBox(Controller):
self.next_port = new_port self.next_port = new_port
def connect(self, port: Optional[str]): def connect(self, port: Optional[str]):
# If we loose the controller, make sure to set channels live, so we tracklist.
for i in range(len(self.server_from_q)):
self.sendToPlayer(i, "SETLIVE:True")
if port: if port:
# connect to serial port # connect to serial port
self.ser = serial.serial_for_url(port, do_not_open=True) self.ser = serial.serial_for_url(port, do_not_open=True)
@ -85,7 +89,13 @@ class MattchBox(Controller):
) # Endianness doesn't matter for 1 byte. ) # Endianness doesn't matter for 1 byte.
self.logger.log.info("Received from controller: " + str(line)) self.logger.log.info("Received from controller: " + str(line))
if line == 255: if line == 255:
self.ser.write(b"\xff") # Send 255 back. self.ser.write(b"\xff") # Send 255 back
elif line in [51,52,53]:
# We've received a status update about fader live status, fader is down.
self.sendToPlayer(line-51, "SETLIVE:False")
elif line in [61,62,63]:
# We've received a status update about fader live status, fader is up.
self.sendToPlayer(line-61, "SETLIVE:True")
elif line in [1, 3, 5]: elif line in [1, 3, 5]:
self.sendToPlayer(int(line / 2), "PLAYPAUSE") self.sendToPlayer(int(line / 2), "PLAYPAUSE")
elif line in [2, 4, 6]: elif line in [2, 4, 6]:
@ -121,5 +131,5 @@ class MattchBox(Controller):
self.connect(None) self.connect(None)
def sendToPlayer(self, channel: int, msg: str): def sendToPlayer(self, channel: int, msg: str):
self.logger.log.info("Sending message to server: " + msg) self.logger.log.info("Sending message to player channel {}: {}".format(channel, msg))
self.server_to_q[channel].put("CONTROLLER:" + msg) self.server_to_q[channel].put("CONTROLLER:" + msg)

View file

@ -600,7 +600,7 @@ class Player:
# Tells the player that the fader is live on-air, so it can tell tracklisting from PFL # Tells the player that the fader is live on-air, so it can tell tracklisting from PFL
def set_live(self, live: bool): def set_live(self, live: bool):
live = bool(live)
self.state.update("live", live) self.state.update("live", live)
# If we're going to live (potentially from not live/PFL), potentially tracklist if it's playing. # If we're going to live (potentially from not live/PFL), potentially tracklist if it's playing.
@ -1007,7 +1007,7 @@ class Player:
"CLEAR": lambda: self._retMsg(self.clear_channel_plan()), "CLEAR": lambda: self._retMsg(self.clear_channel_plan()),
"SETMARKER": lambda: self._retMsg(self.set_marker(self.last_msg.split(":")[1], self.last_msg.split(":", 2)[2])), "SETMARKER": lambda: self._retMsg(self.set_marker(self.last_msg.split(":")[1], self.last_msg.split(":", 2)[2])),
"RESETPLAYED": lambda: self._retMsg(self.reset_played(int(self.last_msg.split(":")[1]))), "RESETPLAYED": lambda: self._retMsg(self.reset_played(int(self.last_msg.split(":")[1]))),
"SETLIVE": lambda: self._retMsg(self.set_live(self.last_msg.split(":")[1])), "SETLIVE": lambda: self._retMsg(self.set_live(self.last_msg.split(":")[1] == "True")),
} }
message_type: str = self.last_msg.split(":")[0] message_type: str = self.last_msg.split(":")[0]