Skip to content

Commit

Permalink
manual focus control!
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Feb 3, 2024
1 parent 7698787 commit 644890e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 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,22 @@ 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)

Check failure on line 510 in adafruit_pycamera/__init__.py

View workflow job for this annotation

GitHub Actions / test

Unnecessary parens after 'not' keyword

Check failure on line 510 in adafruit_pycamera/__init__.py

View workflow job for this annotation

GitHub Actions / test

Unnecessary parens after 'not' keyword
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 644890e

Please sign in to comment.