Skip to content

Commit

Permalink
Merge pull request #25 from adafruit/focus_stack
Browse files Browse the repository at this point in the history
manual focus control!
  • Loading branch information
jepler authored Feb 8, 2024
2 parents 7698787 + 2748e0c commit 6b5c54a
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit 6b5c54a

Please sign in to comment.