support switch out of radio

This commit is contained in:
Karl Hudgell 2024-09-20 21:10:18 +01:00
parent a7a38c6633
commit c026592e9f

View File

@ -1,6 +1,6 @@
import RPi.GPIO as GPIO
import time
from lib.mqtt import create_client, control_player, create_config, check_current_status
from lib.mqtt import create_client, control_player, create_config, check_current_status, check_current_disc
client = create_client()
@ -39,8 +39,10 @@ def button_callback_3(channel):
while GPIO.input(BUTTON_PINS[2]) == GPIO.LOW: # Button is pressed (active low)
if time.time() - start_time >= 3: # Check if 3 seconds have passed
print("Button 3 held for 3 seconds! Sending RADIO2.")
disc_data = check_current_disc(client)
client = create_client()
control_player(client, "RADIO2")
control_player(client, f"{disc_data[0]}:{disc_data[1]}:{disc_data[2]}:RESET")
control_player(client, f"{disc_data[0]}:{disc_data[1]}:{disc_data[2]}:{disc_data[3]}")
return # Exit after sending RADIO2
# If button was not held for 3 seconds, send RADIO