Skip to content

Commit

Permalink
Merge pull request #5 from adafruit/qrio-demo-fix
Browse files Browse the repository at this point in the history
Fix QR scanning demo
  • Loading branch information
jepler authored Dec 14, 2023
2 parents 17bb8a3 + 89a1dc5 commit d7bd59f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions examples/qrio/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,26 @@

import time

import bitmaptools
import displayio
import espcamera
import qrio

from adafruit_pycamera import PyCamera

zoomed = displayio.Bitmap(240, 176, 65535)
pycam = PyCamera()
pycam.camera.reconfigure(
pixel_format=espcamera.PixelFormat.RGB565,
frame_size=espcamera.FrameSize.VGA,
)
pycam._mode_label.text = "QR SCAN" # pylint: disable=protected-access
pycam._res_label.text = "" # pylint: disable=protected-access
pycam.effect = 0
pycam.camera.hmirror = False
pycam.display.refresh()
qrdecoder = qrio.QRDecoder(zoomed.width, zoomed.height)
qrdecoder = qrio.QRDecoder(pycam.camera.width, pycam.camera.height)

old_payload = None
while True:
new_frame = pycam.continuous_capture()
if new_frame is None:
continue
bitmaptools.blit(zoomed, new_frame, 0, 0, x1=(640 - 240) // 2, y1=(480 - 176) // 2)
pycam.blit(zoomed)
for row in qrdecoder.decode(zoomed, qrio.PixelPolicy.RGB565_SWAPPED):
pycam.blit(new_frame)
for row in qrdecoder.decode(new_frame, qrio.PixelPolicy.RGB565_SWAPPED):
print(row)
payload = row.payload
try:
payload = payload.decode("utf-8")
Expand Down

0 comments on commit d7bd59f

Please sign in to comment.