Hallo Leute,
erst einmal tolles Forum. Habe auch schon ne menge gelernt, ich bin noch neu in den Linux und RPI Thema.
Ich versuch seit 2 wochen etwas scheinbar leichtes aber irgend wie ist es doch nicht so leicht.
Der Wunsch: RPI bekommt Strom und ein Script wird gestartet, vieleicht python oder bash.
Es gibt drei Tasten die an GPIO 17,27,22 hängen.
17 Kapitel "zurück" KEY = i
27 Kapitel "vorwärts" KEY = o
22 Startet den Film
zu gegeben habe alles mögliche schon probiert und die meisten haben in Python geschrieben deshalb habe ich es erst einmal in Python probiert. Hier der Code:
Code
#!/usr/bin/env python2.7
import RPi.GPIO as GPIO
import time
import sys
import subprocess
import os
import glob
GPIO.setmode(GPIO.BCM)
# 23 zum Beenden des Script
# 17 als button Play
# 27 als button vor
# 22 als button zurrueck
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
PATHDE="/home/pi/video/kate1.mp4"
PATHEN="/home/pi/video/kate2.mkv"
job=0
def my_callback(channel):
print("i")
#job=subprocess.Popen(["i"], stdin=subprocess.PIPE)
def my_callback1(channel):
print("o")
def my_callback2(channel):
print"omxplayer -o hdmi /home/pi/video/kate1.mp4"
job=subprocess.Popen(["omxplayer","-o", "hdmi", PATHDE], stdin=subprocess.PIPE)
# beim druecken von 24 springt er zum my_callback
GPIO.add_event_detect(17, GPIO.FALLING, callback=my_callback, bouncetime=30)
GPIO.add_event_detect(27, GPIO.FALLING, callback=my_callback1, bouncetime=30)
GPIO.add_event_detect(22, GPIO.FALLING, callback=my_callback2, bouncetime=30)
try:
GPIO.wait_for_edge(23, GPIO.RISING)
print "Bye bye jungs"
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
GPIO.cleanup() # clean up GPIO on normal exit
Alles anzeigen
was mache ich hier falsch ?!