-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_images.py3
172 lines (111 loc) · 3.93 KB
/
generate_images.py3
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env python3
# generate_images.py3
"""Generate simulated screen images for the documentation."""
######################
# Imports & Globals
######################
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import adafruit_framebuf
WIDTH = 128
HEIGHT = 32
######################
# SimulatedScreen class
######################
class SimulatedScreen(adafruit_framebuf.FrameBuffer):
def __init__(self, width, height):
self.buffer = bytearray(round(width * height / 8))
super(SimulatedScreen, self).__init__(self.buffer, width, height, buf_format=adafruit_framebuf.MVLSB)
self.image_index = 0
def show(self):
self.save()
def save(self, status = ""):
screen = Image.new("1", (self.width, self.height))
for y in range(self.height):
for x in range(self.width):
if self.pixel(x, y):
screen.putpixel((x, y), 1)
else:
screen.putpixel((x, y), 0)
if status == "":
screen.save("screen_%d.bmp" % self.image_index)
else:
screen.save("screen_%s.bmp" % status.replace(".", "").replace(":", "").replace("<", "").replace(">", "").replace("/", "_").replace(" ", "_").replace("__", "_").lower())
self.image_index += 1
######################
# Create display
######################
display = SimulatedScreen(WIDTH, HEIGHT)
arrowhead_logo = Image.open("arrowhead_logo.bmp")
xoffset = arrowhead_logo.width + 3
logo = Image.new("1", (display.width, display.height))
logo.paste(arrowhead_logo)
display.image(logo)
######################
# Utilities
######################
def update_status(status, save_name = ""):
display.fill_rect(xoffset, 24, 128, 32, False)
display.text(status, xoffset, 24, True)
if save_name == "":
display.save(status)
else:
display.save(save_name)
######################
# Generate images
######################
# Loading screen
display.text("Arrowhead", xoffset, 0, True)
display.text("Overlay", xoffset, 8, True)
update_status("Loading...")
# Git updates (overlay)
update_status("Updating...")
# Git updates (barrier)
update_status("Updating SW...")
update_status("Building...")
update_status("Updating binary...")
update_status("Building failed.")
# Restart after update
update_status("Restarting...")
# AHCore Discovery
update_status("Obtaining ID...")
## AHCore Discovery failed
update_status(" << FAILED >>")
## AHCore Discovery success
update_status("ID: %d" % 7, "discovery_success")
# Main menu
display.fill_rect(xoffset, 16, 128, 32, False)
display.text("Select mode:", xoffset, 16, True)
update_status("< %s >" % "FindServer".center(10))
display.fill_rect(xoffset, 16, 128, 32, False)
display.text("Select mode:", xoffset, 16, True)
display.text("%d" % 5, display.width - 6, 16, True)
update_status("< %s >" % "FindServer".center(10), "findserver_with_countdown")
# Other menu options
update_status("< %s >" % "ProvideLap".center(10))
update_status("< %s >" % "Local only".center(10))
update_status("< %s >" % "bfed32c".center(10), "githash")
display.fill_rect(xoffset, 16, 128, 32, False)
# Mode 1 Find Server
update_status("Finding host...")
# M1 Unable to orchestrate
update_status("ID: %d O.fail" % 7, "orch_failed")
# M1 Multiple hosts
display.fill_rect(xoffset, 16, 128, 32, False)
display.text("Use provider:", xoffset, 16, True)
update_status("< %s >" % "scoreapp".center(10), "select_provider")
# M1 Multiple endpoints
display.fill_rect(xoffset, 16, 128, 32, False)
display.text("Select endp:", xoffset, 16, True)
update_status("< %s >" % "barrier/1".center(10), "select_endpoint")
display.fill_rect(xoffset, 16, 128, 32, False)
# Mode 2 Provide lap
update_status("Provider mode")
update_status("P:%d I:%d S:%d" % (7, 2, 16), "provider_ids")
# M2 Awaiting connection
update_status("Awaiting conn")
# Bye!
display.fill(0)
display.text("Bye!", 54, 12, True)
display.save("bye")