Skip to content

Commit

Permalink
* add fp5510 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Dec 2, 2024
1 parent a4e2bc7 commit 04bc7f2
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 2 deletions.
47 changes: 47 additions & 0 deletions docs/doc/en/modules/fp5510.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: MaixPy FP5510 Instructions
update:
- date: 2024-12-02
author: lxowalle
version: 1.0.0
content: Initial document
---

## Overview

The **FP5510** is a single 10-bit DAC with a 120mA output current voice coil motor, specifically designed for autofocus operations. It is commonly used in cameras, smartphones, and other electronic devices requiring focus adjustments.

## Using FP5510 in MaixPy

MaixPy supports the operation of the `FP5510` through the `FP5510` object.

Example Code:

```python
from maix.ext_dev import fp5510

fp = fp5510.FP5510()

fp.set_pos(value)
position = fp.get_pos()
print(f'set position to {position}')

```
- Use the `fp5510.FP5510()` method to construct an object for controlling the `fp5510`. Typically, the FP5510 may have slave addresses of `0x0e` or `0x0c`. You can specify the slave address via the `slave_addr` parameter, e.g.:

> **Note**: If the address of fp5510 is found to change between 0x0e and 0x0c, it may be because the `FP5510` shares a reset pin with the `camera`. When the reset pin is enabled, the FP5510 address is `0x0c`. When the reset pin is disabled, the FP5510 address changes to `0x0e`.
```python
fp = fp5510.FP5510(slave_addr = 0x0c)
```
- Use the `set_pos` method of the `FP5510` class to set the position of the voice coil motor. The range is [0, 1023]. For example:

```python
fp.set_pos(500)
```
- Use the `get_pos` method of the `FP5510` class to get the position of the voice coil motor. For example:

```python
position = fp.get_pos()
print(f'set position to {position}')
```
4 changes: 3 additions & 1 deletion docs/doc/en/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ items:
label: TOF
- file: modules/thermal_cam.md
label: Thermal imaging
file: modules/pmu.md
- file: modules/pmu.md
label: Power Management Unit
- file: modules/fp5510.md
label: Voice Coil Motor FP5510

- label: Projects
items:
Expand Down
47 changes: 47 additions & 0 deletions docs/doc/zh/modules/fp5510.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: MaixPy FP5510 使用说明
update:
- date: 2024-12-02
author: lxowalle
version: 1.0.0
content: 初版文档
---

## FP5510 简介

FP5510是一款单10位DAC,具有120mA输出的电流音圈电机,专为自动对焦操作设计,常用于相机,手机等需要对焦的电子设备.

## MaixPy 中使用 FP5510

MaixPy支持使用`FP5510`对象来操作`fp5510`

示例代码:

```python
from maix.ext_dev import fp5510

fp = fp5510.FP5510()

fp.set_pos(value)
position = fp.get_pos()
print(f'set position to {position}')

```
- 使用`fp5510.FP5510()`方法构造一个操作`fp5510`的对象.一般情况, fp5510可能有`0x0e``0x0c`两种从机地址, 通过`slave_addr`参数指定从机地址, 例如:

> 注意: 如果发现fp5510的地址在`0x0e``0x0c`间变化,可能是因为`fp5510``摄像头`共用了reset引脚,当使能reset脚时fp5510地址是`0x0c`, 当失能reset脚时fp5510地址是`0x0e`
```python
fp = fp5510.FP5510(slave_addr = 0x0c)
```
- 使用`FP5510`类的`set_pos`方法来设置音圈电机的位置,范围为[0, 1023], 例如:

```python
fp.set_pos(500)
```
- 使用`FP5510`类的`get_pos`方法来获取音圈电机的位置, 例如:

```python
position = fp.get_pos()
print(f'set position to {position}')
```
4 changes: 3 additions & 1 deletion docs/doc/zh/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ items:
label: TOF 测距
- file: modules/thermal_cam.md
label: 热成像摄像头
file: modules/pmu.md
- file: modules/pmu.md
label: 电源管理单元
- file: modules/fp5510.md
label: 音圈电机 FP5510

- label: 项目实战
items:
Expand Down
14 changes: 14 additions & 0 deletions examples/ext_dev/fp5510.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from maix import app, time
from maix.ext_dev import fp5510

fp = fp5510.FP5510()

value = 0
while not app.need_exit():
fp.set_pos(value)
print(f'set pos to {fp.get_pos()}')

value += 100
if value > 1023:
value = 0
time.sleep_ms(100)

0 comments on commit 04bc7f2

Please sign in to comment.