-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dbus.02.py
69 lines (56 loc) · 1.6 KB
/
test_dbus.02.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
import time
from time import sleep
import os
import RPi.GPIO as GPIO
import sys
import subprocess
from subprocess import Popen
import serial
import shlex
def sensorCallback(channel):
# Called if sensor output changes
if GPIO.input(channel):
# No magnet
print("HIGH")
else:
# Magnet
print("LOW")
#definition du serial
#ser = serial.Serial('/dev/ttyACMaa, 9600)
#killomx = "sudo killall -s 9 omxplayer.bin"
#os.system(killomx)
player = subprocess.Popen(["omxplayer"])
GPIO.setmode(GPIO.BCM)
#GPIO.setwarnings(False)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
#GPIO.setup(18, GPIO.IN)
hallpin = 18
sleepTime = 0.1
pausestat = 0
playstate = 0
GPIO.setup( hallpin, GPIO.IN)
movie1 = ("/home/pi/Desktop/movie1.mp4")
try:
while True:
#omxc=subprocess.Popen(['omxplayer', '-b', movie1])
if (GPIO.input(hallpin) == False):
#print("magnet detected")
omxc=subprocess.Popen(['omxplayer', '-b', movie1])
if (GPIO.input(hallpin) == True):
sleep(1)
if (GPIO.input(hallpin) == True):
print ("Stop")
#player.stdin.write("p")
os.system('killall omxplayer.bin')
#print("magnet not detected")
#os.system('killall omxplayer.bin')
#os.system('/home/pi/mu_code/dbuscontrol.sh pause')
#omxc=subprocess.Popen(['omxplayer', '-i', movie1])
#sleep(sleepTime)
except KeyboardInterrupt:
#Reset GPIO settings
#os.system('killall omxplayer.bin')
GPIO.cleanup()
except KeyboardInterrupt:
print ("Exception: KeyboardInterrupt")