Skip to content
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

manual focus control! #25

Merged
merged 2 commits into from
Feb 8, 2024
Merged
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
20 changes: 20 additions & 0 deletions adafruit_pycamera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
_OV5640_CMD_TRIGGER_AUTOFOCUS = const(0x03)
_OV5640_CMD_AUTO_AUTOFOCUS = const(0x04)
_OV5640_CMD_RELEASE_FOCUS = const(0x08)
_OV5640_CMD_AF_SET_VCM_STEP = const(0x1A)
_OV5640_CMD_AF_GET_VCM_STEP = const(0x1B)

_OV5640_CMD_MAIN = const(0x3022)
_OV5640_CMD_ACK = const(0x3023)
Expand Down Expand Up @@ -493,6 +495,24 @@ def autofocus(self) -> list[int]:
print(f"zones focused: {zone_focus}")
return zone_focus

@property
def autofocus_vcm_step(self):
"""Get the voice coil motor step location"""
if not self._send_autofocus_command(
_OV5640_CMD_AF_GET_VCM_STEP, "get vcm step"
):
return None
return self.read_camera_register(_OV5640_CMD_PARA4)

@autofocus_vcm_step.setter
def autofocus_vcm_step(self, step):
"""Get the voice coil motor step location, from 0 to 255"""
if not 0 <= step <= 255:
raise RuntimeError("VCM step must be 0 to 255")
self.write_camera_register(_OV5640_CMD_PARA3, 0x00)
self.write_camera_register(_OV5640_CMD_PARA4, step)
self._send_autofocus_command(_OV5640_CMD_AF_SET_VCM_STEP, "set vcm step")

def select_setting(self, setting_name):
"""For the point & shoot camera mode, control what setting is being set"""
self._effect_label.color = 0xFFFFFF
Expand Down
Loading