From f3b1f7653c2a151bc52cd866cb1e644fcd7d72fd Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Fri, 20 Sep 2024 21:12:59 +0100 Subject: [PATCH] move client --- buttons.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/buttons.py b/buttons.py index 7e65ead..9149618 100644 --- a/buttons.py +++ b/buttons.py @@ -34,20 +34,18 @@ def button_callback_2(channel): # Handling button 3 with a hold check def button_callback_3(channel): start_time = time.time() - + client = create_client() # Wait until the button is released or held for more than 3 seconds 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, 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 print("Button 3 pressed briefly! Sending RADIO.") - client = create_client() control_player(client, "RADIO") # Add event detection for each button press