-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfourtyYardDash.py
74 lines (52 loc) · 2.17 KB
/
fourtyYardDash.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
72
73
74
from multiprocessing import Process
import time
import threading
import queue
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
from stopWatch import App
global startingChannel, finishingChannel, raceStarted, raceInProgress, raceFinished, stopWatch, startingThread, finishingThread
raceStarted = False
raceInProgress = False
raceFinished = False
i2c = busio.I2C(board.SCL, board.SDA)
ads = ADS.ADS1115(i2c)
startingChannel = AnalogIn(ads, ADS.P1)
finishingChannel = AnalogIn(ads, ADS.P0)
def startingLine():
global startingChannel, finishingChannel, raceStarted, raceInProgress, raceFinished, stopWatch, startingThread
print("starting line function called")
while(True):
#print("starting line " + str(raceInProgress) + " " + str(startingChannel.value))
if(not raceInProgress and int(startingChannel.value) > 1000):
print("starting line laser beam broken" + str(startingChannel.value))
#stopWatch.reset()
finishingThread = threading.Thread(target=finishLine)
finishingThread.start()
stopWatch.start()
raceInProgress= True
print("done")
#break
def finishLine():
global startingChannel, finishingChannel, raceStarted, raceInProgress, raceFinished, stopWatch, startingThread, finishingThread
print("finish line function called")
while(True):
#print("finish " + str(finishingChannel.value))
if(int(finishingChannel.value) > 1800):
print("finish line laser beam broken " + str(int(finishingChannel.value)))
stopWatch.stop()
raceInProgress = False
break
def main():
global startingChannel, finishingChannel, raceStarted, raceInProgress, raceFinished, stopWatch, startingThread, finishingThread
stopWatch = App()
stopWatch.stop()
print("main function called")
startingThread = threading.Thread(target=startingLine)
startingThread.start()
stopWatch.root.mainloop()
if __name__ == "__main__":
main()