Skip to content

Commit cd7aed9

Browse files
committed
add border
1 parent f1b51ff commit cd7aed9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

adafruit_pyportal.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,16 @@ def show_QR(self, qr_data, qr_size=1, x=0, y=0): # pylint: disable=invalid-name
804804
palette[0] = 0xFFFFFF
805805
palette[1] = 0x000000
806806

807-
# bitmap the size of the matrix, monochrome (2 colors)
808-
qr_bitmap = displayio.Bitmap(qrcode.matrix.width, qrcode.matrix.height, 2)
809-
810807
# pylint: disable=invalid-name
808+
# bitmap the size of the matrix, plus border, monochrome (2 colors)
809+
qr_bitmap = displayio.Bitmap(qrcode.matrix.width + 2, qrcode.matrix.height + 2, 2)
810+
for i in range(qr_bitmap.width * qr_bitmap.height):
811+
qr_bitmap[i] = 0
812+
811813
# transcribe QR code into bitmap
812814
for xx in range(qrcode.matrix.width):
813815
for yy in range(qrcode.matrix.height):
814-
qr_bitmap[xx, yy] = 1 if qrcode.matrix[xx, yy] else 0
816+
qr_bitmap[xx+1, yy+1] = 1 if qrcode.matrix[xx, yy] else 0
815817

816818
# display the QR code
817819
qr_sprite = displayio.TileGrid(qr_bitmap, pixel_shader=palette)

0 commit comments

Comments
 (0)