Skip to content

Commit 7376a8f

Browse files
committed
lunt
1 parent 999fe40 commit 7376a8f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

examples/miniqr_displaytest.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,39 @@
1111

1212
def draw_QR(matrix):
1313
# how big each pixel is, add 2 blocks on either side
14-
BLOCK_SIZE = DISPLAY_W // (qr.matrix.width+4)
15-
14+
BLOCK_SIZE = DISPLAY_W // (matrix.width+4)
15+
1616
# Center the QR code in the middle of the screen
17-
X_OFFSET = (DISPLAY_W - BLOCK_SIZE * qr.matrix.width) // 2
18-
Y_OFFSET = (DISPLAY_H - BLOCK_SIZE * qr.matrix.height) // 2
19-
17+
X_OFFSET = (DISPLAY_W - BLOCK_SIZE * matrix.width) // 2
18+
Y_OFFSET = (DISPLAY_H - BLOCK_SIZE * matrix.height) // 2
19+
2020
# monochome (2 color) palette
2121
palette = displayio.Palette(2)
2222
palette[0] = 0xFFFFFF
2323
palette[1] = 0x000000
24-
24+
2525
# bitmap the size of the screen, monochrome (2 colors)
2626
bitmap = displayio.Bitmap(DISPLAY_H, DISPLAY_W, 2)
27-
27+
2828
# raster the QR code
2929
line = bytearray(DISPLAY_W // 8) # monochrome means 8 pixels per byte
30-
for y in range(qr.matrix.height): # each scanline in the height
31-
for i in range(len(line)): # initialize it to be empty
30+
for y in range(matrix.height): # each scanline in the height
31+
for i, _ in enumerate(line): # initialize it to be empty
3232
line[i] = 0
33-
for x in range(qr.matrix.width):
34-
if qr.matrix[x, y]:
33+
for x in range(matrix.width):
34+
if matrix[x, y]:
3535
for b in range(BLOCK_SIZE):
3636
_x = X_OFFSET + x * BLOCK_SIZE + b
3737
line[_x // 8] |= 1 << (7-(_x % 8))
38-
38+
3939
for b in range(BLOCK_SIZE):
4040
# load this line of data in, as many time as block size
41+
#pylint: disable=protected-access
4142
bitmap._load_row(Y_OFFSET + y*BLOCK_SIZE+b, line)
4243

4344
# display the bitmap using our palette
4445
splash = displayio.Group()
45-
face = displayio.Sprite(bitmap, pixel_shader=palette, position=(0,0))
46+
face = displayio.Sprite(bitmap, pixel_shader=palette, position=(0, 0))
4647
splash.append(face)
4748
board.DISPLAY.show(splash)
4849
board.DISPLAY.wait_for_frame()

0 commit comments

Comments
 (0)