Toggle Navigation
Hatchery
Eggs
uQR
__init__.py
Users
Badges
Login
Register
__init__.py
raw
Content
# Simple wrapper around uQR found at https://github.com/JASchilz/uQR import display, keyboard from uqr import uQR def draw_qr(qr_data): print(qr_data) display.drawFill(0xffffff) qr = uQR.QRCode() qr.add_data(qr_data) matrix = qr.get_matrix() sizes = [display.width(), display.height()] sizes.sort() rastersize = (sizes[0] // len(matrix)) pos_x = (display.width() - rastersize * len(matrix[0])) // 2 pos_y = (display.height() - rastersize * len(matrix)) // 2 for matrix_y in range(len(matrix)): for matrix_x in range(len(matrix[0])): black = matrix[matrix_y][matrix_x] if black: display.drawRect(pos_x + matrix_x * rastersize, pos_y + matrix_y * rastersize , rastersize, rastersize, True, 0) display.flush() def main(): display.clearMatrix() display.drawFill(0xffffff) data = keyboard.show("What should the QR Code read?", "", draw_qr) # Start the main program. if not __name__ == "uqr": main()