diff --git a/docs/Advanced_development/zh/QuecPythonBus/ExtInt.md b/docs/Advanced_development/zh/QuecPythonBus/ExtInt.md
index a99f7ddbe0c4b709fa9e1944eeb7a5ac28daf57d..343c8da4b7969777b1227ad9fdbc99a23ad6c796 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/ExtInt.md
+++ b/docs/Advanced_development/zh/QuecPythonBus/ExtInt.md
@@ -1,11 +1,10 @@
-## 外部中断
+# 外部中断实验
-### 修订历史
+## 修订历史
-| 版本 | 日期 | 作者 | 变更描述 |
-| ---- | ---------- | ------- | -------------------------- |
-| 1.0 | 2021-09-22 | Grey.Tu | 初版修订 |
-| 1.1 | 2021-10-09 | Rivern | 新增Helios Service进阶用法 |
+| 版本 | 日期 | 作者 | 变更表述 |
+| ---- | ---------- | ------- | -------- |
+| 1.0 | 2021-09-22 | Grey.Tu | 初版 |
文档主要介绍如何实现 ExtInt 检测外部中断,从硬件设计和软件设计两方面讲解,通过阅读本文,您将学会 ExtInt 外部中断功能使用。
@@ -13,7 +12,7 @@
-### 硬件设计
+## 硬件设计
ExtInt 外部中断原理为检测 PIN 脚外部电平转变,既 PIN 脚上有上升沿或下降沿信号。
@@ -23,11 +22,11 @@ ExtInt 外部中断原理为检测 PIN 脚外部电平转变,既 PIN 脚上有

-### 软件设计
+## 软件设计
首先确定要控制硬件的哪个引脚,然后通过官网的 API 类库找到对应的 GPIO 编号 。详解请参考 [QuecPython-machine - ExtInt](https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=extint)
-例: EC600S/N的引脚10为GPIO1。
+例: EC600U的引脚60为GPIO4。
开始编写代码,选择对应的 GPIO 进行 ExtInt 外部中断初始化:
@@ -39,104 +38,19 @@ def callback(args):
print('interrupt: {}'.format(args))
-extint13 = ExtInt(ExtInt.GPIO13, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # 创建对象
-extint12 = ExtInt(ExtInt.GPIO12, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # 创建对象
-extint13.enable() # 使能中断
-extint12.enable() # 使能中断
-print('开启GPIO: {}中断. \r\n'.format(extint13.line()))
-print('开启GPIO: {}中断. \r\n'.format(extint12.line()))
+extint = ExtInt(ExtInt.GPIO4, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # Create object
+extint.enable() # Enable interrupt
+print('Start GPIO: {}Interrupt. \r\n'.format(extint.line()))
-# extint13.disable() # 关闭中断
-# extint12.disable() # 关闭中断
+# extint.disable() # Disable interrupt
```
-配套代码
+
-### 配套代码
+> 注:屏幕截图显示的代码运行结果基于EC600U_EVB 1.3, GPIO 4分别对应pin60, 即EVB上的KEY 1.
+
+## 配套代码
下载代码
-### Helios Service进阶用法
-
-在学习本内容前需先了解[Helios Service](../HeliosService/HeliosService_1.md)内容
-
-需要用的代码有Helios service框架代码,代码获取:[https://gitee.com/quecpython/helios-service](https://gitee.com/quecpython/helios-service)
-
-以及**quec_key.py**,代码如下
-
-```python
-# 注意以下代码需基于helios service框架使用
-# 代码获取:https://gitee.com/quecpython/helios-service
-from machine import Pin, ExtInt
-from usr.bin.third_party.ql_interrupter import BusExIntInterrupter
-from usr.bin.third_party.ql_interrupter import TimerInterrupter
-import sys_bus
-
-#按下对应的沿
-KEY_PR = 1
-KEY_RES = 0
-
-#按键对应状态
-KEY_PRESS = 0 #长按
-KEY_DOWN = 1 #按下
-KEY_UP = 2 #抬起
-
-
-class KeyProcess(object):
- def __init__(self, gpio_num, gpio_timeout, gpio_callback):
- self.__name = "KEY_" + str(gpio_num)
-
- if(self.__name in sys_bus.sub_table()):
- print(self.__name,'in sub_table')
- sys_bus.unsubscribe(self.__name)
-
- self.__key = BusExIntInterrupter(self.__name, gpio_num, trige_mode=ExtInt.IRQ_RISING_FALLING, pull_mode=ExtInt.PULL_PU)
- self.__timer = TimerInterrupter(gpio_timeout, self.fun_cb, 0)
- self.__gpio = gpio_num
- self.__callback = gpio_callback
- sys_bus.subscribe(self.__name, self.extint_cb)
-
- def process(self, state):
- key_put = [self.__gpio, state]
- #print('key_put==={}'.format(key_put))
- self.__callback(key_put)
-
- def __del__(self):
- print("del gpio:",self.__name)
- sys_bus.unsubscribe(self.__name)
- self.__timer.stop()
-
- def fun_cb(self, *args, **kwargs):
- self.process(KEY_PRESS)
-
- def extint_cb(self,topic,msg):
- #print(topic,msg)
- if(msg['pressure'] == KEY_PR):
- self.__timer.start()
- self.process(KEY_DOWN)
- else:
- self.__timer.stop()
- self.process(KEY_UP)
-
-
-"""
-使用如下:
-from usr.quec_key import KeyProcess
-from machine import Pin
-
-def fun(para):
- print(para) #para[0] 管脚名 para[1]: 0 长按, 1 按下, 2 弹起
-
-
-aa = KeyProcess(Pin.GPIO13, 1000, fun) #gpio13, 按下1000ms为长按, 回调函数为 fun
-bb = KeyProcess(Pin.GPIO12, 3000, fun)
-"""
-```
-
-
-
-
-
-> 注意: 截图代码运行结果基于开发板1.3版本实现,GPIO12、13对应Pin59、60,即是开发板的KEY1、KEY2按键
-
diff --git a/docs/Advanced_development/zh/QuecPythonBus/button.md b/docs/Advanced_development/zh/QuecPythonBus/button.md
index acfec324500112026c303a12032867fa95005da6..a8e5c6b5eee96f32a5adcf29a3ad2f30ba8a2f8a 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/button.md
+++ b/docs/Advanced_development/zh/QuecPythonBus/button.md
@@ -26,7 +26,7 @@ EC600x 开发板引出了两个 PIN 脚供客户实验按键输入实验。
首先确定要检测的硬件引脚是那一个 GPIO ,我们通过官网的 API 类库找到对应的 GPIO编号 。详解请参考 [QuecPython-machine - PIN](https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=pin)
-例: EC600S/N的引脚10为GPIO1。
+例: EC600U的引脚60为GPIO6。
而我们 EC600x 开发板两个按键 PIN59/PIN60,对应EC600S/N为:PIN59 => GPIO12;PIN60 => GPIO13。对应EC600U为:PIN60 => GPIO4;PIN59 无对应 GPIO,不能进行按键输入检测。这边我们实现一个按键的按键检测功能。
@@ -38,8 +38,8 @@ from machine import Pin
if __name__ == '__main__':
- gpio13 = Pin(Pin.GPIO13, Pin.IN, Pin.PULL_PU, 1) # EC600S/N开发板使用
- # gpio13 = Pin(Pin.GPIO4, Pin.IN, Pin.PULL_PU, 1) # EC600U开发板使用
+ # gpio13 = Pin(Pin.GPIO13, Pin.IN, Pin.PULL_PU, 1) # EC600S/N
+ gpio13 = Pin(Pin.GPIO4, Pin.IN, Pin.PULL_PU, 1) # EC600U
while True:
if gpio13.read() == 0:
utime.sleep_ms(10)
diff --git a/docs/Advanced_development/zh/QuecPythonBus/buzzer.md b/docs/Advanced_development/zh/QuecPythonBus/buzzer.md
index dea729e4b9194330dc65e43f30fa25a57654df80..7ddf1c1fcb526f92962161043d9277a453e0f2eb 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/buzzer.md
+++ b/docs/Advanced_development/zh/QuecPythonBus/buzzer.md
@@ -5,8 +5,8 @@
| 版本 | 日期 | 作者 | 变更表述 |
|------|------|------|------|
| 1.0 | 2021-03-20 | gary.zhou | 初版 |
-| 1.1 | 2021-09-15 | Grey.Tu | 修改有源蜂鸣器控制为无源蜂鸣器控制. |
-| 1.2 | 2021-12-07 | Grey.Tu | 勘误. |
+| 1.1 | 2021-09-15 | Grey.Tu | 修改有源蜂鸣器绘制为无源蜂鸣器控绘制. |
+| 1.2 | 2021-11-29 | Grey.Tu | 勘误. |
文档主要介绍如何 PWM 控制 **无源蜂鸣器** ,使 **无源蜂鸣器** 发声。从硬件设计和软件设计两方面讲解,通过阅读本文,可以学习 PWM 基本使用。
@@ -44,92 +44,47 @@
### **实验代码**
```python
-
from misc import PWM
import utime as time
import urandom as random
import log
-# API https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=pwm
-# 蜂鸣器模块 https://detail.tmall.com/item.htm?id=41251333522
-# 无源蜂鸣器-频率可控版
-
-"""
-
-pwm0 = PWM(PWM.PWMn,PWM.ABOVE_xx,highTime,cycleTime)
-
-注:EC600SCN平台,支持PWM0-PWM3,对应引脚如下:
-
-PWM0 – 引脚号52
-
-PWM1 – 引脚号53
-
-PWM2 – 引脚号70
-
-PWM3 – 引脚号69
-
-"""
-
-# 获取logger对象
+# Creating log object
buzzer_log = log.getLogger("buzzer_test")
-# Duration 为 ms
-
+# Duration: ms
def outputpwm(HZ, duty_cycle, Duration):
-
- # 将HZ 转化为 10us 级别
-
cycleTime = int((10000000/HZ)/10)
highTime = int(cycleTime * duty_cycle)
-
- # 输出debug级别的日志
-
buzzer_log.debug(
"""out put pin70 cycleTime {0} * 10us,
highTime {1} * 10us, Duration of {2}"""
.format(cycleTime, highTime, Duration))
- pwm1 = PWM(PWM.PWM2, PWM.ABOVE_10US, highTime, cycleTime)
+ pwm1 = PWM(PWM.PWM0, PWM.ABOVE_10US, highTime, cycleTime)
pwm1.open()
-
- # 休眠给定毫秒数的时间
-
time.sleep_ms(Duration)
pwm1.close()
pass
def test_Buzzer():
-
- #设置日志输出级别
-
+ # Set the log output level
log.basicConfig(level=log.DEBUG)
-
- # 循环遍历10次
-
+ # Loop 10 times
for i in range(10):
-
- # 随机生成 start 到 end 范围内的浮点数,范围可以自己选择, 0~1
-
+ # Random generation of floating point numbers in the start to end range, optionally, 0~1
duty_cycle = random.uniform(0.1, 0.8)
-
- # 建议输出2000~5000HZ 的PWM波形
- # 随机生成一个 start 到 end 之间的整数
-
+ # Suggested that the output2000~5000HZ_PWM waveform
+ # Generate a random start ~ end Integer between
HZ = random.randint(2000, 5000)
outputpwm(HZ, duty_cycle, 500)
time.sleep_ms(1500)
-
pass
if __name__ == "__main__":
-
- # creat a thread Check key status
-
test_Buzzer()
-
-# 将代码下载运行,可以听到蜂鸣器产生随机的声音
```
## 配套代码
diff --git a/docs/Advanced_development/zh/QuecPythonBus/code/code_ExtInt.py b/docs/Advanced_development/zh/QuecPythonBus/code/code_ExtInt.py
index 241ccd79ca3130dce058c71b9577fac8dc4b6da7..c809acdd77710b2e51a80daf1c49e3f6aed7eb3d 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/code/code_ExtInt.py
+++ b/docs/Advanced_development/zh/QuecPythonBus/code/code_ExtInt.py
@@ -1,29 +1,12 @@
from machine import ExtInt
-import utime as time
-# PIN脚及API介绍请参考 https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=extint
-state = 10 # 测试次数
def callback(args):
print('interrupt: {}'.format(args))
-def main():
- extint13 = ExtInt(ExtInt.GPIO13, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # 创建对象
- extint12 = ExtInt(ExtInt.GPIO12, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # 创建对象
- extint13.enable() # 使能中断
- extint12.enable() # 使能中断
- print('开启GPIO: {}中断. \r\n'.format(extint13.line()))
- print('开启GPIO: {}中断. \r\n'.format(extint12.line()))
- # 等待按键按下,触发
- while state:
- time.sleep_ms(1)
- pass
- # 停止映射外部中断
- extint13.disable() # 关闭中断
- extint12.disable() # 关闭中断
- print("The main function has exited")
+extint = ExtInt(ExtInt.GPIO4, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, callback) # Create object
+extint.enable() # Enable interrupt
+print('Start GPIO: {} Interrupt. \r\n'.format(extint.line()))
-
-if __name__ == "__main__":
- main()
+# extint.disable() # Disable interrupt
diff --git a/docs/Advanced_development/zh/QuecPythonBus/code/code_UART_CDC.py b/docs/Advanced_development/zh/QuecPythonBus/code/code_UART_CDC.py
index a8d288d5ef5c2687598f5a9bd78c390b6eb664ab..5ab92c748c49688687c59ba17354f2bd16a1252f 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/code/code_UART_CDC.py
+++ b/docs/Advanced_development/zh/QuecPythonBus/code/code_UART_CDC.py
@@ -8,17 +8,6 @@ state = 1
uart_x = None
usbcdc = None
-# # | 参数 | 参数类型 | 说明 |
-# # | -------- | ------- | ------------------ |
-# # | CRITICAL | 常量 | 日志记录级别的数值 50 |
-# # | ERROR | 常量 | 日志记录级别的数值 40 |
-# # | WARNING | 常量 | 日志记录级别的数值 30 |
-# # | INFO | 常量 | 日志记录级别的数值 20 |
-# # | DEBUG | 常量 | 日志记录级别的数值 10 |
-# # | NOTSET | 常量 | 日志记录级别的数值 0 |
-# log.basicConfig(level=log.CRITICAL) # 设置日志输出级别
-# log = log.getLogger("Grey") # 获取logger对象,如果不指定name则返回root对象,多次使用相同的name调用getLogger方法返回同一个logger对象
-
def uart_x_read():
global state
@@ -26,14 +15,14 @@ def uart_x_read():
global usbcdc
while state:
- msglen = uart_x.any() # 返回是否有可读取的数据长度
- if msglen: # 当有数据时进行读取
- msg = uart_x.read(msglen) # 读取数据
- utf8_msg = msg.decode() # 初始数据是字节类型(bytes),将字节类型数据进行编码
+ msglen = uart_x.any() # Returns whether there is a readable length of data
+ if msglen: # Read when data is available
+ msg = uart_x.read(msglen) # Read Data
+ utf8_msg = msg.decode() # The initial data is byte type (bytes), which encodes byte type data
if "Grey" in utf8_msg:
break
else:
- usbcdc.write("{}".format(utf8_msg)) # 发送数据
+ usbcdc.write("{}".format(utf8_msg)) # send data
utime.sleep_ms(1)
state = 0
@@ -44,27 +33,27 @@ def usbcdc_read():
global usbcdc
while state:
- msglen = usbcdc.any() # 返回是否有可读取的数据长度
- if msglen: # 当有数据时进行读取
- msg = usbcdc.read(msglen) # 读取数据
- utf8_msg = msg.decode() # 初始数据是字节类型(bytes),将字节类型数据进行编码
+ msglen = usbcdc.any() # Returns whether there is a readable length of data
+ if msglen: # Read when data is available
+ msg = usbcdc.read(msglen) # Read Data
+ utf8_msg = msg.decode() # The initial data is byte type (bytes), which encodes byte type data
if "Grey" in utf8_msg:
break
else:
- uart_x.write("{}".format(utf8_msg)) # 发送数据
+ uart_x.write("{}".format(utf8_msg)) # send data
utime.sleep_ms(1)
state = 0
if __name__ == "__main__":
uart_x = UART(UART.UART2, 115200, 8, 0, 1, 0)
- usbcdc = UART(UART.UART3, 115200, 8, 0, 1, 0)
+ usbcdc = UART(UART.UART3, 115200, 8, 0, 1, 0) # It is unvalid to set the baudrate, while in communication, any baudrate is available
- uart_x.write("Grey_测试")
- usbcdc.write("Grey_测试")
+ uart_x.write("Grey_test")
+ usbcdc.write("Grey_test")
- _thread.start_new_thread(uart_x_read, ()) # 创建一个线程来监听接收uart消息
- _thread.start_new_thread(usbcdc_read, ()) # 创建一个线程来监听接收CDC消息
+ _thread.start_new_thread(uart_x_read, ()) # Create a thread to listen for receiving UART messages
+ _thread.start_new_thread(usbcdc_read, ()) # Create a thread to listen for receiving CDC messages
while state:
utime.sleep_ms(1)
diff --git a/docs/Advanced_development/zh/QuecPythonBus/code/code_button.py b/docs/Advanced_development/zh/QuecPythonBus/code/code_button.py
index 097c0992ad2c319c7eabecbc90f4caa34713697c..1d5e635af178fb750a4350440290cfd3f59667cb 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/code/code_button.py
+++ b/docs/Advanced_development/zh/QuecPythonBus/code/code_button.py
@@ -3,13 +3,12 @@ from machine import Pin
if __name__ == '__main__':
- gpio13 = Pin(Pin.GPIO13, Pin.IN, Pin.PULL_PU, 1) # EC600S/N开发板使用
- # gpio13 = Pin(Pin.GPIO4, Pin.IN, Pin.PULL_PU, 1) # EC600U开发板使用
+ gpio = Pin(Pin.GPIO4, Pin.IN, Pin.PULL_PU, 1)
while True:
- if gpio13.read() == 0:
+ if gpio.read() == 0:
utime.sleep_ms(10)
- if gpio13.read() == 0:
- while gpio13.read() == 0:
+ if gpio.read() == 0:
+ while gpio.read() == 0:
pass
- print("GPIO13按下")
- pass
+ print("Button press")
+ pass
\ No newline at end of file
diff --git a/docs/Advanced_development/zh/QuecPythonBus/code/code_buzzer.py b/docs/Advanced_development/zh/QuecPythonBus/code/code_buzzer.py
index 5225c7bbaed9b85736d1dad9b7cd261fc11b6215..73f469e8a09c020b4e0f0b14a50ec68e7a2c0b49 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/code/code_buzzer.py
+++ b/docs/Advanced_development/zh/QuecPythonBus/code/code_buzzer.py
@@ -3,81 +3,39 @@ import utime as time
import urandom as random
import log
-# API https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=pwm
-# 蜂鸣器模块 https://detail.tmall.com/item.htm?id=41251333522
-# 无源蜂鸣器-频率可控版
-
-"""
-
-pwm0 = PWM(PWM.PWMn,PWM.ABOVE_xx,highTime,cycleTime)
-
-注:EC600SCN平台,支持PWM0-PWM3,对应引脚如下:
-
-PWM0 – 引脚号52
-
-PWM1 – 引脚号53
-
-PWM2 – 引脚号70
-
-PWM3 – 引脚号69
-
-"""
-
-# 获取logger对象
+# Creating log object
buzzer_log = log.getLogger("buzzer_test")
-# Duration 为 ms
-
+# Duration: ms
def outputpwm(HZ, duty_cycle, Duration):
-
- # 将HZ 转化为 10us 级别
-
cycleTime = int((10000000/HZ)/10)
highTime = int(cycleTime * duty_cycle)
-
- # 输出debug级别的日志
-
buzzer_log.debug(
"""out put pin70 cycleTime {0} * 10us,
highTime {1} * 10us, Duration of {2}"""
.format(cycleTime, highTime, Duration))
- pwm1 = PWM(PWM.PWM2, PWM.ABOVE_10US, highTime, cycleTime)
+ pwm1 = PWM(PWM.PWM0, PWM.ABOVE_10US, highTime, cycleTime)
pwm1.open()
-
- # 休眠给定毫秒数的时间
-
time.sleep_ms(Duration)
pwm1.close()
pass
def test_Buzzer():
-
- #设置日志输出级别
-
+ # Set the log output level
log.basicConfig(level=log.DEBUG)
-
- # 循环遍历10次
-
+ # Loop 10 times
for i in range(10):
-
- # 随机生成 start 到 end 范围内的浮点数,范围可以自己选择, 0~1
-
+ # Random generation of floating point numbers in the start to end range, optionally, 0~1
duty_cycle = random.uniform(0.1, 0.8)
-
- # 建议输出2000~5000HZ 的PWM波形
- # 随机生成一个 start 到 end 之间的整数
-
+ # Suggested that the output2000~5000HZ_PWM waveform
+ # Generate a random start ~ end Integer between
HZ = random.randint(2000, 5000)
outputpwm(HZ, duty_cycle, 500)
time.sleep_ms(1500)
-
pass
if __name__ == "__main__":
-
- # creat a thread Check key status
-
test_Buzzer()
\ No newline at end of file
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_1.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_1.jpg
index 41421feb83f7955a3de178e949d94ed47a6287ea..cf6d368d8dbe87eea00ddcba750dea410b43c76e 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_1.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_1.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_3.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_3.jpg
index 5f7d9a8fdcc6186a90a06efeaced6fcf0e872fe4..3c6063497b470c4ec9f68dfa136a56e41fe5de04 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_3.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_3.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_4.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_4.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..12005e17aa06bf8ca000db460be0bb30b69593aa
Binary files /dev/null and b/docs/Advanced_development/zh/QuecPythonBus/media/media_ExtInt_4.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_UART_3.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_UART_3.jpg
index 042fc4cfc8b4c1ccdc900ca31be90588cfcace38..f312ebcc7c2bc04954106c7f8f3e9c263e44edcb 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_UART_3.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_UART_3.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_button_2.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_button_2.jpg
index 5f7d9a8fdcc6186a90a06efeaced6fcf0e872fe4..e68fc1d5f1ebc772be8d4431fab34bc0647dc204 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_button_2.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_button_2.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_button_4.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_button_4.jpg
index 80bd9f7dd8497851cab1c8ea92455a595be6a9a7..2e63b9e29dc683fea579228b7fda06507ca202aa 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_button_4.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_button_4.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_1.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_1.jpg
index 08655fb0aca59b86c0c8c0c856522fe0f440cd1a..4d29a3cf7d9f71fce80bb55373fa486fb8f84830 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_1.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_1.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_2.jpg b/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_2.jpg
index 04f1abf9f20c5d03199c9f018b7fb957cc5db9b4..b73ee663bccb8f77399042d8abaa89c12db8711e 100644
Binary files a/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_2.jpg and b/docs/Advanced_development/zh/QuecPythonBus/media/media_buzzer_2.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonBus/uart.md b/docs/Advanced_development/zh/QuecPythonBus/uart.md
index 9fd997311654bce2958ac7c9594f0385401a8beb..483455ef3b98d1320d366ece89f939d0963bd0b7 100644
--- a/docs/Advanced_development/zh/QuecPythonBus/uart.md
+++ b/docs/Advanced_development/zh/QuecPythonBus/uart.md
@@ -37,23 +37,65 @@
USB CDC PORT 为USB虚拟的串行通信口,此通信口采用 UART 一样的通信协议,但并未真正意义的 UART。它的通信速率不受 UART 波特率的限制,可根据USB协议自动设别。可以更快速率的传输数据,也无需固定波特率的繁琐。
```python
+# import log
+import utime
+import _thread
+import ubinascii
from machine import UART
-uart_x = UART(UART.UART2, 115200, 8, 0, 1, 0)
-usbcdc = UART(UART.UART3, 115200, 8, 0, 1, 0) # 此波特率设置无效, 通信时可以任意波特率
-
-while True:
- uart_x_msglen = uart_x.any()
- if uart_x_msglen:
- uart_x_msg = uart_x.read(uart_x_msglen)
- uart_x_utf8_msg = uart_x_msg.decode()
- usbcdc.write("{}".format(uart_x_utf8_msg))
-
- usbcdc_msglen = usbcdc.any()
- if usbcdc_msglen:
- usbcdc_msg = usbcdc.read(usbcdc_msglen)
- usbcdc_utf8_msg = usbcdc_msg.decode()
- uart_x.write("{}".format(usbcdc_utf8_msg))
+state = 1
+uart_x = None
+usbcdc = None
+
+
+def uart_x_read():
+ global state
+ global uart_x
+ global usbcdc
+
+ while state:
+ msglen = uart_x.any() # Returns whether there is a readable length of data
+ if msglen: # Read when data is available
+ msg = uart_x.read(msglen) # Read Data
+ utf8_msg = msg.decode() # The initial data is byte type (bytes), which encodes byte type data
+ if "Grey" in utf8_msg:
+ break
+ else:
+ usbcdc.write("{}".format(utf8_msg)) # send data
+ utime.sleep_ms(1)
+ state = 0
+
+
+def usbcdc_read():
+ global state
+ global uart_x
+ global usbcdc
+
+ while state:
+ msglen = usbcdc.any() # Returns whether there is a readable length of data
+ if msglen: # Read when data is available
+ msg = usbcdc.read(msglen) # Read Data
+ utf8_msg = msg.decode() # The initial data is byte type (bytes), which encodes byte type data
+ if "Grey" in utf8_msg:
+ break
+ else:
+ uart_x.write("{}".format(utf8_msg)) # send data
+ utime.sleep_ms(1)
+ state = 0
+
+
+if __name__ == "__main__":
+ uart_x = UART(UART.UART2, 115200, 8, 0, 1, 0)
+ usbcdc = UART(UART.UART3, 115200, 8, 0, 1, 0) # It is unvalid to set the baudrate, while in communication, any baudrate is available
+
+ uart_x.write("Grey_test")
+ usbcdc.write("Grey_test")
+
+ _thread.start_new_thread(uart_x_read, ()) # Create a thread to listen for receiving UART messages
+ _thread.start_new_thread(usbcdc_read, ()) # Create a thread to listen for receiving CDC messages
+
+ while state:
+ utime.sleep_ms(1)
```
运行上面的脚本代码,便可实现物理 UART2 与 USB CDC PORT 的数据透传。
diff --git a/docs/Advanced_development/zh/QuecPythonSub/LCD.md b/docs/Advanced_development/zh/QuecPythonSub/LCD.md
index 142050339a181b44916522e85a632e00bd343b4b..0c34a38e182e92fd831e09cb0433b079563db274 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/LCD.md
+++ b/docs/Advanced_development/zh/QuecPythonSub/LCD.md
@@ -80,52 +80,52 @@
本章封装了部分 API 函数。 在介绍这些 API 之前,我们先了解一下已固件中提供的函数接口。这里我们主要介绍 LCD 初始化函数,其他函数较为简单,请自行参考:[QuecPython-machine - LCD](https://python.quectel.com/wiki/#/zh-cn/api/QuecPythonClasslib?id=lcd) 进行了解。
```python
-# lcd.lcd_init函数参数说明
-# lcd_init_data: 传入LCD的配置命令
-# lcd_width: LCD屏幕的宽度。宽度不超过 500
-# lcd_hight: LCD屏幕的高度。高度不超过 500
-# lcd_clk: LCD SPI时钟。SPI时钟为 6.5K/13K/26K/52K
-# data_line: 数据线数。参数值为 1 和 2。
-# line_num: 线的数量。参数值为 3 和 4。
-# lcd_type: 屏幕类型。0:rgb;1:fstn。
-# lcd_invalid: 传入LCD 区域设置的配置命令
-# lcd_display_on: 传入LCD 屏亮的配置命令
-# lcd_display_off: 传入LCD 屏灭的配置命令
-# lcd_set_brightness: 传入LCD屏亮度的配置命令。设置为 None表示由 LCD_BL_K 控制亮度(有些屏幕是由寄存器控制屏幕亮度,有 些是通过 LCD_BL_K 控制屏幕亮度)
+# lcd.lcd_ Init function parameter description
+# lcd_ init_ Data: incoming LCD configuration command
+# lcd_ Width: the width of the LCD screen. Width not exceeding 500
+# lcd_ High: the height of the LCD screen. Height not exceeding 500
+# lcd_ CLK: LCD SPI clock. SPI clock is 6.5k/13k/26k/52k
+# data_ Line: number of data lines. The parameter values are 1 and 2.
+# line_ Num: number of lines. The parameter values are 3 and 4.
+# lcd_ Type: screen type. 0:rgb; 1:fstn。
+# lcd_ Invalid: pass in the configuration command of LCD locale
+# lcd_ display_ On: pass in the configuration command of LCD screen
+# lcd_ display_ Off: pass in the configuration command of LCD screen off
+# lcd_ set_ Brightness: pass in the configuration command of LCD screen brightness. Set to none to indicate by LCD_ BL_ K controls the brightness (some screens are controlled by registers, and some are controlled by lcd_bl_k)
lcd.lcd_init(lcd_init_data, lcd_width, lcd_hight, lcd_clk, data_line, line_num, lcd_type, lcd_invalid, lcd_display_on, lcd_display_off, lcd_set_brightness)
```
下面通过实际代码介绍 LCD 初始化函数的参数传入。
```python
-from machine import LCD # 屏幕显示模块
-
-# 常用颜色定义
-red = 0xF800 # 红色
-green = 0x07E0 # 绿色
-blue = 0x001F # 蓝色
-white = 0xFFFF # 白色
-black = 0x0000 # 黑色
-purple = 0xF81F # 紫色
-colour = white # 默认背景色
-
-# 屏幕参数
-screen_high = 240 # 屏高
-screen_wide = 240 # 屏高
-XSTART_H = 0xf0 # 起始点X坐标高字节寄存器
-XSTART_L = 0xf1 # 起始点X坐标低字节寄存器
-XEND_H = 0xE0 # 结束点X坐标高字节寄存器
-XEND_L = 0xE1 # 结束点X坐标低字节寄存器
-YSTART_H = 0xf2 # 起始点Y坐标高字节寄存器
-YSTART_L = 0xf3 # 起始点Y坐标低字节寄存器
-YEND_H = 0xE2 # 结束点Y坐标高字节寄存器
-YEND_L = 0xE3 # 结束点Y坐标低字节寄存器
-
-# 屏幕初始化参数
-# 元组中三个元素为一组, 单组中每个元素定义如下:
-# 1: 类型, 0 表示命令; 1 表示数据; 2 表示延时
-# 2: 长度, 若类型为 0,则长度表示命令后的数据数量;若类型为 1,则长度表示数据的长度
-# 3: 参数值, 对应值
+from machine import LCD # Screen display module
+
+# Common color definitions
+red = 0xF800 # gules
+green = 0x07E0 # green
+blue = 0x001F # blue
+white = 0xFFFF # white
+black = 0x0000 # black
+purple = 0xF81F # purple
+colour = white # Default background color
+
+# Screen parameters
+screen_high = 240 # Screen height
+screen_wide = 240 # Screen height
+XSTART_H = 0xf0 # Start point X coordinate high byte register
+XSTART_L = 0xf1 # Start point X coordinate low byte register
+XEND_H = 0xE0 # End point X coordinate high byte register
+XEND_L = 0xE1 # End point X coordinate low byte register
+YSTART_H = 0xf2 # Start point y coordinate high byte register
+YSTART_L = 0xf3 # Start point y coordinate low byte register
+YEND_H = 0xE2 # End point y coordinate high byte register
+YEND_L = 0xE3 # End point y coordinate low byte register
+
+# Screen initialization parameters
+# Three elements in a tuple form a group, and each element in a single group is defined as follows:
+# 1: Type, 0 indicates command; 1 represents data; 2 indicates delay
+# 2: Length. If the type is 0, the length represents the amount of data after the command; If the type is 1, the length represents the length of the data
+# 3: Parameter value
init_data = (
0, 0, 0x11,
0, 1, 0x36,
@@ -204,11 +204,11 @@ init_data = (
0, 0, 0x2c,
)
-# 屏幕区域显示参数
-# 元组中三个元素为一组, 单组中每个元素定义如下:
-# 1: 类型, 0 表示命令; 1 表示数据; 2 表示延时
-# 2: 长度, 若类型为 0,则长度表示命令后的数据数量;若类型为 1,则长度表示数据的长度
-# 3: 参数值, 对应值
+# Screen area display parameters
+# Three elements in a tuple form a group, and each element in a single group is defined as follows:
+# 1: Type, 0 indicates command; 1 represents data; 2 indicates delay
+# 2: Length. If the type is 0, the length represents the amount of data after the command; If the type is 1, the length represents the length of the data
+# 3: Parameter value
lcd_set_display_area = (
0, 4, 0x2a,
1, 1, XSTART_H,
@@ -223,11 +223,11 @@ lcd_set_display_area = (
0, 0, 0x2c,
)
-lcd = LCD() # 创建对象
-lcd_init_data = bytearray(init_data) # 转换初始化参数数组
-lcd_invalid = bytearray(lcd_set_display_area) # 转换区域设定参数数组
+lcd = LCD() # create object
+lcd_init_data = bytearray(init_data) # Conversion initialization parameter array
+lcd_invalid = bytearray(lcd_set_display_area) # Conversion area setting parameter array
self.lcd.lcd_init(lcd_init_data, screen_high, screen_wide,
- 6500, 1, 4, 0, lcd_invalid, None, None, None) # 初始化LCD屏
+ 6500, 1, 4, 0, lcd_invalid, None, None, None) # Initialize LCD screen
```
### 封装API函数
@@ -471,16 +471,16 @@ lcd_st7789v = st7789v.ST7789V(240, 240)
import utime
'''
-如果用户使用的固件版本中没有checkNet库,请将checkNet.mpy文件上传到模块的usr目录,
-并将 import checkNet 改为 from usr import checkNet
+If there is no checknet Library in the firmware version used by the user, please upload the checknet.mpy file to the usr directory of the module,
+And change import checknet to from usr import checknet
'''
import checkNet
from usr import st7789v
# from usr import image
'''
-下面两个全局变量是必须有的,用户可以根据自己的实际项目修改下面两个全局变量的值,
-在执行用户代码前,会先打印这两个变量的值。
+The following two global variables are required. Users can modify the values of the following two global variables according to their actual projects,
+The values of these two variables are printed before executing the user code.
'''
PROJECT_NAME = "QuecPython_ST7789V_LCD_Example"
PROJECT_VERSION = "1.0.0"
@@ -491,22 +491,22 @@ lcd_st7789v = st7789v.ST7789V(240, 240)
if __name__ == '__main__':
'''
- 手动运行本例程时,可以去掉该延时,如果将例程文件名改为main.py,希望开机自动运行时,需要加上该延时,
- 否则无法从CDC口看到下面的 poweron_print_once() 中打印的信息
+When running this routine manually, you can remove the delay. If you change the routine file name to main.py, you need to add the delay when you want to start up and run automatically,
+Otherwise, the following poweron cannot be seen from the CDC port_ print_ Information printed in once()
'''
# utime.sleep(5)
checknet.poweron_print_once()
'''
- 如果用户程序包含网络相关代码,必须执行 wait_network_connected() 等待网络就绪(拨号成功);
- 如果是网络无关代码,可以屏蔽 wait_network_connected()
+If the user program contains network related code, wait must be executed_ network_ Connected() wait for the network to be ready (dialing succeeded);
+If it is a network independent code, you can mask the wait_ network_ connected()
'''
# checknet.wait_network_connected()
- # 用户代码
+ # user designation codes
'''######################【User code star】#####################################'''
- # 显示一张240*240大小的图片
+ # Display a 240 * 240 size picture
lcd_st7789v.lcd_show_image_file("usr/image.txt", 0, 0, 240, 240, 8)
'''######################【User code end 】#####################################'''
@@ -566,7 +566,7 @@ PCtoLCD2002 是一款字符取模软件,可以生成汉字、英文以及标
(1)打开 Image2Lcd 软件,点击【打开】按钮,选择要显示的图片;
-
+
(2)输出数据类型选择【C语言数组(*.c)】,扫描方式选择【水平扫描】,输出灰度一定要选择【16位真彩色】;
@@ -576,7 +576,7 @@ PCtoLCD2002 是一款字符取模软件,可以生成汉字、英文以及标
-### 如何对字符取模
+### 如何对字符取模(英文客户无需关注)
(1)打开 PCtoLCD2002 软件,依次点击【模式】-【字符模式(W)】;
@@ -596,4 +596,4 @@ PCtoLCD2002 是一款字符取模软件,可以生成汉字、英文以及标
## 配套代码
- 下载实验材料
\ No newline at end of file
+ 下载实验材料
\ No newline at end of file
diff --git a/docs/Advanced_development/zh/QuecPythonSub/code/LCD_file.7z b/docs/Advanced_development/zh/QuecPythonSub/code/LCD_file.7z
new file mode 100644
index 0000000000000000000000000000000000000000..64f58ec2fbb672b6c652012705888a1d4ebf3f45
Binary files /dev/null and b/docs/Advanced_development/zh/QuecPythonSub/code/LCD_file.7z differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/code/code_ebf_smd4805.py b/docs/Advanced_development/zh/QuecPythonSub/code/code_ebf_smd4805.py
index ee9ac94fef04638b31b41e9a0017bf11a585210f..558fc17352dec53107aa96e044494f669bff056d 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/code/code_ebf_smd4805.py
+++ b/docs/Advanced_development/zh/QuecPythonSub/code/code_ebf_smd4805.py
@@ -11,25 +11,23 @@ Copyright 2021 - 2021 quectel
'''
"""
-参考资料
+reference material
1. API
-https://python.quectel.com/wiki/#/zh-cn/api/?id=pwm
-https://python.quectel.com/wiki/#/zh-cn/api/?id=pin
-2. 模块资料
+https://python.quectel.com/wiki/#/en-us/api/QuecPythonClasslib?id=pwm
+https://python.quectel.com/wiki/#/en-us/api/QuecPythonClasslib?id=pin
+2. Module data
https://item.taobao.com/item.htm?ft=t&id=543053172983
-步进电机驱动器 + 42步进电机
-2.1 模块开发资料
https://ebf-products.readthedocs.io/zh_CN/latest/module/motor/ebf-msd4805.html
"""
"""
-引脚连接
-| 电机 | EC600开发板 | 对应的函数标号 |
-| ---------- | ------------------ | ------- |
-| ENA- (GPIO) | GPIO81 (引脚号16) | GPIO7 |
-| DIR- (GPIO) | GPIO77 (引脚号15) | GPIO6 |
-| PUL- (PWM) | GPIO2_1V8 (引脚号70) | PWM2 |
-| ENA+ DIR+ PUL+ | 1V8(电源) | 无 |
+Pin connection
+| electrical machinery | development board | The corresponding function label |
+| -------------------- | ----------------- | -------------------------------- |
+| ENA- (GPIO) | GPIO81 (pin 16) | GPIO7 |
+| DIR- (GPIO) | GPIO77 (pin15) | GPIO6 |
+| PUL- (PWM) | GPIO2_1V8 (pin70) | PWM2 |
+| ENA+ DIR+ PUL+ | 1V8(power supply) | 无 |
"""
@@ -61,21 +59,21 @@ class ebf_smd4805():
dev_log = None
- # 步进电机的参数
- sm_para_step = None # 步进角度
- # 控制器的参数
- env_pin = None # 使能引脚
- dir_pin = None # 方向引脚
- pul_pwm = None # 脉冲输出引脚
- ctrl_divstep = None # 细分参数,具体请参考控制器手册
+ # Parameters of stepping motor
+ sm_para_step = None # Step angle
+ # Parameters of controller
+ env_pin = None # Enable pin
+ dir_pin = None # Direction pin
+ pul_pwm = None # Pulse output pin
+ ctrl_divstep = None # For subdivision parameters, please refer to the controller manual
def init(self, step, divstep):
self.dev_log = log.getLogger("ebf_smd4805")
self.env_pin = Pin(Pin.GPIO7, Pin.OUT, Pin.PULL_DISABLE, 0)
self.dir_pin = Pin(Pin.GPIO6, Pin.OUT, Pin.PULL_DISABLE, 0)
- # 配置电机的参数
+ # Configure the parameters of the motor
self.sm_para_step = step
- # 配置控制器的参数
+ # Configure the parameters of the controller
self.ctrl_divstep = divstep
def reset(self):
@@ -84,23 +82,23 @@ class ebf_smd4805():
if self.pul_pwm is not None:
self.pul_pwm.close()
- # 根据频率 初始化PWM
+ # Initialize PWM according to frequency
def outputpwm(self, HZ, duty_cycle):
- # 将HZ 转化为 us 级别
+ # Convert Hz to us level
cycleTime = int(1000000/HZ)
highTime = int(cycleTime * duty_cycle)
return highTime, cycleTime
- # 根据速度,设置PWM的输出
+ # Set the output of PWM according to the speed
def enable_pwm(self, speed):
- # 1. 首先根据步进电机的步进角度,计算旋转一圈需要多少个脉冲
+ # 1. First, calculate the number of pulses required for one revolution according to the stepping angle of the stepping
Count_pulse = int(360/self.sm_para_step)
self.dev_log.debug("sm motor step as {0}".format(Count_pulse))
- # 2. 根据控制器的细分参数,计算控制器控制步进电机旋转一圈,需要多少的脉冲
+ # 2. According to the subdivision parameters of the controller, calculate the number of pulses required for the controller to control the stepper motor to rotate for one turn
Count_pulse = int(Count_pulse * self.ctrl_divstep)
- # 3. 最后计算出1秒旋转speed圈,需要多少个脉冲 , 换句话说 就是频率
+ # 3. Finally, calculate how many pulses are needed to rotate the speed cycle in one second, in other words, the frequency
Count_pulse = int(Count_pulse * speed)
- # 4. 初始化PWM, 默认占空比%50
+ # 4. Initialize PWM, default duty cycle% 50
highTime, cycleTime = self.outputpwm(Count_pulse, 0.1)
self.dev_log.debug(
"""config frequency is {0}HZ,cycleTime {1}us, hightime {2}us"""
@@ -114,9 +112,9 @@ class ebf_smd4805():
self.pul_pwm.close()
pass
- # speed 为速度, 每秒多少圈
- # Duration 为持续时间, ms
- # dir 表示方向
+ # Speed is the speed, how many laps per second
+ # Duration is the duration, Ms
+ # Dir indicates direction
def run(self, speed, Duration, dir=DIR_CLOCKWISE):
self.dir_pin.write(dir)
self.dev_log.info(
diff --git a/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_aht10.py b/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_aht10.py
index e706b11aaf1531f036b4eaa2091c898fa18b26fb..4a9793c7c62a4319cb20ef358c6c4b4520ab6e47 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_aht10.py
+++ b/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_aht10.py
@@ -4,8 +4,8 @@ Project: i2c
File Created: Monday, 28th December 2020 5:17:28 pm
Author: chengzhu.zhou
-----
-Last Modified: Tuesday, 29th December 2020 9:01:35 pm
-Modified By: chengzhu.zhou
+Last Modified: Tuesday, 29th December 2021 9:01:35 pm
+Modified By: Grey.Tu
-----
Copyright 2020 - 2020 quectel
'''
@@ -19,9 +19,8 @@ import utime as time
3. read data
"""
-# API 手册 http://qpy.quectel.com/wiki/#/zh-cn/api/?id=i2c
-# AHT10 说明书
-# https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf
+# API: https://python.quectel.com/wiki/#/en-us/api/QuecPythonClasslib?id=i2c
+# AHT10: https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf
class aht10class():
@@ -53,14 +52,14 @@ class aht10class():
def aht10_init(self, addre=0x38, Alise="Ath10"):
self.i2c_log = log.getLogger(Alise)
- self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE) # 返回i2c对象
+ self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE) # Returns an i2C object
self.i2c_addre = addre
self.sensor_init()
pass
def aht10_transformation_temperature(self, data):
r_data = data
- # 根据数据手册的描述来转化温度
+ # Convert the temperature as described in the data sheet
humidity = (r_data[0] << 12) | (
r_data[1] << 4) | ((r_data[2] & 0xF0) >> 4)
humidity = (humidity/(1 << 20)) * 100.0
@@ -98,7 +97,7 @@ def i2c_aht10_test():
ath_dev = aht10class()
ath_dev.aht10_init()
- # 测试十次
+ # The test ten times
for i in range(10):
ath_dev.Trigger_measurement()
time.sleep(1)
diff --git a/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_lis2dh12.py b/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_lis2dh12.py
index 0d80c9fa86eb2aca92c888702fbd3e24760eb2ec..57fb70da8f09460c30759f0b8822ff390193ddae 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_lis2dh12.py
+++ b/docs/Advanced_development/zh/QuecPythonSub/code/code_i2c_lis2dh12.py
@@ -4,7 +4,7 @@ import _thread
from machine import I2C
from machine import Pin
-# 寄存器地址
+# Register address
LIS2DH12_OUT_X_L = 0x28
LIS2DH12_OUT_X_H = 0x29
LIS2DH12_OUT_Y_L = 0x2A
@@ -13,7 +13,7 @@ LIS2DH12_OUT_Z_L = 0x2C
LIS2DH12_OUT_Z_H = 0x2D
LIS2DH12_FIFO_CTRL_REG = 0x2E
-# 控制寄存器
+# Control register
LIS2DH12_CTRL_REG1 = 0x20
LIS2DH12_CTRL_REG2 = 0x21
LIS2DH12_CTRL_REG3 = 0x22
@@ -23,19 +23,19 @@ LIS2DH12_CTRL_REG6 = 0x25
LIS2DH12_REFERENCE_REG = 0x26
LIS2DH12_STATUS_REG = 0x27
-# 状态寄存器
+# Status register
LIS2DH12_STATUS_REG_AUX = 0x7
-# 中断寄存器
+# Interrupt register
LIS2DH12_INT1_CFG = 0x30
LIS2DH12_INT1_SRC = 0x31
LIS2DH12_INT1_THS = 0x32
LIS2DH12_INT1_DURATION = 0x33
-# 身份寄存器
+# Identity register
LIS2DH12_WHO_AM_I = 0x0F
-# 单击有关的寄存器
+# Click the relevant register
LIS2DH12_CLICK_CFG = 0x38
LIS2DH12_CLICK_SRC = 0x39
LIS2DH12_CLICK_THS = 0x3A
@@ -43,7 +43,7 @@ LIS2DH12_TIME_LIMIT = 0x3B
LIS2DH12_TIME_LATENCY = 0x3C
-# 将其和外部的中断引脚绑定到一起。
+# Bind it to the external interrupt pin。
class lis2dh12(object):
i2c_dev = None
address = None
@@ -54,9 +54,9 @@ class lis2dh12(object):
self.dev_log = log.getLogger("I2C")
self.address = slave_address
self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE)
- self.int_pin = Pin(Pin.GPIO14, Pin.IN, Pin.PULL_PU, 0) # 中断引脚, 根据硬件连接不同而改变
+ self.int_pin = Pin(Pin.GPIO14, Pin.IN, Pin.PULL_PU, 0) # Interrupt pin, which changes according to different hardware connections
self.sensor_init()
- self.single_tap_enable() # 配置单击检测
+ self.single_tap_enable() # Configure click detection
self.start_sensor()
pass
@@ -72,40 +72,39 @@ class lis2dh12(object):
def write_data(self, regaddr, data, debug=True):
w_data = bytearray([regaddr, data])
- # 临时将需要传送的地址放在数据位
+ # Temporarily put the address to be transmitted in the data bit
self.i2c_dev.write(self.address, bytearray(0x00), 0, bytearray(w_data), len(w_data))
if debug is True:
self.dev_log.debug(" write 0x{0:02x} to 0x{1:02x}".format(data, regaddr))
def sensor_reset(self):
- # 重置chip
+ # Reset chip
self.write_data(LIS2DH12_CTRL_REG5, 0x80)
utime.sleep_ms(100)
r_data = self.read_data(LIS2DH12_WHO_AM_I, 1)
- # 确定重启成功
+ # Confirm that the restart is successful
while r_data[0] != 0x33:
r_data = self.read_data(LIS2DH12_WHO_AM_I, 1)
utime.sleep_ms(5)
- self.dev_log.debug("传感器重置成功")
+ self.dev_log.debug("sensor reset succeeded")
pass
def sensor_init(self):
- self.sensor_reset() # 1. 重置设备
- # 2. 初始化传感器
- self.write_data(LIS2DH12_CTRL_REG2, 0x04) # 使能高分辨率
- self.write_data(LIS2DH12_CTRL_REG3, 0x80) # 将中断引到INT1 引脚上面, 默认高电平有效
+ self.sensor_reset() # 1. Reset the device; 2. Initialize the sensor
+ self.write_data(LIS2DH12_CTRL_REG2, 0x04) # Enable high resolution
+ self.write_data(LIS2DH12_CTRL_REG3, 0x80) # Lead the interrupt to the INT1 pin. The default high level is valid
self.write_data(LIS2DH12_CTRL_REG4, 0x08) # ±2g, High-resolution mode
def single_tap_enable(self):
- self.write_data(LIS2DH12_CLICK_CFG, 0x15) # 使能 XYZ 三轴单击中断,
- # self.write_data(LIS2DH12_CLICK_CFG, 0x10) # 使能 Z 轴单击中断,
- self.write_data(LIS2DH12_CLICK_THS, 0x30) # 设置阈值
- self.write_data(LIS2DH12_TIME_LIMIT, 0x18) # 设置时间窗口限制
- self.write_data(LIS2DH12_TIME_LATENCY, 0x02) # 设置延时
+ self.write_data(LIS2DH12_CLICK_CFG, 0x15) # Enable XYZ triaxial click interrupt
+ # self.write_data(LIS2DH12_CLICK_CFG, 0x10) # enables z-axis click interrupt
+ self.write_data(LIS2DH12_CLICK_THS, 0x30) # Set threshold
+ self.write_data(LIS2DH12_TIME_LIMIT, 0x18) # Set time window limit
+ self.write_data(LIS2DH12_TIME_LATENCY, 0x02) # Set delay
def start_sensor(self):
- self.write_data(LIS2DH12_CTRL_REG1, 0x77) # 设置ODR 400HZ ,enable XYZ.
- # self.write_data(LIS2DH12_CTRL_REG1, 0x74) # 设置ODR ,enable Z轴.
+ self.write_data(LIS2DH12_CTRL_REG1, 0x77) # Set ODR 400HZ ,enable XYZ
+ # self.write_data(LIS2DH12_CTRL_REG1, 0x74) # Set ODR ,enable Z axis
utime.sleep_ms(20) # (7/ODR) = 18ms
def read_xyz(self):
@@ -125,27 +124,27 @@ class lis2dh12(object):
def exti_processing_data(self):
value = self.int_pin.read()
- if value == 1: # 检测到中断信号了
+ if value == 1: # Interrupt signal detected
self.processing_data()
return 1
else:
return 0
-# 参数说明
-# state: 是否使能中断读取. 1:使能; 0:不使能
-# delay: 延时时间(ms), 此参数在中断模式下无效
-# retryCount: 读取次数
+# Parameter description
+# state: whether to enable interrupt reading. 1: enable; 0: not enabled
+# delay: delay time (MS). This parameter is invalid in interrupt mode
+# retryCount: number of reads
def is2dh12_thread(state, delay, retryCount):
- # | 参数 | 参数类型 | 说明 |
- # | -------- | ------- | ------------------ |
- # | CRITICAL | 常量 | 日志记录级别的数值 50 |
- # | ERROR | 常量 | 日志记录级别的数值 40 |
- # | WARNING | 常量 | 日志记录级别的数值 30 |
- # | INFO | 常量 | 日志记录级别的数值 20 |
- # | DEBUG | 常量 | 日志记录级别的数值 10 |
- # | NOTSET | 常量 | 日志记录级别的数值 0 |
- log.basicConfig(level=log.INFO) # 设置日志输出级别
+ # | Parameter | parameter type | description |
+ # | --------- | -------------- | ------------------------- |
+ # | CRITICAL | constant | value of logging level 50 |
+ # | ERROR | constant | value of logging level 40 |
+ # | WARNING | constant | value of logging level 30 |
+ # | INFO | constant | value of logging level 20 |
+ # | DEBUG | constant | value of logging level 10 |
+ # | NOTSET | constant | value of logging level 0 |
+ log.basicConfig(level=log.INFO) # Set log output level
dev = lis2dh12()
dev.init(0x19)
while True:
@@ -158,7 +157,7 @@ def is2dh12_thread(state, delay, retryCount):
retryCount -= 1
if retryCount == 0:
break
- print("检测结束退出")
+ print("detection end exit")
if __name__ == "__main__":
diff --git a/docs/Advanced_development/zh/QuecPythonSub/ebf_smd4805.md b/docs/Advanced_development/zh/QuecPythonSub/ebf_smd4805.md
index 9d434c1d4aca364265b283d4f4362573c62ebba9..5aefb8fa97bcbafbb3a95a95dc7c5bc1d34f0d5e 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/ebf_smd4805.md
+++ b/docs/Advanced_development/zh/QuecPythonSub/ebf_smd4805.md
@@ -84,21 +84,11 @@
## 软件设计
```python
-# 引脚连接
-# | 电机引脚 | EC600开发板 | 对应的函数标号 |
-# | ------------------- | --------------------- | ------------ |
-# | ENA- (GPIO) | GPIO81 (引脚号16) | GPIO7 |
-# | DIR- (GPIO) | GPIO77 (引脚号15) | GPIO6 |
-# | PUL- (PWM) | GPIO2_1V8 (引脚号70) | PWM2 |
-# | ENA+ DIR+ PUL+ | 1V8(电源) | 无 |
-
from misc import PWM
from machine import Pin
import utime as time
import urandom as random
import log
-
-
def delay_500us():
for i in range(600):
pass
@@ -116,25 +106,25 @@ DIR_CLOCKWISE = 0x1
DIR_ANTI_CLOCKWISE = 0x0
-class ebf_smd4805:
+class ebf_smd4805():
dev_log = None
- # 步进电机的参数
- sm_para_step = None # 步进角度
- # 控制器的参数
- env_pin = None # 使能引脚
- dir_pin = None # 方向引脚
- pul_pwm = None # 脉冲输出引脚
- ctrl_divstep = None # 细分参数,具体请参考控制器手册
+ # Parameters of stepping motor
+ sm_para_step = None # Step angle
+ # Parameters of controller
+ env_pin = None # Enable pin
+ dir_pin = None # Direction pin
+ pul_pwm = None # Pulse output pin
+ ctrl_divstep = None # For subdivision parameters, please refer to the controller manual
def init(self, step, divstep):
self.dev_log = log.getLogger("ebf_smd4805")
self.env_pin = Pin(Pin.GPIO7, Pin.OUT, Pin.PULL_DISABLE, 0)
self.dir_pin = Pin(Pin.GPIO6, Pin.OUT, Pin.PULL_DISABLE, 0)
- # 配置电机的参数
+ # Configure the parameters of the motor
self.sm_para_step = step
- # 配置控制器的参数
+ # Configure the parameters of the controller
self.ctrl_divstep = divstep
def reset(self):
@@ -143,29 +133,28 @@ class ebf_smd4805:
if self.pul_pwm is not None:
self.pul_pwm.close()
- # 根据频率 初始化PWM
- @staticmethod
- def outputpwm(hz, duty_cycle):
- # 将HZ 转化为 us 级别
- cycleTime = int(1000000 / hz)
+ # Initialize PWM according to frequency
+ def outputpwm(self, HZ, duty_cycle):
+ # Convert Hz to us level
+ cycleTime = int(1000000/HZ)
highTime = int(cycleTime * duty_cycle)
return highTime, cycleTime
- # 根据速度,设置PWM的输出
+ # Set the output of PWM according to the speed
def enable_pwm(self, speed):
- # 1. 首先根据步进电机的步进角度,计算旋转一圈需要多少个脉冲
+ # 1. First, calculate the number of pulses required for one revolution according to the stepping angle of the stepping
Count_pulse = int(360/self.sm_para_step)
self.dev_log.debug("sm motor step as {0}".format(Count_pulse))
- # 2. 根据控制器的细分参数,计算控制器控制步进电机旋转一圈,需要多少的脉冲
+ # 2. According to the subdivision parameters of the controller, calculate the number of pulses required for the controller to control the stepper motor to rotate for one turn
Count_pulse = int(Count_pulse * self.ctrl_divstep)
- # 3. 最后计算出1秒旋转speed圈,需要多少个脉冲 , 换句话说 就是频率
+ # 3. Finally, calculate how many pulses are needed to rotate the speed cycle in one second, in other words, the frequency
Count_pulse = int(Count_pulse * speed)
- # 4. 初始化PWM, 默认占空比%50
- highTime, cycleTime = self.outputpwm(Count_pulse, 0.5)
+ # 4. Initialize PWM, default duty cycle% 50
+ highTime, cycleTime = self.outputpwm(Count_pulse, 0.1)
self.dev_log.debug(
"""config frequency is {0}HZ,cycleTime {1}us, hightime {2}us"""
.format(Count_pulse, cycleTime, highTime))
- self.pul_pwm = PWM(PWM.PWM0, PWM.ABOVE_10US,
+ self.pul_pwm = PWM(PWM.PWM2, PWM.ABOVE_10US,
int(highTime), int(cycleTime))
self.pul_pwm.open()
pass
@@ -174,17 +163,17 @@ class ebf_smd4805:
self.pul_pwm.close()
pass
- # speed 为速度, 每秒多少圈
- # Duration 为持续时间, ms
- # dir 表示方向
- def run(self, speed, duration, dir1=DIR_CLOCKWISE):
- self.dir_pin.write(dir1)
+ # Speed is the speed, how many laps per second
+ # Duration is the duration, Ms
+ # Dir indicates direction
+ def run(self, speed, Duration, dir=DIR_CLOCKWISE):
+ self.dir_pin.write(dir)
self.dev_log.info(
"Configure the motor to rotate {0} revolutions per second".format(speed))
self.enable_pwm(speed)
self.env_pin.write(1)
# delay
- for i in range(int(duration * 4)):
+ for i in range(int(Duration * 4)):
delay_250us()
self.env_pin.write(0)
@@ -198,12 +187,13 @@ def test_ebf_smd4805():
ebf_smd4805_dev = ebf_smd4805()
ebf_smd4805_dev.init(step=1.8, divstep=2)
for i in range(2, 10):
- ebf_smd4805_dev.run(i, duration=1000, dir1=DIR_CLOCKWISE)
+ ebf_smd4805_dev.run(i, Duration=1000, dir=DIR_CLOCKWISE)
print("test_ebf_smd4805 Function exit,!!!")
pass
if __name__ == "__main__":
+ # creat a thread Check key status
test_ebf_smd4805()
```
diff --git a/docs/Advanced_development/zh/QuecPythonSub/i2c_aht.md b/docs/Advanced_development/zh/QuecPythonSub/i2c_aht.md
index 8229c9d39816c5553fd344aa3d0ca022cc595396..8edd47b6afdb8d574cbaa23794744b502b43dce7 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/i2c_aht.md
+++ b/docs/Advanced_development/zh/QuecPythonSub/i2c_aht.md
@@ -12,9 +12,9 @@
## 硬件介绍
-
+
-AHT10是一款高精度,完全校准,贴片封装的温湿度传感器,MEMS的制作工艺,确保产品具有极高的可靠性与卓越的长期稳定性。传感器包括一个电容式感湿元件和一个高性能CMOS微处理器相连接。该产品具有品质卓越、超快响应、抗干扰能力强、性价比极高等优点。具体可以参考: [AHT10产品手册 A2 20201221.pdf](media\AHT10产品手册 A2 20201221.pdf) 。
+AHT10是一款高精度,完全校准,贴片封装的温湿度传感器,MEMS的制作工艺,确保产品具有极高的可靠性与卓越的长期稳定性。传感器包括一个电容式感湿元件和一个高性能CMOS微处理器相连接。该产品具有品质卓越、超快响应、抗干扰能力强、性价比极高等优点。
AHT10 通过 I2C 接口通讯。按照说明书的简介。只需要按照下面的方式,发送数据就可以获取数据了。
@@ -74,7 +74,7 @@ class aht10class:
def aht10_init(self, addre=0x38, alise="Ath10"):
self.i2c_log = log.getLogger(alise)
- self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE) # 返回i2c对象
+ self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE) #Return I2C object
self.i2c_addre = addre
self.sensor_init()
pass
@@ -82,7 +82,7 @@ class aht10class:
@staticmethod
def aht10_transformation_temperature(data):
r_data = data
- # 根据数据手册的描述来转化温度
+ #Convert the temperature as described in the data book
humidity = (r_data[0] << 12) | (
r_data[1] << 4) | ((r_data[2] & 0xF0) >> 4)
humidity = (humidity/(1 << 20)) * 100.0
@@ -119,7 +119,7 @@ def i2c_aht10_test():
ath_dev = aht10class()
ath_dev.aht10_init()
- # 测试十次
+ #Test ten times
for i in range(10):
ath_dev.trigger_measurement()
time.sleep(1)
diff --git a/docs/Advanced_development/zh/QuecPythonSub/i2c_lis2dh.md b/docs/Advanced_development/zh/QuecPythonSub/i2c_lis2dh.md
index 3e8e21e89974094bf4915ecaed30c6b179d5452c..ec5f75a869b5fb34f20c12e236cbb8ed11565e2f 100644
--- a/docs/Advanced_development/zh/QuecPythonSub/i2c_lis2dh.md
+++ b/docs/Advanced_development/zh/QuecPythonSub/i2c_lis2dh.md
@@ -5,7 +5,6 @@
| 版本 | 日期 | 作者 | 变更表述 |
| ---- | ---------- | ------- | -------- |
| 1.0 | 2021-09-29 | Grey.Tu | 初版 |
-| 1.1 | 2021-12-16 | Grey.Tu | 文档勘误 |
本片文章主要基于 EC600x_IIC接口介绍三轴加速度传感器LIS2DH12TR,做一个检测加速度的小实验。
@@ -23,26 +22,26 @@ LIS2DH12 是属于“nano”系列的超低功耗高性能 3 轴线性加速度
引脚功能介绍:
-| 引脚号 | 引脚名 | 说明 | 备份 |
-| ------ | ----------- | ------------------------------------------------------------ | ---- |
-| 1 | SCL/SPC | IIC/SPI时钟引脚。 | |
-| 2 | CS | SPI使能引脚,控制芯片通信方式。
1:IIC通信;2:SPI通信。 | |
-| 3 | SDO/SA0 | SPI模式下为数据输出引脚;
IIC模式为设备从地址选择引脚,1:0x19;0:0x18。 | |
-| 4 | SDA/SDI/SDO | IIC模式下为数据引脚;
标准SPI模式下为数据输入引脚;
也可以作为SPI的数据输出引脚。 | |
-| 5 | RES | 接地即可。 | |
-| 6 | GND | 地 | |
-| 7 | GND | 地 | |
-| 8 | GND | 地 | |
-| 9 | VDD | 电源 | |
-| 10 | VDD_IO | IO参考电平引脚 | |
-| 11 | INT2 | 中断引脚2 | |
-| 12 | INT1 | 中断引脚1 | |
+| 引脚号 | 引脚名 | 说明 | 备份 |
+| ------ | --------------------- | ------------------------------------------------------------ | ---- |
+| 1 | SCL
SPC | IIC/SPI时钟引脚。 | |
+| 2 | CS | SPI使能引脚,控制芯片通信方式。
1:IIC通信;2:SPI通信。 | |
+| 3 | SDO
SA0 | SPI模式下为数据输出引脚;
IIC模式为设备从地址选择引脚,1:0x19;0:0x18。 | |
+| 4 | SDA
SDI
SDO | IIC模式下为数据引脚;
标准SPI模式下为数据输入引脚;
也可以作为SPI的数据输出引脚。 | |
+| 5 | Res | 接地即可。 | |
+| 6 | GND | 地 | |
+| 7 | GND | 地 | |
+| 8 | GND | 地 | |
+| 9 | VDD | 电源 | |
+| 10 | VDD_IO | IO参考电平引脚 | |
+| 11 | INT2 | 中断引脚2 | |
+| 12 | INT1 | 中断引脚1 | |
本章我们采用 I2C 接口通讯。原理图如下。

-本次我们 SD0/SA0 引脚接高电平。 因此可以确认加速度传感器的从机地址为0x19。
+本次我们 D0/SA0 引脚高电平。 因此可以确认加速度传感器的从机地址为0x19。
@@ -96,7 +95,7 @@ import _thread
from machine import I2C
from machine import Pin
-# 寄存器地址
+# Register address
LIS2DH12_OUT_X_L = 0x28
LIS2DH12_OUT_X_H = 0x29
LIS2DH12_OUT_Y_L = 0x2A
@@ -105,7 +104,7 @@ LIS2DH12_OUT_Z_L = 0x2C
LIS2DH12_OUT_Z_H = 0x2D
LIS2DH12_FIFO_CTRL_REG = 0x2E
-# 控制寄存器
+# Control register
LIS2DH12_CTRL_REG1 = 0x20
LIS2DH12_CTRL_REG2 = 0x21
LIS2DH12_CTRL_REG3 = 0x22
@@ -115,19 +114,19 @@ LIS2DH12_CTRL_REG6 = 0x25
LIS2DH12_REFERENCE_REG = 0x26
LIS2DH12_STATUS_REG = 0x27
-# 状态寄存器
+# Status register
LIS2DH12_STATUS_REG_AUX = 0x7
-# 中断寄存器
+# Interrupt register
LIS2DH12_INT1_CFG = 0x30
LIS2DH12_INT1_SRC = 0x31
LIS2DH12_INT1_THS = 0x32
LIS2DH12_INT1_DURATION = 0x33
-# 身份寄存器
+# Identity register
LIS2DH12_WHO_AM_I = 0x0F
-# 单击有关的寄存器
+# Click the relevant register
LIS2DH12_CLICK_CFG = 0x38
LIS2DH12_CLICK_SRC = 0x39
LIS2DH12_CLICK_THS = 0x3A
@@ -135,7 +134,7 @@ LIS2DH12_TIME_LIMIT = 0x3B
LIS2DH12_TIME_LATENCY = 0x3C
-# 将其和外部的中断引脚绑定到一起。
+# Bind it to the external interrupt pin。
class lis2dh12(object):
i2c_dev = None
address = None
@@ -146,9 +145,9 @@ class lis2dh12(object):
self.dev_log = log.getLogger("I2C")
self.address = slave_address
self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE)
- self.int_pin = Pin(Pin.GPIO14, Pin.IN, Pin.PULL_PU, 0) # 中断引脚, 根据硬件连接不同而改变
+ self.int_pin = Pin(Pin.GPIO14, Pin.IN, Pin.PULL_PU, 0) # Interrupt pin, which changes according to different hardware connections
self.sensor_init()
- self.single_tap_enable() # 配置单击检测
+ self.single_tap_enable() # Configure click detection
self.start_sensor()
pass
@@ -164,40 +163,39 @@ class lis2dh12(object):
def write_data(self, regaddr, data, debug=True):
w_data = bytearray([regaddr, data])
- # 临时将需要传送的地址放在数据位
+ # Temporarily put the address to be transmitted in the data bit
self.i2c_dev.write(self.address, bytearray(0x00), 0, bytearray(w_data), len(w_data))
if debug is True:
self.dev_log.debug(" write 0x{0:02x} to 0x{1:02x}".format(data, regaddr))
def sensor_reset(self):
- # 重置chip
+ # Reset chip
self.write_data(LIS2DH12_CTRL_REG5, 0x80)
utime.sleep_ms(100)
r_data = self.read_data(LIS2DH12_WHO_AM_I, 1)
- # 确定重启成功
+ # Confirm that the restart is successful
while r_data[0] != 0x33:
r_data = self.read_data(LIS2DH12_WHO_AM_I, 1)
utime.sleep_ms(5)
- self.dev_log.debug("传感器重置成功")
+ self.dev_log.debug("sensor reset succeeded")
pass
def sensor_init(self):
- self.sensor_reset() # 1. 重置设备
- # 2. 初始化传感器
- self.write_data(LIS2DH12_CTRL_REG2, 0x04) # 使能高分辨率
- self.write_data(LIS2DH12_CTRL_REG3, 0x80) # 将中断引到INT1 引脚上面, 默认高电平有效
+ self.sensor_reset() # 1. Reset the device; 2. Initialize the sensor
+ self.write_data(LIS2DH12_CTRL_REG2, 0x04) # Enable high resolution
+ self.write_data(LIS2DH12_CTRL_REG3, 0x80) # Lead the interrupt to the INT1 pin. The default high level is valid
self.write_data(LIS2DH12_CTRL_REG4, 0x08) # ±2g, High-resolution mode
def single_tap_enable(self):
- self.write_data(LIS2DH12_CLICK_CFG, 0x15) # 使能 XYZ 三轴单击中断,
- # self.write_data(LIS2DH12_CLICK_CFG, 0x10) # 使能 Z 轴单击中断,
- self.write_data(LIS2DH12_CLICK_THS, 0x30) # 设置阈值
- self.write_data(LIS2DH12_TIME_LIMIT, 0x18) # 设置时间窗口限制
- self.write_data(LIS2DH12_TIME_LATENCY, 0x02) # 设置延时
+ self.write_data(LIS2DH12_CLICK_CFG, 0x15) # Enable XYZ triaxial click interrupt
+ # self.write_data(LIS2DH12_CLICK_CFG, 0x10) # enables z-axis click interrupt
+ self.write_data(LIS2DH12_CLICK_THS, 0x30) # Set threshold
+ self.write_data(LIS2DH12_TIME_LIMIT, 0x18) # Set time window limit
+ self.write_data(LIS2DH12_TIME_LATENCY, 0x02) # Set delay
def start_sensor(self):
- self.write_data(LIS2DH12_CTRL_REG1, 0x77) # 设置ODR 400HZ ,enable XYZ.
- # self.write_data(LIS2DH12_CTRL_REG1, 0x74) # 设置ODR ,enable Z轴.
+ self.write_data(LIS2DH12_CTRL_REG1, 0x77) # Set ODR 400HZ ,enable XYZ
+ # self.write_data(LIS2DH12_CTRL_REG1, 0x74) # Set ODR ,enable Z axis
utime.sleep_ms(20) # (7/ODR) = 18ms
def read_xyz(self):
@@ -217,27 +215,27 @@ class lis2dh12(object):
def exti_processing_data(self):
value = self.int_pin.read()
- if value == 1: # 检测到中断信号了
+ if value == 1: # Interrupt signal detected
self.processing_data()
return 1
else:
return 0
-# 参数说明
-# state: 是否使能中断读取. 1:使能; 0:不使能
-# delay: 延时时间(ms), 此参数在中断模式下无效
-# retryCount: 读取次数
+# Parameter description
+# state: whether to enable interrupt reading. 1: enable; 0: not enabled
+# delay: delay time (MS). This parameter is invalid in interrupt mode
+# retryCount: number of reads
def is2dh12_thread(state, delay, retryCount):
- # | 参数 | 参数类型 | 说明 |
- # | -------- | ------- | ------------------ |
- # | CRITICAL | 常量 | 日志记录级别的数值 50 |
- # | ERROR | 常量 | 日志记录级别的数值 40 |
- # | WARNING | 常量 | 日志记录级别的数值 30 |
- # | INFO | 常量 | 日志记录级别的数值 20 |
- # | DEBUG | 常量 | 日志记录级别的数值 10 |
- # | NOTSET | 常量 | 日志记录级别的数值 0 |
- log.basicConfig(level=log.INFO) # 设置日志输出级别
+ # | Parameter | parameter type | description |
+ # | --------- | -------------- | ------------------------- |
+ # | CRITICAL | constant | value of logging level 50 |
+ # | ERROR | constant | value of logging level 40 |
+ # | WARNING | constant | value of logging level 30 |
+ # | INFO | constant | value of logging level 20 |
+ # | DEBUG | constant | value of logging level 10 |
+ # | NOTSET | constant | value of logging level 0 |
+ log.basicConfig(level=log.INFO) # Set log output level
dev = lis2dh12()
dev.init(0x19)
while True:
@@ -250,7 +248,7 @@ def is2dh12_thread(state, delay, retryCount):
retryCount -= 1
if retryCount == 0:
break
- print("检测结束退出")
+ print("detection end exit")
if __name__ == "__main__":
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_1.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_1.jpg
index 448e34941fce5f3a89174e42a3e97046c185294c..9054c6b4b5cddc1396d30ed3dadb4b57ce23f566 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_1.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_1.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_3.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_3.jpg
index d1b9b96a236ee53dbffc43848d4b390e667fb693..e081ace623ee62d8eab9ca397a24c01781a47f1b 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_3.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_3.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_4.png b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_4.png
index 1d10a7f41db0bf594df84ca39930b7d815c389c7..dc8d9f8534d3bb13cf98320235b8e204c8c771bd 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_4.png and b/docs/Advanced_development/zh/QuecPythonSub/media/media_ebf_smd4805_4.png differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_1.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..750445e58c159f5370fcd5881a1bbf66ba7a4ff4
Binary files /dev/null and b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_1.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_2.png b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_2.png
index 4078a7a3eabcf523aa62f652543b5fe50ee7fd83..97114d5daa98d60a7a333c2452b1bbcf4c8af2c7 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_2.png and b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_aht_2.png differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_2.png b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_2.png
index 08698e7d38e908646d19b28162fa72d9fb28bf31..63234c91a3a2665d7742e497e1a7c9ecccdca56a 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_2.png and b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_2.png differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_3.png b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_3.png
index 28754c22552bf9e5dffdb9e9b92c9070111265ce..908e1a847adc1db098450958d745bc90a7dbf6bd 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_3.png and b/docs/Advanced_development/zh/QuecPythonSub/media/media_i2c_lis2dh_3.png differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_2.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_2.jpg
index ea54fd40a581c98c074d1a8f7816221158178f5b..7562f425f5aa6e0a398ba893d9d7a4ca2de6939c 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_2.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_2.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_4.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_4.jpg
index a1c4ad75deb812cc754f762eaf25c41180409a9e..dbed07784f982480e02ca588fd7de6fae4eb310e 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_4.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_4.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_5.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_5.jpg
index 6029ab10718625015444319b8758350c7e5040fa..aa26a833d4e70a7f899dd67fd1eb18c49a3ab082 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_5.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_5.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_7.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_7.jpg
index 1a800d1f51f28d925647c253278a5ccaa3a4447e..430303ab9703f2d5b8e6e4842406c3cc3dd653c5 100644
Binary files a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_7.jpg and b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_7.jpg differ
diff --git a/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_8.jpg b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_8.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..d1477b40fb19a75e02d4d3bb9939c807332e5b4f
Binary files /dev/null and b/docs/Advanced_development/zh/QuecPythonSub/media/media_lcd_8.jpg differ
diff --git a/docs/sbs/zh/BSP/SPI.md b/docs/sbs/zh/BSP/SPI.md
index 74f170deee3eadad647775e9247f933bef327617..0d915c15bb49f9f5d9caead624758b1f4840b218 100644
--- a/docs/sbs/zh/BSP/SPI.md
+++ b/docs/sbs/zh/BSP/SPI.md
@@ -42,12 +42,17 @@ Master 设备会根据将要交换的数据来产生相应的时钟脉冲(Clock
根据 **时钟极性 CPOL** 与 **时钟相位 CPHA** 的不同,SPI具有四种通信模式。
+| SPI mode | CPOL | CPHA | SCK Clock when idle | Sampling moment |
+| -------- | ---- | ---- | ------------------- | --------------- |
+| 0 | 0 | 0 | Low level | Odd edge |
+| 1 | 0 | 1 | Low level | Even edge |
+| 2 | 1 | 0 | High level | Odd edge |
+| 3 | 1 | 1 | High level | Even edge |
+


-
-
### 数据交换(Data Exchanges)
@@ -72,17 +77,17 @@ import utime
from machine import SPI
from machine import Pin
-# 屏蔽GNSS模块数据干扰. 由于EC600S/N的SPI_MISO与SPI_MOSI引脚还被复用为UART1. 开发板还连接GNSS模块L76K, 为了断开L76K吐数据对SPI通信的干扰, 需要添加下面两句代码.
-gpio11 = Pin(Pin.GPIO11, Pin.OUT, Pin.PULL_PD, 0) # EC600S/EC600N使用
-gpio11.write(0) # EC600S/EC600N使用
+# Shield the data inteference of GNSS module. As the SPI_MISO and SPI_MOSI are multiplexed as UART1, A GNSS module (L76K)is also connected to EVB. In order to disconnect the inteference to SPI communition by data from L76K, followiing two lines of codes should be added.
+gpio11 = Pin(Pin.GPIO11, Pin.OUT, Pin.PULL_PD, 0) # Used in EC600S/EC600N
+gpio11.write(0) # Used in EC600S/EC600N
w_data = "Grey"
r_data = bytearray(len(w_data))
-count = 10 # 运行次数
+count = 10 # Running count
-# 以下代码根据模块型号进行选择.
-spi_obj = SPI(1, 0, 1) # EC600S/N使用
-# spi_obj = SPI(0, 0, 1) # EC600U使用
+# Please select codes with the module type
+spi_obj = SPI(1, 0, 1) # Used in EC600S/N
+# spi_obj = SPI(0, 0, 1) # Used in EC600U
while count:
count -= 1
@@ -99,7 +104,7 @@ while count:
### 实验现象
-
+
## 配套代码
diff --git a/docs/sbs/zh/BSP/code/code_SPI.py b/docs/sbs/zh/BSP/code/code_SPI.py
index 2eaef63c7a2a226912adb82b4a8cbf3113c415ea..7e06045f729d4922c04b1d759c0e666f655fbac7 100644
--- a/docs/sbs/zh/BSP/code/code_SPI.py
+++ b/docs/sbs/zh/BSP/code/code_SPI.py
@@ -3,15 +3,15 @@ import utime
from machine import SPI
from machine import Pin
-# 屏蔽GNSS模块数据干扰. 由于EC600S/N的SPI_MISO与SPI_MOSI引脚还被复用为UART1. 开发板还连接GNSS模块L76K, 为了断开L76K吐数据对SPI通信的干扰, 需要添加下面两句代码.
-gpio11 = Pin(Pin.GPIO11, Pin.OUT, Pin.PULL_PD, 0) # EC600S/EC600N使用
-gpio11.write(0) # EC600S/EC600N使用
+# Shield the data inteference of GNSS module. As the SPI_MISO and SPI_MOSI are multiplexed as UART1, A GNSS module (L76K)is also connected to EVB. In order to disconnect the inteference to SPI communition by data from L76K, followiing two lines of codes should be added.
+gpio11 = Pin(Pin.GPIO11, Pin.OUT, Pin.PULL_PD, 0) # Used in EC600S/EC600N
+gpio11.write(0) # Used in EC600S/EC600N
w_data = "Grey"
r_data = bytearray(len(w_data))
-count = 10 # 运行次数
-spi_obj = SPI(1, 0, 1) # EC600S/EC600N使用
-# spi_obj = SPI(0, 0, 1) # EC600U/EC100Y使用
+count = 10 # Running count
+spi_obj = SPI(1, 0, 1) # Running count
+# spi_obj = SPI(0, 0, 1) # Running count
while count:
count -= 1
diff --git a/docs/sbs/zh/BSP/media/media_SPI_1.jpg b/docs/sbs/zh/BSP/media/media_SPI_1.jpg
index f9e636fa9fc329c164c2e2f42f31795b5c61abaf..bce081debb26d7540461a980724c99564442fc70 100644
Binary files a/docs/sbs/zh/BSP/media/media_SPI_1.jpg and b/docs/sbs/zh/BSP/media/media_SPI_1.jpg differ
diff --git a/docs/sbs/zh/BSP/media/media_SPI_2.jpg b/docs/sbs/zh/BSP/media/media_SPI_2.jpg
index 7ac14f0715250687e91e68bf13d5b98b4efac075..0721d35820433b53f2983d99a66f7bf863e6432c 100644
Binary files a/docs/sbs/zh/BSP/media/media_SPI_2.jpg and b/docs/sbs/zh/BSP/media/media_SPI_2.jpg differ
diff --git a/docs/sbs/zh/BSP/media/media_SPI_3.jpg b/docs/sbs/zh/BSP/media/media_SPI_3.jpg
index cf87c486c4832c74f3d20170f7cd64faf10d774a..a47dc750e018a26efc6e11b4af911adecc564b92 100644
Binary files a/docs/sbs/zh/BSP/media/media_SPI_3.jpg and b/docs/sbs/zh/BSP/media/media_SPI_3.jpg differ
diff --git a/docs/sbs/zh/BSP/media/media_SPI_4.jpg b/docs/sbs/zh/BSP/media/media_SPI_4.jpg
index 66b9a7b203f332146efb947dc5c550a98c413dd5..d7b63d6397ec270cd4dec7865a0b8beecf1d9483 100644
Binary files a/docs/sbs/zh/BSP/media/media_SPI_4.jpg and b/docs/sbs/zh/BSP/media/media_SPI_4.jpg differ
diff --git a/docs/sbs/zh/BSP/media/media_SPI_5.jpg b/docs/sbs/zh/BSP/media/media_SPI_5.jpg
index 88c9a0922849681691935bf954f22daf1123b45e..a41d5f821b017388e145b87efddbe0a9759f3619 100644
Binary files a/docs/sbs/zh/BSP/media/media_SPI_5.jpg and b/docs/sbs/zh/BSP/media/media_SPI_5.jpg differ