Simple test
Ensure your device works with this simple test.
examples/miniqr_simpletest.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import sys
5
6import adafruit_miniqr
7
8# For drawing filled rectangles to the console:
9out = sys.stdout
10WHITE = "\x1b[1;47m \x1b[40m"
11BLACK = " "
12
13
14def prettyprint_QR(matrix):
15 # white 4-pixel border at top
16 for _ in range(4):
17 for _ in range(matrix.width + 8):
18 out.write(WHITE)
19 print()
20 for y in range(matrix.height):
21 out.write(WHITE * 4) # 4-pixel border to left
22 for x in range(matrix.width):
23 if matrix[x, y]:
24 out.write(BLACK)
25 else:
26 out.write(WHITE)
27 out.write(WHITE * 4) # 4-pixel bporder to right
28 print()
29 # white 4-pixel border at bottom
30 for _ in range(4):
31 for _ in range(matrix.width + 8):
32 out.write(WHITE)
33 print()
34
35
36qr = adafruit_miniqr.QRCode(qr_type=3, error_correct=adafruit_miniqr.L)
37qr.add_data(b"https://www.adafruit.com")
38qr.make()
39print(qr.matrix)
40prettyprint_QR(qr.matrix)