|
8 | 8 | # import textmap |
9 | 9 | # from textmap import textBox |
10 | 10 |
|
| 11 | +import gc |
| 12 | +import time |
11 | 13 | import board |
12 | 14 | import displayio |
13 | 15 | import terminalio |
14 | | -import fontio |
15 | | -import sys |
16 | | -import time |
17 | | -import busio |
| 16 | +from adafruit_bitmap_font import bitmap_font |
18 | 17 |
|
19 | 18 | from adafruit_display_text import bitmap_label |
20 | 19 |
|
|
26 | 25 | ########## |
27 | 26 | # Use this Boolean variables to select which font style to use |
28 | 27 | ########## |
29 | | -use_builtin_font = True # Set True to use the terminalio.FONT BuiltinFont, |
| 28 | +use_builtinfont = True # Set True to use the terminalio.FONT BuiltinFont, |
30 | 29 | # Set False to use a BDF loaded font, see "fontFiles" below |
31 | 30 | ########## |
32 | 31 |
|
|
99 | 98 | # 'fonts/BitstreamVeraSans-Roman-16.bdf', # mainText |
100 | 99 | ] |
101 | 100 |
|
102 | | -from adafruit_bitmap_font import bitmap_font |
| 101 | + |
103 | 102 |
|
104 | 103 | for i, fontFile in enumerate(fontFiles): |
105 | 104 |
|
106 | | - if use_builtin_font: |
| 105 | + if use_builtinfont: |
107 | 106 | thisFont = ( |
108 | 107 | terminalio.FONT |
109 | 108 | ) # comment this out to switch back to BDF loaded fonts |
|
113 | 112 | fontList.append(thisFont) |
114 | 113 |
|
115 | 114 |
|
116 | | -preloadTheGlyphs = ( |
117 | | - True # set this to True if you want to preload the font glyphs into memory |
118 | | -) |
| 115 | +preload_glyphs = True # set this to True if you want to preload the font glyphs into memory |
119 | 116 | # preloading the glyphs will help speed up the rendering of text but will use more RAM |
120 | 117 |
|
121 | | -if preloadTheGlyphs: |
| 118 | +if preload_glyphs: |
122 | 119 |
|
123 | 120 | # identify the glyphs to load into memory -> increases rendering speed |
124 | 121 | glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.:?! " |
|
134 | 131 | print("Fonts completed loading.") |
135 | 132 |
|
136 | 133 | # create group |
137 | | -import gc |
138 | | - |
139 | 134 |
|
140 | | -myString1 = "This is a label.py and\nbitmap_label.py comparison." |
141 | | -myString23 = "none" |
142 | | -myString_bitmap_label = "bitmap_label" |
143 | | -myString_label = "label bitmap_label" |
| 135 | +my_string1 = "This is a label.py and\nbitmap_label.py comparison." |
| 136 | +my_string23 = "none" |
| 137 | +my_string_bitmap_label = "bitmap_label" |
| 138 | +my_string_label = "label bitmap_label" |
144 | 139 |
|
145 | 140 |
|
146 | 141 | ##### |
|
151 | 146 |
|
152 | 147 | bmap_label1 = bitmap_label.Label( |
153 | 148 | font=fontList[0], |
154 | | - text=myString1, |
| 149 | + text=my_string1, |
155 | 150 | color=0xFFFFFF, |
156 | | - max_glyphs=len(myString1), |
| 151 | + max_glyphs=len(my_string1), |
157 | 152 | background_color=0xFF0000, |
158 | 153 | padding_bottom=0, |
159 | 154 | padding_left=0, |
|
170 | 165 | label2_padding = 10 |
171 | 166 | bmap_label2 = bitmap_label.Label( |
172 | 167 | font=fontList[0], |
173 | | - text=myString23, |
| 168 | + text=my_string23, |
174 | 169 | color=0x000000, |
175 | | - max_glyphs=len(myString23), |
| 170 | + max_glyphs=len(my_string23), |
176 | 171 | background_color=0xFFFF00, |
177 | 172 | padding_bottom=label2_padding, |
178 | 173 | padding_left=0, |
|
189 | 184 |
|
190 | 185 | bmap_label3 = bitmap_label.Label( |
191 | 186 | font=fontList[0], |
192 | | - text=myString23, |
| 187 | + text=my_string23, |
193 | 188 | color=0x000000, |
194 | | - max_glyphs=len(myString23), |
| 189 | + max_glyphs=len(my_string23), |
195 | 190 | background_color=0xFFFF00, |
196 | 191 | padding_bottom=0, |
197 | 192 | padding_left=0, |
|
206 | 201 |
|
207 | 202 | bmap_label4 = bitmap_label.Label( |
208 | 203 | font=fontList[0], |
209 | | - text=myString_label, |
| 204 | + text=my_string_label, |
210 | 205 | color=0x000000, |
211 | | - max_glyphs=len(myString_label), |
| 206 | + max_glyphs=len(my_string_label), |
212 | 207 | background_color=0xFFFF00, |
213 | 208 | padding_bottom=0, |
214 | 209 | padding_left=0, |
|
221 | 216 | scale=my_scale, |
222 | 217 | ) |
223 | 218 |
|
224 | | -myString5 = "bitmap_label -->" |
| 219 | +my_string5 = "bitmap_label -->" |
225 | 220 | bmap_label5 = bitmap_label.Label( |
226 | 221 | font=fontList[0], |
227 | | - text=myString5, |
| 222 | + text=my_string5, |
228 | 223 | color=0xFFFFFF, |
229 | | - max_glyphs=len(myString5), |
| 224 | + max_glyphs=len(my_string5), |
230 | 225 | background_color=0x000000, |
231 | 226 | padding_bottom=0, |
232 | 227 | padding_left=0, |
|
261 | 256 |
|
262 | 257 | label1 = label.Label( |
263 | 258 | font=fontList[0], |
264 | | - text=myString1, |
| 259 | + text=my_string1, |
265 | 260 | color=0xFFFFFF, |
266 | | - max_glyphs=len(myString1), |
| 261 | + max_glyphs=len(my_string1), |
267 | 262 | background_color=0xFF0000, |
268 | 263 | padding_bottom=0, |
269 | 264 | padding_left=0, |
|
280 | 275 |
|
281 | 276 | label2 = label.Label( |
282 | 277 | font=fontList[0], |
283 | | - text=myString23, |
| 278 | + text=my_string23, |
284 | 279 | color=0x000000, |
285 | | - max_glyphs=len(myString23), |
| 280 | + max_glyphs=len(my_string23), |
286 | 281 | background_color=0xFFFF00, |
287 | 282 | padding_bottom=label2_padding, |
288 | 283 | padding_left=0, |
|
299 | 294 |
|
300 | 295 | label3 = label.Label( |
301 | 296 | font=fontList[0], |
302 | | - text=myString23, |
| 297 | + text=my_string23, |
303 | 298 | color=0x000000, |
304 | | - max_glyphs=len(myString23), |
| 299 | + max_glyphs=len(my_string23), |
305 | 300 | background_color=0xFFFF00, |
306 | 301 | padding_bottom=0, |
307 | 302 | padding_left=0, |
|
316 | 311 |
|
317 | 312 | label4 = label.Label( |
318 | 313 | font=fontList[0], |
319 | | - text=myString_label, |
| 314 | + text=my_string_label, |
320 | 315 | color=0x000000, |
321 | | - max_glyphs=len(myString_label), |
| 316 | + max_glyphs=len(my_string_label), |
322 | 317 | background_color=0xFFFF00, |
323 | 318 | padding_bottom=0, |
324 | 319 | padding_left=0, |
|
332 | 327 | ) |
333 | 328 |
|
334 | 329 |
|
335 | | -myString5 = "<-- label" |
| 330 | +my_string5 = "<-- label" |
336 | 331 | label5 = label.Label( |
337 | 332 | font=fontList[0], |
338 | | - text=myString5, |
| 333 | + text=my_string5, |
339 | 334 | color=0xFFFFFF, |
340 | | - max_glyphs=len(myString5), |
| 335 | + max_glyphs=len(my_string5), |
341 | 336 | background_color=0x000000, |
342 | 337 | padding_bottom=0, |
343 | 338 | padding_left=0, |
|
0 commit comments