add shuffle to button 4
This commit is contained in:
parent
cd10380d1a
commit
9379df14f3
11
buttons.py
11
buttons.py
@ -7,7 +7,7 @@ client = create_client()
|
||||
create_config(client)
|
||||
|
||||
# Set up GPIO pins for each button
|
||||
BUTTON_PINS = [17, 18, 27] # Replace with your GPIO pin numbers
|
||||
BUTTON_PINS = [17, 18, 27, 22]
|
||||
|
||||
GPIO.setmode(GPIO.BCM) # Use BCM numbering
|
||||
|
||||
@ -31,7 +31,6 @@ def button_callback_2(channel):
|
||||
control_player(client, "SKIP")
|
||||
control_player(client, "PLAY")
|
||||
|
||||
# Handling button 3 with a hold check
|
||||
def button_callback_3(channel):
|
||||
start_time = time.time()
|
||||
client = create_client()
|
||||
@ -49,10 +48,18 @@ def button_callback_3(channel):
|
||||
print("Button 3 pressed briefly! Sending RADIO.")
|
||||
control_player(client, "RADIO")
|
||||
|
||||
def button_callback_4(channel):
|
||||
print("Button 4 pressed!")
|
||||
client = create_client()
|
||||
control_player(client, "SHUFFLE")
|
||||
control_player(client, "PLAY")
|
||||
|
||||
|
||||
# Add event detection for each button press
|
||||
GPIO.add_event_detect(BUTTON_PINS[0], GPIO.FALLING, callback=button_callback_1, bouncetime=200)
|
||||
GPIO.add_event_detect(BUTTON_PINS[1], GPIO.FALLING, callback=button_callback_2, bouncetime=200)
|
||||
GPIO.add_event_detect(BUTTON_PINS[2], GPIO.FALLING, callback=button_callback_3, bouncetime=200)
|
||||
GPIO.add_event_detect(BUTTON_PINS[3], GPIO.FALLING, callback=button_callback_3, bouncetime=200)
|
||||
|
||||
try:
|
||||
# Keep the script running to detect button presses
|
||||
|
Loading…
x
Reference in New Issue
Block a user