From 947477892ad3d0d4621c2de92dc45bc71c10fdcc Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Sat, 21 Sep 2024 08:10:34 +0100 Subject: [PATCH] get disc data once --- buttons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons.py b/buttons.py index 7b93469..62c19aa 100644 --- a/buttons.py +++ b/buttons.py @@ -35,11 +35,11 @@ def button_callback_2(channel): def button_callback_3(channel): start_time = time.time() client = create_client() + disc_data = check_current_disc(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) update_disc(client, ["ytmusic",disc_data['name'],disc_data['type'],"RESET"]) time.sleep(1) update_disc(client, ["ytmusic",disc_data['name'],disc_data['type'],disc_data['id']])