From c026592e9f12bfdd57c69fa09bf5d29614bda375 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Fri, 20 Sep 2024 21:10:18 +0100 Subject: [PATCH] support switch out of radio --- buttons.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buttons.py b/buttons.py index 5ef3612..7e65ead 100644 --- a/buttons.py +++ b/buttons.py @@ -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