Repository navigation
Expand file tree
/
Copy pathtest_harness.py
More file actions
116 lines (100 loc) · 3.51 KB
/
Copy pathtest_harness.py
File metadata and controls
116 lines (100 loc) · 3.51 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import time
import custom_display
_DELAY = 0.6
def run(matrix, bitmap, set_status_light, clear_status_lights):
display = matrix.display
boot_group = display.root_group
print("TEST MODE: initializing CustomDisplay")
cd = custom_display.CustomDisplay(display)
while True:
# --- Phase 1: Status lights ---
print("TEST: status lights")
display.root_group = boot_group
for light_id in (1, 2, 3):
clear_status_lights()
for color_idx in (1, 2, 3): # red, amber, green
set_status_light(light_id, color_idx)
time.sleep(_DELAY)
# all three lights, same color
for color_idx in (1, 2, 3):
for light_id in (1, 2, 3):
set_status_light(light_id, color_idx)
time.sleep(_DELAY)
clear_status_lights()
time.sleep(_DELAY)
# --- Switch to CustomDisplay ---
display.root_group = cd.root_group
cd.night_time = False
cd.is_home = True
cd._night_mode_received = True
cd._is_home_received = True
cd.has_error = None # reset so setter fires
cd.is_stale = True # reset so setter fires
cd.set_error(False)
cd.set_stale(False)
cd.hidden = False
# --- Phase 2: Big digits ---
print("TEST: big digits")
cd.make_big_digit('.', 3, 3) # decimal stays fixed
for ch in '0123456789-':
print(" big:", ch)
for pos in (0, 1, 2, 4): # skip pos 3 (decimal)
cd.make_big_digit(ch, pos, 3) # green
time.sleep(_DELAY)
# --- Phase 3: Small digits ---
print("TEST: small digits")
for ch in '0123456789':
print(" small:", ch)
for pos in range(3):
cd.make_small_digit(ch, pos, 1, 4) # cyan, row 1
cd.make_small_digit(ch, pos, 2, 3) # green, row 2
time.sleep(_DELAY)
# --- Phase 4: Sensor values (full update_display pass) ---
print("TEST: sensor values")
cases = [
(888.8, 88, 888),
(-5.0, 10, 25),
(32.0, 30, 75),
(72.3, 55, 125),
(85.0, 70, 175),
(99.9, 95, 350),
]
for t, h, a in cases:
print(" temp=%s hum=%s aqi=%s" % (t, h, a))
cd.set_temperature(t)
cd.set_humidity(h)
cd.set_aqi(a)
cd.update_display()
time.sleep(_DELAY)
# --- Phase 5: Line states ---
print("TEST: line states")
cd.has_error = None
cd.is_stale = True
cd.set_error(False)
cd.set_stale(False)
cd.update_display()
time.sleep(_DELAY) # gray lines
cd.set_stale(True)
cd.update_display()
time.sleep(_DELAY) # amber lines
cd.set_stale(False)
cd.set_error(True)
cd.update_display()
time.sleep(_DELAY) # red lines
cd.set_error(False)
cd.update_display()
time.sleep(_DELAY) # gray lines
# --- Phase 6: Visibility states ---
print("TEST: night mode")
cd.night_time = False
cd.set_night_time(True) # hidden
time.sleep(_DELAY)
cd.set_night_time(False) # visible
time.sleep(_DELAY)
print("TEST: is_home")
cd.is_home = True
cd.set_is_home(False) # hidden
time.sleep(_DELAY)
cd.set_is_home(True) # visible
time.sleep(_DELAY)
print("TEST: loop restart")