You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
quirc_decode: finally debug prints work!
This commit is contained in:
+11
-4
@@ -1,5 +1,10 @@
|
||||
import qrdecode
|
||||
import random
|
||||
|
||||
# Create a 240x240 byte buffer
|
||||
buffer = bytearray(240 * 240)
|
||||
|
||||
# Fill buffer with random bytes
|
||||
|
||||
# Image dimensions
|
||||
width = 240
|
||||
@@ -8,11 +13,13 @@ buffer_size = width * height # 240 * 240 = 57600 bytes
|
||||
try:
|
||||
# Allocate buffer for grayscale image
|
||||
buffer = bytearray(buffer_size)
|
||||
for i in range(240 * 240):
|
||||
buffer[i] = random.getrandbits(8)
|
||||
# Read the raw grayscale image file
|
||||
with open('qrcode2.raw', 'rb') as f:
|
||||
bytes_read = f.readinto(buffer)
|
||||
if bytes_read != buffer_size:
|
||||
raise ValueError("File size does not match expected 240x240 grayscale image")
|
||||
#with open('qrcode2.raw', 'rb') as f:
|
||||
# bytes_read = f.readinto(buffer)
|
||||
# if bytes_read != buffer_size:
|
||||
# raise ValueError("File size does not match expected 240x240 grayscale image")
|
||||
# Decode QR code using qrdecode module
|
||||
print("decoding...")
|
||||
print(f"buffer length: {len(buffer)}")
|
||||
|
||||
Reference in New Issue
Block a user