Toggle Navigation
Hatchery
Eggs
QR test
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import ugfx import math from qr import pyqrnative def render(thing): # up to level 27 (125x125px) can be displayed qr = pyqrnative.QRCode(2, pyqrnative.QRErrorCorrectLevel.Q) qr.addData(thing) qr.make() max_x = max_y = qr.getModuleCount() matrix = qr.modules disp_x, disp_y = (296, 128) block_size = math.floor(disp_y/max_y) offset_x = int(disp_x/2) - int(block_size*max_y/2) offset_y = int(disp_y/2) - int(block_size*max_x/2) ugfx.init() ugfx.clear(ugfx.WHITE) for y, row in enumerate(matrix): for x, col in enumerate(row): if qr.isDark(x, y): ugfx.area(offset_x+x*block_size, offset_y+y*block_size, block_size, block_size, ugfx.BLACK) ugfx.flush() render('https://hackon.nl') import time time.sleep(0.7) import deepsleep deepsleep.start_sleeping(60000)