Karl 3 роки тому
батько
коміт
f75c95d141
1 змінених файлів з 48 додано та 0 видалено
  1. 48 0
      buttons.py

+ 48 - 0
buttons.py

@@ -0,0 +1,48 @@
+import RPi.GPIO as GPIO
+import time
+import subprocess
+
+GPIO.setmode(GPIO.BCM)
+
+GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+
+while True:
+    input_state = GPIO.input(14)
+    if input_state == False:
+        print('playpause')
+        result = subprocess.run(
+            [f"python ./player.py playpause"],
+            stdout=subprocess.PIPE,
+            shell=True,
+        ).stdout.decode("utf-8")
+        time.sleep(0.2)
+    input_state = GPIO.input(15)
+    if input_state == False:
+        print('next')
+        result = subprocess.run(
+            [f"python ./player.py next"],
+            stdout=subprocess.PIPE,
+            shell=True,
+        ).stdout.decode("utf-8")
+        time.sleep(0.2)
+    input_state = GPIO.input(24)
+    if input_state == False:
+        print('previous')
+        result = subprocess.run(
+            [f"python ./player.py previous"],
+            stdout=subprocess.PIPE,
+            shell=True,
+        ).stdout.decode("utf-8")
+        time.sleep(0.2)
+    input_state = GPIO.input(23)
+    if input_state == False:
+        print('shuffle')
+        result = subprocess.run(
+            [f"python ./player.py shuffle"],
+            stdout=subprocess.PIPE,
+            shell=True,
+        ).stdout.decode("utf-8")
+        time.sleep(0.2)