8000 use espcamera reset functionality; other minor changes by dhalbert · Pull Request #41 · adafruit/Adafruit_CircuitPython_PyCamera · GitHub
[go: up one dir, main page]

Skip to content

use espcamera reset functionality; other minor changes #41

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

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: v2.17.4
rev: v3.3.1
hooks:
- id: pylint
name: pylint (library code)
Expand Down
30 changes: 11 additions & 19 deletions adafruit_pycamera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@


class PyCameraBase: # pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Base class for PyCamera hardware"""
"""Base class for PyCamera hardware

"""Wrapper class for the PyCamera hardware with lots of smarts"""
Wrapper class for the PyCamera hardware with lots of smarts
"""

_finalize_firmware_load = (
0x3022,
Expand Down Expand Up @@ -253,9 +254,6 @@ def __init__(self) -> None: # pylint: disable=too-many-statements
self.shutter_button.switch_to_input(Pull.UP)
self.shutter = Button(self.shutter_button)

self._cam_reset = DigitalInOut(board.CAMERA_RESET)
self._cam_pwdn = DigitalInOut(board.CAMERA_PWDN)

# AW9523 GPIO expander
self._aw = adafruit_aw9523.AW9523(self._i2c, address=0x58)
print("Found AW9523")
Expand Down Expand Up @@ -374,14 +372,6 @@ def init_neopixel(self):

def init_camera(self, init_autofocus=True) -> None:
"""Initialize the camera, by default including autofocus"""
print("reset camera")
self._cam_reset.switch_to_output(False)
self._cam_pwdn.switch_to_output(True)
time.sleep(0.01)
self._cam_pwdn.switch_to_output(False)
time.sleep(0.01)
self._cam_reset.switch_to_output(True)
time.sleep(0.01)

print("Initializing camera")
self.camera = espcamera.Camera(
Expand All @@ -390,6 +380,8 @@ def init_camera(self, init_autofocus=True) -> None:
pixel_clock_pin=board.CAMERA_PCLK,
vsync_pin=board.CAMERA_VSYNC,
href_pin=board.CAMERA_HREF,
powerdown_pin=board.CAMERA_PWDN,
reset_pin=board.CAMERA_RESET,
pixel_format=espcamera.PixelFormat.RGB565,
frame_size=espcamera.FrameSize.HQVGA,
i2c=board.I2C(),
Expand Down Expand Up @@ -455,13 +447,13 @@ def write_camera_list(self, reg_list: Sequence[int]) -> None:

def read_camera_register(self, reg: int) -> int:
"""Read a 1-byte camera register"""
b = bytearray(2)
b[0] = reg >> 8
b[1] = reg & 0xFF
b_out = bytearray(2)
b_out[0] = reg >> 8
b_out[1] = reg & 0xFF
b_in = bytearray(1)
with self._camera_device as i2c:
i2c.write(b)
i2c.readinto(b, end=1)
return b[0]
i2c.write_then_readinto(b_out, b_in)
return b_in[0]

def autofocus_init_from_bitstream(self, firmware: bytes):
"""Initialize the autofocus engine from a bytestring"""
Expand Down
3 changes: 1 addition & 2 deletions examples/filter/code.py
7899
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ def sketch(b):

def cycle(seq):
while True:
for s in seq:
yield s
yield from seq


effects_cycle = iter(cycle(effects))
Expand Down
0