-
Notifications
You must be signed in to change notification settings - Fork 0
/
grackle.py
56 lines (47 loc) · 1.66 KB
/
grackle.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
#wack a grackle root file
#by Shawn and Bob for Bridgewater Studios
#this files calls game.py for most of the game mechanics
#the pi communicates with 3 arduinos over MQTT to run 2 digit 7 segment displays
#this program runs at boot with a cron job
import time
import paho.mqtt.publish as publish
from usb_serial import UsbSerial
from game import Game
import serial
class Grackle:
@classmethod
def run(cls):
is_running = True
run_time = 30
max_pin = 51
ada_pins = 22
start = 20
ada_start = 21
ser_conf = {"port": "/dev/ttyACM0", "baud": 115200}
NUMATO=UsbSerial(ser_conf)
gameDict = {'serial': ser_conf, 'game_time': run_time}
NUMATO.reset()
NUMATO.clear(4)
NUMATO.clear(5)
while is_running:
if NUMATO.readGPIO(start)=="1":
NUMATO.set(4)
NUMATO.set(5)
print("go")
gameDict['last_pin'] = max_pin
publish.single("start")
Game.start(gameDict)
NUMATO.clear(4)
NUMATO.clear(5)
time.sleep(.1)
if NUMATO.readGPIO(ada_start)=="1":
NUMATO.set(4)
NUMATO.set(5)
print("ada button input activated")
gameDict['last_pin'] = ada_pins
publish.single("start")
Game.start(gameDict)
NUMATO.clear(4)
NUMATO.clear(5)
time.sleep(.1)
Grackle.run()