Skip to content

Commit 3ee9c47

Browse files
committed
Add README of battery module in English.
1 parent 3554d1e commit 3ee9c47

File tree

3 files changed

+218
-51
lines changed

3 files changed

+218
-51
lines changed

README-zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# QuecPython_lib_bundles 代码提交说明
22

3-
[[英文](./README.md)]
3+
[[English](./README.md)]
44

55
## 目录结构示例
66

libraries/battery/README-zh.md

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# 电池功能模块 用户指导手册
2+
3+
[[English](./README.md)]
4+
5+
## 简介
6+
7+
> 该模块用于查询当前设备的电池电量与电压, 设备的充电状态。
8+
9+
## API说明
10+
11+
### 实例化对象
12+
13+
**示例:**
14+
15+
```python
16+
from battery import Battery
17+
18+
adc_args = (adc_num, adc_period, factor)
19+
chrg_gpion = 0
20+
stdby_gpion = 1
21+
22+
battery = Battery(adc_args=adc_args, chrg_gpion=chrg_gpion, stdby_gpion=stdby_gpion)
23+
```
24+
25+
**参数:**
26+
27+
|参数|类型|说明|
28+
|:---|---|---|
29+
|adc_args|tuple|元素1: [ADC通道](https://python.quectel.com/doc/API_reference/zh/peripherals/misc.ADC.html#%E5%B8%B8%E9%87%8F), 元素2: ADC循环读取次数, 元素3: 计算系数, 可选|
30+
|chrg_gpion|int|CHRG (引脚 1):漏极开路输出的充电状态指示端。可选|
31+
|stdby_gpion|int|STDBY (引脚 5):电池充电完成指示端。可选|
32+
33+
### set_charge_callback
34+
35+
> 充电事件回调函数
36+
37+
**示例:**
38+
39+
```python
40+
def charge_callback(charge_status):
41+
print(charge_status)
42+
43+
res = battery.set_charge_callback(charge_callback)
44+
```
45+
46+
**参数:**
47+
48+
|参数|类型|说明|
49+
|:---|---|---|
50+
|charge_callback|function|充电事件回调函数, 回调函数参数为设备充电状态: 0-未充电;1-充电中;2-充电完成|
51+
52+
**返回值:**
53+
54+
|数据类型|说明|
55+
|:---|---|
56+
|bool|`True`成功, `False`失败|
57+
58+
### set_temp
59+
60+
> 设置当前设备所处工作环境温度, 用于计算设备电池电量
61+
62+
**示例:**
63+
64+
```python
65+
res = battery.set_temp(20)
66+
```
67+
68+
**参数:**
69+
70+
|参数|类型|说明|
71+
|:---|---|---|
72+
|temp|int/float|温度值, 单位:摄氏度 |
73+
74+
**返回值:**
75+
76+
|数据类型|说明|
77+
|:---|---|
78+
|bool|`True`成功, `False`失败|
79+
80+
### voltage
81+
82+
> 查询电池电压
83+
84+
**示例:**
85+
86+
```python
87+
battery.voltage
88+
# 523
89+
```
90+
91+
**返回值:**
92+
93+
|数据类型|说明|
94+
|:---|---|
95+
|int|电池电压, 单位mV。|
96+
97+
### energy
98+
99+
> 查询电池电量
100+
101+
**示例:**
102+
103+
```python
104+
res = battery.energy
105+
# 100
106+
```
107+
108+
**返回值:**
109+
110+
|数据类型|说明|
111+
|:---|---|
112+
|int|电池电量百分比, 0~100。|
113+
114+
### charge_status
115+
116+
> 查询充电状态
117+
118+
**示例:**
119+
120+
```python
121+
battery.charge_status
122+
# 1
123+
```
124+
125+
**返回值:**
126+
127+
|数据类型|说明|
128+
|:---|---|
129+
|int|0-未充电<br>1-充电中<br>2-充电完成|
130+
131+
## 使用示例
132+
133+
```python
134+
from battery import Battery
135+
136+
# 实例化对象
137+
adc_args = (adc_num, adc_period, factor)
138+
chrg_gpion = 0
139+
stdby_gpion = 1
140+
battery = Battery(adc_args=adc_args, chrg_gpion=chrg_gpion, stdby_gpion=stdby_gpion)
141+
142+
def charge_callback(charge_status):
143+
print(charge_status)
144+
145+
# 设置充电状态回调函数
146+
battery.set_charge_callback(charge_callback)
147+
# True
148+
149+
# 设置当前设备温度
150+
temp = 30
151+
battery.set_temp(temp)
152+
# True
153+
154+
# 获取当前电池电压
155+
battery.voltage
156+
# 3000
157+
158+
# 获取当前电池电量
159+
battery.energy
160+
# 100
161+
162+
# 获取当前充电状态
163+
battery.charge_status
164+
# 1
165+
166+
```

libraries/battery/README.md

+51-50
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# 电池功能模块 用户指导手册
1+
# Battery Module User Guide
22

3-
## 简介
3+
[[中文](./README-zh.md)]
44

5-
> 该模块用于查询当前设备的电池电量与电压, 设备的充电状态。
5+
## Introduction
66

7-
## API说明
7+
> This module is used to query the battery level, voltage, and charging status of the current device.
88
9-
### 实例化对象
9+
## API Documentation
1010

11-
**示例:**
11+
### Instantiate an Object
12+
13+
**Example:**
1214

1315
```python
1416
from battery import Battery
@@ -20,19 +22,19 @@ stdby_gpion = 1
2022
battery = Battery(adc_args=adc_args, chrg_gpion=chrg_gpion, stdby_gpion=stdby_gpion)
2123
```
2224

23-
**参数:**
25+
**Parameters:**
2426

25-
|参数|类型|说明|
27+
|Parameter|Type|Description|
2628
|:---|---|---|
27-
|adc_args|tuple|元素1: [ADC通道](https://python.quectel.com/doc/API_reference/zh/peripherals/misc.ADC.html#%E5%B8%B8%E9%87%8F), 元素2: ADC循环读取次数, 元素3: 计算系数, 可选|
28-
|chrg_gpion|int|CHRG (引脚 1):漏极开路输出的充电状态指示端。可选|
29-
|stdby_gpion|int|STDBY (引脚 5):电池充电完成指示端。可选|
29+
|`adc_args`|tuple|Element 1: [ADC channel](https://python.quectel.com/doc/API_reference/en/peripherals/misc.ADC.html#Constants).<br>Element 2: Number of ADC readings in a loop.<br>Element 3: Calculation factor, optional.|
30+
|`chrg_gpion`|int|CHRG (Pin 1): Charging status indication with open-drain output (Optional).|
31+
|`stdby_gpion`|int|STDBY (Pin 5): Battery charging completion indication (Optional).|
3032

3133
### set_charge_callback
3234

33-
> 充电事件回调函数
35+
> Charging event callback function
3436
35-
**示例:**
37+
**Example:**
3638

3739
```python
3840
def charge_callback(charge_status):
@@ -41,97 +43,96 @@ def charge_callback(charge_status):
4143
res = battery.set_charge_callback(charge_callback)
4244
```
4345

44-
**参数:**
46+
**Parameters:**
4547

46-
|参数|类型|说明|
48+
|Parameter|Type|Description|
4749
|:---|---|---|
48-
|charge_callback|function|充电事件回调函数, 回调函数参数为设备充电状态: 0-未充电;1-充电中;2-充电完成|
50+
|charge_callback|function|Charging event callback function, callback function parameter is the device charging status:<br>0 - not charging.<br>1 - charging.<br>2 - charging completed.|
4951

50-
**返回值:**
52+
**Returns:**
5153

52-
|数据类型|说明|
54+
|Data Type|Description|
5355
|:---|---|
54-
|bool|`True`成功, `False`失败|
56+
|bool|`True` for success, `False` for failure|
5557

5658
### set_temp
5759

58-
> 设置当前设备所处工作环境温度, 用于计算设备电池电量
60+
> Set the current working environment temperature of the device for calculating the device's battery level.
5961
60-
**示例:**
62+
**Example:**
6163

6264
```python
6365
res = battery.set_temp(20)
6466
```
6567

66-
**参数:**
68+
**Parameters:**
6769

68-
|参数|类型|说明|
70+
|Parameter|Type|Description|
6971
|:---|---|---|
70-
|temp|int/float|温度值, 单位:摄氏度 |
72+
|temp|int/float|Temperature value, unit: Celsius|
7173

72-
**返回值:**
74+
**Returns:**
7375

74-
|数据类型|说明|
76+
|Data Type|Description|
7577
|:---|---|
76-
|bool|`True`成功, `False`失败|
78+
|bool|`True` for success, `False` for failure|
7779

7880
### voltage
7981

80-
> 查询电池电压
82+
> Query the battery voltage
8183
82-
**示例:**
84+
**Example:**
8385

8486
```python
8587
battery.voltage
8688
# 523
8789
```
8890

89-
**返回值:**
91+
**Returns:**
9092

91-
|数据类型|说明|
93+
|Data Type|Description|
9294
|:---|---|
93-
|int|电池电压, 单位mV。|
95+
|int|Battery voltage, unit: mV|
9496

9597
### energy
9698

97-
> 查询电池电量
99+
> Query the battery level
98100
99-
**示例:**
101+
**Example:**
100102

101103
```python
102104
res = battery.energy
103105
# 100
104106
```
105107

106-
**返回值:**
108+
**Returns:**
107109

108-
|数据类型|说明|
110+
|Data Type|Description|
109111
|:---|---|
110-
|int|电池电量百分比, 0~100|
112+
|int|Battery level in percentage, 0~100|
111113

112114
### charge_status
113115

114-
> 查询充电状态
116+
> Query the charging status
115117
116-
**示例:**
118+
**Example:**
117119

118120
```python
119121
battery.charge_status
120-
# 1
121122
```
122123

123-
**返回值:**
124+
**Returns:**
124125

125-
|数据类型|说明|
126+
|Data Type|Description|
126127
|:---|---|
127-
|int|0-未充电<br>1-充电中<br>2-充电完成|
128+
|int|0 - Not charging<br>1 - Charging<br>2 - Charging completed|
128129

129-
## 使用示例
130+
## Usage Example
130131

131132
```python
132133
from battery import Battery
133134

134-
# 实例化对象
135+
# Instantiate the object
135136
adc_args = (adc_num, adc_period, factor)
136137
chrg_gpion = 0
137138
stdby_gpion = 1
@@ -140,24 +141,24 @@ battery = Battery(adc_args=adc_args, chrg_gpion=chrg_gpion, stdby_gpion=stdby_gp
140141
def charge_callback(charge_status):
141142
print(charge_status)
142143

143-
# 设置充电状态回调函数
144+
# Set the charging status callback function
144145
battery.set_charge_callback(charge_callback)
145146
# True
146147

147-
# 设置当前设备温度
148+
# Set the current device temperature
148149
temp = 30
149150
battery.set_temp(temp)
150151
# True
151152

152-
# 获取当前电池电压
153+
# Get the current battery voltage
153154
battery.voltage
154155
# 3000
155156

156-
# 获取当前电池电量
157+
# Get the current battery level
157158
battery.energy
158159
# 100
159160

160-
# 获取当前充电状态
161+
# Get the current charging status
161162
battery.charge_status
162163
# 1
163164

0 commit comments

Comments
 (0)