-
Notifications
You must be signed in to change notification settings - Fork 1
/
TimeWarp.py
71 lines (55 loc) · 1.89 KB
/
TimeWarp.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
70
71
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.ADC as ADC
import mplayer as mp
from time import sleep
from random import randint
from math import floor
def checkKnob(potPin):
# LOL return randint(0,1) # needs to be replaced by GPIO data
value = ADC.read(potPin)
return floor(24 * value)
def main():
print('start')
potPin = "P9_33"
running = True
# Setup GPIO
knobReading = 0
knobMoving = False
# Setup mplayer
video = mp.Player()
video.loadfile('/home/debian/videos/test.mpg')
video.fullscreen = True
video.loop = 10 # arbitrarily 'large'
timecode = 1 #do not use zero, it creates a pause
# time in seconds, where there is static I want to use
staticStart = [1,70,100,140,200]
staticLength = [10,10,9,9,9] # corresponding length of each static clip
# outter most loop, keep service running
while running:
# just play
# respond to input
knobMoving = checkKnob()
while knobMoving == True:
knobChoice = randint(0,4) # so I can use this to correlate staticStart and staticLength
video.time_pos = staticStart[knobChoice]
print(video.time_pos)
sleep(1)
knobMoving = checkKnob()
if knobMoving == False:
video.time_pos = knobTime()
break
someTime = randint(2,staticLength[knobChoice]-1)
sleep(someTime)
knobMoving = checkKnob()
if knobMoving == False:
video.time_pos = knobTime()
# only here for testing, otherwise loop forever
keepRunning = raw_input('Shall we continue?')
if keepRunning == 'n':
running = False
elif keepRunning == 't':
knobMoving = True
sleep(0.25)
print('end')
if __name__ == "__main__":
main()