Skip to content

Commit 4de2566

Browse files
committed
qrio example
1 parent 4614ad3 commit 4de2566

File tree

1 file changed

+57
-0
lines changed
  • circuitpython-esp32-camera/esp32-s3eye-qrio-repl

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
"""
6+
This demo is designed for the Kaluga development kit version 1.3 with the
7+
ILI9341 display.
8+
"""
9+
10+
import esp32_camera
11+
from terminalio import FONT
12+
import board
13+
import qrio
14+
import displayio
15+
import busio
16+
import struct
17+
18+
print("Initializing camera")
19+
cam = esp32_camera.Camera(
20+
data_pins=board.CAMERA_DATA,
21+
external_clock_pin=board.CAMERA_XCLK,
22+
pixel_clock_pin=board.CAMERA_PCLK,
23+
vsync_pin=board.CAMERA_VSYNC,
24+
href_pin=board.CAMERA_HREF,
25+
pixel_format=esp32_camera.PixelFormat.RGB565,
26+
frame_size=esp32_camera.FrameSize.R240X240,
27+
i2c=board.I2C(),
28+
external_clock_frequency=20_000_000,
29+
framebuffer_count=2)
30+
cam.vflip = True
31+
cam.hmirror = True
32+
33+
board.DISPLAY.auto_refresh = False
34+
display_bus = board.DISPLAY.bus
35+
36+
print(cam.width, cam.height)
37+
qrdecoder = qrio.QRDecoder(cam.width, cam.height)
38+
39+
print(qrdecoder.width, qrdecoder.height)
40+
#raise SystemExit
41+
42+
ow = (board.DISPLAY.width - cam.width) // 2
43+
oh = (board.DISPLAY.height - cam.height) // 2
44+
display_bus.send(42, struct.pack(">hh", ow, cam.width + ow - 1))
45+
display_bus.send(43, struct.pack(">hh", oh, cam.height + ow - 1))
46+
47+
while True:
48+
frame = cam.take(1)
49+
display_bus.send(44, frame)
50+
for row in qrdecoder.decode(memoryview(frame), qrio.PixelPolicy.RGB565_SWAPPED):
51+
payload = row.payload
52+
try:
53+
payload = payload.decode("utf-8")
54+
except UnicodeError:
55+
payload = str(payload)
56+
print(payload)
57+
print(end=".")

0 commit comments

Comments
 (0)