generated from msalloum/CS178A-B-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardwareTest.py
84 lines (70 loc) · 2.06 KB
/
hardwareTest.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
75
76
77
78
79
80
81
82
83
84
from hardware import *
# Logic for capturing:
# # up
# # down
# # could send both moves and it woould ignore the invalid one?
# # up (whos turn matters?)
# # up (ignore)
# # down
# LIGHTS UP EVERY SQUARE WITH A PIECE ON IT GREEN
def all_leds_green():
try:
prev = getBoard()
current = []
while(True):
LEDS = []
# setGPIO(51) #for testing voltage
current = getBoard()
for i in range(64):
if current[i] == 1:
LEDS.append((squareMap[i], GREEN))
# print(LEDS)
# print()
setLEDS(LEDS)
except:
pass
GPIO.cleanup()
# RAVE
# ################# SHIFT REGISTER EXAMPLE #####################
def led_rave_test():
try:
while(True):
for color in [RED, GREEN, BLUE]:
LEDs = []
for letter in "abcdefgh":
for i in range(1, 9):
print((letter + str(i), color))
# setLEDS([(letter + str(i), color)])
LEDs.append((letter + str(i), color))
# time.sleep(0.05)
setLEDS(LEDs)
time.sleep(0.05)
# while(True):
# pass
except:
pass
#PINs final cleaning
GPIO.cleanup()
# LIGHTS EVERY LED UP 1 AT A TIME
################# SHIFT REGISTER EXAMPLE #####################
def snake_led_rgb():
try:
while(True):
for color in [RED, GREEN, BLUE]:
for letter in "abcdefgh":
for i in range(1, 9):
print((letter + str(i), color))
setLEDS([(letter + str(i), color)])
time.sleep(0.01)
# while(True):
# pass
except:
pass
#PINs final cleaning
GPIO.cleanup()
def test_func():
arr = ["a2a4", "a2a3", "b2b4", "b2b3", "c2c4", "c2c3", "d2d4", "d2d3", "e2e4", "e2e3", "f2f4", "f2f3", "g2g4", "g2g3", "h2h4", "h2h3", "b1a3", "b1c3", "g1f3", "g1h3"]
print(get_move(arr))
#led_rave_test()
#all_leds_green()
test_func()