-
Notifications
You must be signed in to change notification settings - Fork 1.3k
esp32-camera: make the master_clock_pin really optional #7355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The master_clock_pin was already optional, but not specifying it would result in a crash. This fixes it, so it really can be omitted, when the camera module has its own clock source built in.
To test this with a module that doesn't have a crystal, you can create the PWMOut yourself before creating the camera: import board
import displayio
import adafruit_ili9341
import busio
import digitalio
import esp32_camera
import pwmio
displayio.release_displays()
display_bus = displayio.FourWire(
busio.SPI(clock=board.IO7, MOSI=board.IO5),
command=board.IO9,
chip_select=board.IO3,
baudrate=80_000_000,
)
display = adafruit_ili9341.ILI9341(
display_bus,
width=320,
height=240,
)
pwm = pwmio.PWMOut(board.IO11, frequency=20_000_000)
pwm.duty_cycle = 65536//2
i2c = busio.I2C(scl=board.IO35, sda=board.IO33)
data_pins = (
board.IO21, board.IO17, board.IO16, board.IO18,
board.IO37, board.IO34, board.IO36, board.IO39,
)
c = esp32_camera.Camera(
data_pins=data_pins,
# external_clock_pin=board.IO11,
pixel_clock_pin=board.IO12,
vsync_pin=board.IO40,
href_pin=board.IO38,
pixel_format=esp32_camera.PixelFormat.RGB565,
frame_size=esp32_camera.FrameSize.QVGA,
i2c=i2c,
# external_clock_frequency=20_000_000,
)
g = displayio.Group()
bitmap = None
while not bitmap:
bitmap = c.take()
shader = displayio.ColorConverter(
input_colorspace=displayio.Colorspace.BGR565_SWAPPED
)
tg = displayio.TileGrid(bitmap, pixel_shader=shader)
g.append(tg)
display.show(g)
display.auto_refresh = False
while True:
bitmap = c.take()
tg.x = 1 # make the grid dirty
tg.x = 0
display.refresh() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more files than I would expect to have changed in the changes for the esp32-camera submodule. Your PR to that changed only one file, I think.
That is because the circuitpython branch contains all those changes, with my commit only being added on top of that. The current submodule points at a specific commit in the circuitpython branch, and I don't see any way of adding only my commit to it. Do you know if something like that is possible? |
On the other hand, I don't see those changes breaking anything, so maybe I could make a separate PR bringing the submodule to the commit just before my commit, and you could merge that first? |
Ah, I see, #2 brought in a bunch of upstream changes, but the circuitpython repo didn't pick those up. Sorry, it's fine, then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good!
The master_clock_pin was already optional, but not specifying it would result in a crash. This fixes it, so it really can be omitted, when the camera module has its own clock source built in.