Skip to content

Commit 3d02a8c

Browse files
authored
Merge pull request #8 from jepler/use-data-pins
Update for incompatible upstream changes
2 parents 568680f + 6546574 commit 3d02a8c

File tree

5 files changed

+111
-8
lines changed

5 files changed

+111
-8
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ On an Adafruit Metro M4 Grand Central, capture a 40x30 image into a buffer:
5656
5757
cam = OV7670(
5858
bus,
59-
data0=board.PCC_D0,
59+
data_pins=[board.PCC_D0, board.PCC_D1, board.PCC_D2, board.PCC_D3, board.PCC_D4, board.PCC_D5, board.PCC_D6, board.PCC_D7],
6060
clock=board.PCC_CLK,
6161
vsync=board.PCC_DEN1,
6262
href=board.PCC_DEN2,

adafruit_ov7670.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class OV7670: # pylint: disable=too-many-instance-attributes
506506
def __init__(
507507
self,
508508
i2c_bus,
509-
data0,
509+
data_pins,
510510
clock,
511511
vsync,
512512
href,
@@ -519,7 +519,7 @@ def __init__(
519519
"""
520520
Args:
521521
i2c_bus (busio.I2C): The I2C bus used to configure the OV7670
522-
data0 (microcontroller.Pin): The first of 8 parallel data capture pins.
522+
data_pins (List[microcontroller.Pin]): A list of 8 data pins, in order.
523523
clock (microcontroller.Pin): The pixel clock from the OV7670.
524524
vsync (microcontroller.Pin): The vsync signal from the OV7670.
525525
href (microcontroller.Pin): The href signal from the OV7670, \
@@ -581,7 +581,7 @@ def __init__(
581581
self._night = OV7670_NIGHT_MODE_OFF
582582

583583
self._imagecapture = imagecapture.ParallelImageCapture(
584-
data0=data0, clock=clock, vsync=vsync, href=href
584+
data_pins=data_pins, clock=clock, vsync=vsync, href=href
585585
)
586586

587587
def capture(self, buf):

examples/ov7670_displayio_gcm4_tftshield18.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ def __init__(self):
5151
self,
5252
bus,
5353
mclk=board.PCC_XCLK,
54-
data0=board.PCC_D0,
54+
data_pins=[
55+
board.PCC_D0,
56+
board.PCC_D1,
57+
board.PCC_D2,
58+
board.PCC_D3,
59+
board.PCC_D4,
60+
board.PCC_D5,
61+
board.PCC_D6,
62+
board.PCC_D7,
63+
],
5564
clock=board.PCC_CLK,
5665
vsync=board.PCC_DEN1,
5766
href=board.PCC_DEN2,
@@ -84,7 +93,6 @@ def deinit(self):
8493
)
8594
g.append(tg)
8695
display.show(g)
87-
buf = memoryview(bitmap)
8896

8997
t0 = time.monotonic_ns()
9098
display.auto_refresh = False
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries
3+
#
4+
# SPDX-License-Identifier: Unlicense
5+
6+
"""
7+
The Kaluga development kit comes in two versions (v1.2 and v1.3); this demo is
8+
tested on v1.3. It probably won't work on v1.2 without modification.
9+
10+
The v1.3 development kit's LCD can have one of two chips, the ili9341 or
11+
st7789. Furthermore, there are at least 2 ILI9341 variants, one of which needs
12+
rotation=90! This demo is for the ili9341. If the display is garbled, try adding
13+
rotation=90, or try modifying it to use ST7799.
14+
15+
The camera included with the Kaluga development kit is the incompatible OV2640,
16+
it won't work.
17+
18+
The audio board must be mounted between the Kaluga and the LCD, it provides the
19+
I2C pull-ups(!)
20+
"""
21+
22+
import time
23+
import board
24+
import busio
25+
import displayio
26+
from adafruit_ili9341 import ILI9341
27+
from adafruit_ov7670 import ( # pylint: disable=unused-import
28+
OV7670,
29+
OV7670_TEST_PATTERN_COLOR_BAR,
30+
OV7670_SIZE_DIV2,
31+
OV7670_NIGHT_MODE_2,
32+
)
33+
34+
# Pylint is unable to see that the "size" property of OV7670_GrandCentral exists
35+
# pylint: disable=attribute-defined-outside-init
36+
37+
# Release any resources currently in use for the displays
38+
displayio.release_displays()
39+
40+
spi = busio.SPI(MOSI=board.LCD_MOSI, clock=board.LCD_CLK)
41+
display_bus = displayio.FourWire(
42+
spi, command=board.LCD_D_C, chip_select=board.LCD_CS, reset=board.LCD_RST
43+
)
44+
display = ILI9341(display_bus, width=320, height=240)
45+
46+
bus = busio.I2C(scl=board.CAMERA_SIOC, sda=board.CAMERA_SIOD)
47+
cam = OV7670(
48+
bus,
49+
data_pins=board.CAMERA_DATA,
50+
clock=board.CAMERA_PCLK,
51+
vsync=board.CAMERA_VSYNC,
52+
href=board.CAMERA_HREF,
53+
mclk=board.CAMERA_XCLK,
54+
mclk_frequency=20_000_000,
55+
)
56+
57+
cam.size = OV7670_SIZE_DIV2
58+
cam.flip_x = False
59+
cam.flip_y = True
60+
pid = cam.product_id
61+
ver = cam.product_version
62+
print(f"Detected pid={pid:x} ver={ver:x}")
63+
# cam.test_pattern = OV7670_TEST_PATTERN_COLOR_BAR
64+
65+
g = displayio.Group(scale=1)
66+
bitmap = displayio.Bitmap(320, 240, 65536)
67+
tg = displayio.TileGrid(
68+
bitmap,
69+
pixel_shader=displayio.ColorConverter(
70+
input_colorspace=displayio.Colorspace.RGB565_SWAPPED
71+
),
72+
)
73+
g.append(tg)
74+
display.show(g)
75+
76+
t0 = time.monotonic_ns()
77+
display.auto_refresh = False
78+
while True:
79+
cam.capture(bitmap)
80+
bitmap.dirty()
81+
display.refresh(minimum_frames_per_second=0)
82+
t1 = time.monotonic_ns()
83+
print("fps", 1e9 / (t1 - t0))
84+
t0 = t1
85+
86+
cam.deinit()

examples/ov7670_displayio_pico_st7789_2in.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@
4545
# Set up the camera (you must customize this for your board!)
4646
cam = OV7670(
4747
bus,
48-
data0=board.GP12, # [16] [org]
48+
data_pins=[
49+
board.GP12,
50+
board.GP13,
51+
board.GP14,
52+
board.GP15,
53+
board.GP16,
54+
board.GP17,
55+
board.GP18,
56+
board.GP19,
57+
], # [16] [org] etc
4958
clock=board.GP11, # [15] [blk]
5059
vsync=board.GP7, # [10] [brn]
5160
href=board.GP21, # [27/o14] [red]
@@ -69,7 +78,7 @@
6978
if cam.height > height:
7079
continue
7180
try:
72-
bitmap = Bitmap(cam.width, cam.height, 65535)
81+
bitmap = Bitmap(cam.width, cam.height, 65536)
7382
break
7483
except MemoryError:
7584
continue

0 commit comments

Comments
 (0)