Skip to content

Commit 04bc7f2

Browse files
committed
* add fp5510 driver
1 parent a4e2bc7 commit 04bc7f2

File tree

5 files changed

+114
-2
lines changed

5 files changed

+114
-2
lines changed

docs/doc/en/modules/fp5510.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: MaixPy FP5510 Instructions
3+
update:
4+
- date: 2024-12-02
5+
author: lxowalle
6+
version: 1.0.0
7+
content: Initial document
8+
---
9+
10+
## Overview
11+
12+
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.
13+
14+
## Using FP5510 in MaixPy
15+
16+
MaixPy supports the operation of the `FP5510` through the `FP5510` object.
17+
18+
Example Code:
19+
20+
```python
21+
from maix.ext_dev import fp5510
22+
23+
fp = fp5510.FP5510()
24+
25+
fp.set_pos(value)
26+
position = fp.get_pos()
27+
print(f'set position to {position}')
28+
29+
```
30+
- 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.:
31+
32+
> **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`.
33+
34+
```python
35+
fp = fp5510.FP5510(slave_addr = 0x0c)
36+
```
37+
- 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:
38+
39+
```python
40+
fp.set_pos(500)
41+
```
42+
- Use the `get_pos` method of the `FP5510` class to get the position of the voice coil motor. For example:
43+
44+
```python
45+
position = fp.get_pos()
46+
print(f'set position to {position}')
47+
```

docs/doc/en/sidebar.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ items:
172172
label: TOF
173173
- file: modules/thermal_cam.md
174174
label: Thermal imaging
175-
file: modules/pmu.md
175+
- file: modules/pmu.md
176176
label: Power Management Unit
177+
- file: modules/fp5510.md
178+
label: Voice Coil Motor FP5510
177179

178180
- label: Projects
179181
items:

docs/doc/zh/modules/fp5510.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: MaixPy FP5510 使用说明
3+
update:
4+
- date: 2024-12-02
5+
author: lxowalle
6+
version: 1.0.0
7+
content: 初版文档
8+
---
9+
10+
## FP5510 简介
11+
12+
FP5510是一款单10位DAC,具有120mA输出的电流音圈电机,专为自动对焦操作设计,常用于相机,手机等需要对焦的电子设备.
13+
14+
## MaixPy 中使用 FP5510
15+
16+
MaixPy支持使用`FP5510`对象来操作`fp5510`
17+
18+
示例代码:
19+
20+
```python
21+
from maix.ext_dev import fp5510
22+
23+
fp = fp5510.FP5510()
24+
25+
fp.set_pos(value)
26+
position = fp.get_pos()
27+
print(f'set position to {position}')
28+
29+
```
30+
- 使用`fp5510.FP5510()`方法构造一个操作`fp5510`的对象.一般情况, fp5510可能有`0x0e``0x0c`两种从机地址, 通过`slave_addr`参数指定从机地址, 例如:
31+
32+
> 注意: 如果发现fp5510的地址在`0x0e``0x0c`间变化,可能是因为`fp5510``摄像头`共用了reset引脚,当使能reset脚时fp5510地址是`0x0c`, 当失能reset脚时fp5510地址是`0x0e`
33+
34+
```python
35+
fp = fp5510.FP5510(slave_addr = 0x0c)
36+
```
37+
- 使用`FP5510`类的`set_pos`方法来设置音圈电机的位置,范围为[0, 1023], 例如:
38+
39+
```python
40+
fp.set_pos(500)
41+
```
42+
- 使用`FP5510`类的`get_pos`方法来获取音圈电机的位置, 例如:
43+
44+
```python
45+
position = fp.get_pos()
46+
print(f'set position to {position}')
47+
```

docs/doc/zh/sidebar.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ items:
173173
label: TOF 测距
174174
- file: modules/thermal_cam.md
175175
label: 热成像摄像头
176-
file: modules/pmu.md
176+
- file: modules/pmu.md
177177
label: 电源管理单元
178+
- file: modules/fp5510.md
179+
label: 音圈电机 FP5510
178180

179181
- label: 项目实战
180182
items:

examples/ext_dev/fp5510.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from maix import app, time
2+
from maix.ext_dev import fp5510
3+
4+
fp = fp5510.FP5510()
5+
6+
value = 0
7+
while not app.need_exit():
8+
fp.set_pos(value)
9+
print(f'set pos to {fp.get_pos()}')
10+
11+
value += 100
12+
if value > 1023:
13+
value = 0
14+
time.sleep_ms(100)

0 commit comments

Comments
 (0)