Skip to content

Commit bc1a444

Browse files
stephen.gaosupremeys
stephen.gao
authored andcommitted
add (sensors) :添加三轴传感器,温湿度传感器,光照传感器代码及datasheet
1 parent 1d90820 commit bc1a444

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3042
-0
lines changed

libraries/ADXL346/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# adxl346
2+
3+
默认初始化2G量程。
4+
5+
**类引用:**
6+
7+
```python
8+
from adxl346 import Adxl346
9+
```
10+
11+
12+
13+
**实例化参数:**
14+
15+
| 名称 | 必填 | 类型 | 说明 |
16+
| -------- | ---- | ------- | ----------------------------------- |
17+
| i2c || i2c对象 | 如I2C(I2C.I2C1, I2C.STANDARD_MODE) |
18+
| dev_addr || int | 默认0x53 |
19+
20+
```python
21+
i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE)
22+
adxl = Adxl346(i2c_dev)
23+
```
24+
25+
**接口函数:**
26+
27+
l **set_range(range=0)**
28+
29+
设置量程。
30+
31+
参数:
32+
33+
| 名称 | 必填 | 类型 | 说明 |
34+
| ----- | ---- | ---- | ------------------------------------------------------------ |
35+
| range || int | range_2g:0;<br />range_4g :1;<br />range_8g :2;<br />range_16g:3 |
36+
37+
返回值:
38+
39+
​ 无。
40+
41+
l **int_enable(int_code,tap_thr,dur,tap_axis,laten,window,ff_thr,ff_time,act_thr,act_axis,inact_thr,inact_axis,inact_time)**
42+
43+
​ 中断使能。
44+
45+
参数:
46+
47+
| 名称 | 必填 | 类型 | 说明 |
48+
| ---------- | ---- | ---- | ------------------------------------------------------------ |
49+
| int_code || int | 中断类型<br />单击中断:0x40<br />双击中断:0x20<br />运动中断:0x10<br />静止中断:0x08<br />自由落体中断:0x04 |
50+
| tap_thr || int | 单双击中断选配<br />敲击中断阈值,默认0x30,建议不要小于该值 |
51+
| dur || int | 单双击中断选配<br />敲击期间,默认0x20,建议大于0x10 |
52+
| tap_axis || int | 单双击中断选配<br />敲击轴,默认0x07,既xyz,<br />只x轴:0x04<br />只y轴:0x02<br />只z轴:0x01 |
53+
| laten || int | 双击中断选配<br />延迟,双击需在单击检测后该段时间外触发,默认0x15 |
54+
| window || int | 双击中断选配<br />窗口,双击需在该时间内完成,默认0xff |
55+
| ff_thr || int | 自由落体中断选配<br />加速度阈值,触发需大于该加速度,默认0x06,建议3-9 |
56+
| ff_time || int | 自由落体中断选配<br />加速度时间,触发需大于该时间,默认0x15,建议0x14-0x46 |
57+
| act_thr || int | 运动中断选配<br />加速度阈值,触发需大于该加速度,默认0x03 |
58+
| act_axis || int | 运动中断选配,运动轴,默认0xf0<br />只x轴:0xc0<br />只y轴:0xa0<br />只z轴:0x90 |
59+
| inact_thr || int | 静止中断选配<br />加速度阈值,触发需大于该加速度,默认0x03 |
60+
| inact_axis || int | 静止中断选配,运动轴,默认0x0f<br />只x轴:0x0c<br />只y轴:0x0a<br />只z轴:0x09 |
61+
| inact_time || int | 静止中断选配<br />静止保持时间,触发需静止大于该时间,默认0x03 |
62+
63+
返回值:
64+
65+
​ 0 :成功
66+
67+
​ -1 : 失败
68+
69+
l **clear_int(int_code)**
70+
71+
​ 清除某中断使能。
72+
73+
参数:
74+
75+
| 名称 | 必填 | 类型 | 说明 |
76+
| -------- | ---- | ---- | ------------------------------------------------------------ |
77+
| int_code || int | 中断类型<br />单击中断:0x40<br />双击中断:0x20<br />运动中断:0x10<br />静止中断:0x08<br />自由落体中断:0x04 |
78+
79+
返回值:
80+
81+
​ 无
82+
83+
l **read_acceleration()**
84+
85+
​ 读取三轴加速度。
86+
87+
参数:
88+
89+
​ 无。
90+
91+
返回值:
92+
93+
| 名称 | 类型 | 说明 |
94+
| ------- | ----- | --------------------- |
95+
| (x,y,z) | tuple | x, y, z轴加速度,单位G |
96+
97+
98+
99+
l **process_single_tap ()**
100+
101+
​ 循环读取中断源寄存器,单击中断检测。
102+
103+
​ 注:未检测到中断则死循环,谨慎在主线程执行,执行前请确保单击中断使能并配置正确。
104+
105+
参数:
106+
107+
​ 无。
108+
109+
返回值:
110+
111+
​ 1:检测到单击中断
112+
113+
l **process_double_tap()**
114+
115+
​ 循环读取中断源寄存器,双击中断检测。
116+
117+
​ 注:未检测到中断则死循环,谨慎在主线程执行,执行前请确保双击中断使能并配置正确。
118+
119+
参数:
120+
121+
​ 无。
122+
123+
返回值:
124+
125+
​ 1:检测到双击中断
126+
127+
l **process_act ()**
128+
129+
​ 循环读取中断源寄存器,运动中断检测。
130+
131+
​ 注:未检测到中断则死循环,谨慎在主线程执行,执行前请确保运动中断使能并配置正确。
132+
133+
参数:
134+
135+
​ 无。
136+
137+
返回值:
138+
139+
​ 1:检测到运动中断
140+
141+
l **process_inact()**
142+
143+
​ 循环读取中断源寄存器,静止中断检测。
144+
145+
​ 注:未检测到中断则死循环,谨慎在主线程执行,执行前请确保静止中断使能并配置正确。
146+
147+
参数:
148+
149+
​ 无。
150+
151+
返回值:
152+
153+
​ 1:检测到静止中断
154+
155+
l **process_ff ()**
156+
157+
​ 循环读取中断源寄存器,自由落体中断检测。
158+
159+
​ 注:未检测到中断则死循环,谨慎在主线程执行,执行前请确保自由落体中断使能并配置正确。
160+
161+
参数:
162+
163+
​ 无。
164+
165+
返回值:
166+
167+
​ 1:检测到自由落体中断

libraries/ADXL346/adxl346.pdf

674 KB
Binary file not shown.

0 commit comments

Comments
 (0)