forked from simonmonk/raspirobotboard3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_all.py
More file actions
101 lines (77 loc) · 2.23 KB
/
Copy pathtest_all.py
File metadata and controls
101 lines (77 loc) · 2.23 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#Python 2
import rrb3 as rrb
import time
#import ex_8x8_pixels
rr = rrb.RRB3(6, 3)
def confirm(question):
answer = input(question)
def test_leds():
rr.set_led1(0)
rr.set_led2(0)
confirm("Are LED1 and LED2 both OFF?")
rr.set_led1(1)
rr.set_led2(0)
confirm("Is LED1 ON and LED2 OFF?")
rr.set_led1(1)
rr.set_led2(1)
confirm("Are LED1 and LED2 both ON?")
rr.set_led1(0)
rr.set_led2(0)
confirm("Are LED1 and LED2 both OFF?")
def test_oc():
rr.set_oc1(0)
rr.set_oc2(0)
confirm("OC1 and OC2 OFF?")
rr.set_oc1(1)
rr.set_oc2(0)
confirm("OC1 ON?")
rr.set_oc1(0)
rr.set_oc2(1)
confirm("OC2 ON?")
rr.set_oc1(0)
rr.set_oc2(0)
confirm("OC1 and OC2 OFF?")
def test_switches():
print("Remove header jumpers from [SW1] and [SW2]")
while rr.sw1_closed() or rr.sw2_closed():
pass
print("PASS: [SW1] and [SW2] open")
print("Fit header jumpers over [SW1] only")
while not rr.sw1_closed() or rr.sw2_closed():
pass
print("PASS: [SW1] closed")
print("Fit header jumpers over [SW2] only")
while rr.sw1_closed() or not rr.sw2_closed():
pass
print("PASS: [SW2] closed")
def test_motors():
rr.set_motors(0, 0, 0, 0)
confirm("Are Both motors stopped?")
rr.set_motors(1, 0, 1, 0)
confirm("Are Both motors going forwards?")
rr.set_motors(0.5, 0, 0.5, 0)
confirm("Are both motors going forwards at half speed?")
rr.set_motors(1, 1, 1, 1)
confirm("Are both motors going backwards?")
rr.set_motors(0, 0, 0, 0)
confirm("Are the motors off now?")
def test_ranger():
print("Make sure there is nothing infront of the rangefinder for 30cm")
print("Approximate distance should be displayed.")
print("Put your hand less than 10cm from rangefinder to finish test.")
d = rr.get_distance()
while d > 10:
print(d)
time.sleep(1)
d = rr.get_distance()
print("PASS")
def testI2C():
confirm("Watch the LED Matrix. Press Return when ready.")
ex_8x8_pixels.display_pattern()
confirm("Did the display draw a line at a time?")
test_leds()
test_oc()
test_switches()
test_motors()
test_ranger()
#testI2C()