From 93244914b778466a7433c8fbc3efca2acdc967ad Mon Sep 17 00:00:00 2001 From: "mark.zhu" Date: Mon, 17 Apr 2023 22:15:32 +0800 Subject: [PATCH] =?UTF-8?q?docs=20(osTimer&misc.PowerKey):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0osTimer,=E5=AE=8C=E5=96=84powerkey=E7=89=B9=E6=80=A7?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.添加osTimer模块介绍 2.增加powerkey在注册用户回调时长按不再关机的特性描述 固件版本: N/A 是否需要文案翻译: 是 --- .../README.md" | 1 + .../misc.PowerKey.md" | 6 +- .../osTimer.md" | 81 +++++++++++++++++++ docs/API_reference/zh/sidebar.yaml | 2 + 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 "docs/API_reference/zh/QuecPython\347\261\273\345\272\223/osTimer.md" diff --git "a/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/README.md" "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/README.md" index ecf0aa11..4299b41c 100644 --- "a/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/README.md" +++ "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/README.md" @@ -26,6 +26,7 @@ - [wifiScan - WiFi扫描](./wifiScan.md) - [machine - 硬件相关功能](./machine.md) - [misc - 其他](./misc.md) +- [osTimer - os定时器](./osTimer.md) - [qrcode - 二维码显示](./qrcode.md) - [ethernet - 以太网相关功能](./ethernet.md) - [camera - 摄像头](./camera.md) diff --git "a/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/misc.PowerKey.md" "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/misc.PowerKey.md" index ef5c1807..f213ed65 100644 --- "a/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/misc.PowerKey.md" +++ "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/misc.PowerKey.md" @@ -39,9 +39,11 @@ PowerKey.powerKeyEventRegister(usrFun) `0`表示注册成功,`-1`表示注册失败。 -> EC600S/EC600N系列,对于powerkey,按下和松开时,都会触发用户注册的回调函数; +> ECX00S/ECX00N/ECX00M/ECX00E系列,对于powerkey,按下和松开时,都会触发用户注册的回调函数; > -> EC200U/EC600U系列,对于powerkey,只在按键松开时才会触发回调函数,并且按键按下的时间需要维持500ms以上。 +> ECX00U/ECX00G系列,对于powerkey,只在按键松开时才会触发回调函数,并且按键按下的时间需要维持500ms以上; +> +> 上述所有平台在注册用户的回调函数后,powerkey长按不再触发关机。 **示例:** diff --git "a/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/osTimer.md" "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/osTimer.md" new file mode 100644 index 00000000..ab2a3b49 --- /dev/null +++ "b/docs/API_reference/zh/QuecPython\347\261\273\345\272\223/osTimer.md" @@ -0,0 +1,81 @@ +# osTimer - os定时器 + +模组提供底层os的定时器接口,os定时器超时会触发其绑定的回调函数。 + +**示例** + +```python +import osTimer + +def test_cb(arg): + print("Expired!!"") +# 创建os定时器 +timer = osTimer() +# 启动定时器,参数依次为时间、是否循环、回调函数 +timer.start(10000,1,test_cb) +# 停止定时器 +timer.stop() +# 删除定时器 +timer.delete_timer(timer) +``` + + +## 创建定时器 + +### `osTimer` + +```python +osTimer() +``` + +创建osTimer定时器对象 + +> 相比[machine.Timer](./machine.Timer.md),此定时器不存在创建个数的限制 + +## 启动定时器 + +### `osTimer.start` + +```python +osTimer.start(initialTime, cyclialEn, callback) +``` + +**参数描述** + +* `initialTime`,定时器超时的时间(单位ms),int类型 +* `cyclialEn`,是否循环,0为单次,1为循环,int类型 +* `callback`,定时器超时触发的回调,函数 + +**返回值描述** + +int类型,0为成功,其余为失败 + +## 停止定时器 + +### `osTimer.stop` + +```python +osTimer.stop() +``` +停止定时器 + +**返回值描述** + +int类型,0为成功,其余为失败 + +## 删除定时器 + +### `osTimer.delete_timer` + +```python +osTimer.delete_timer(timer_obj) +``` +删除定时器 + +**参数描述** + +* `timer_obj`,osTimer对象 + +**返回值描述** + +int类型,0为成功,其余为失败 \ No newline at end of file diff --git a/docs/API_reference/zh/sidebar.yaml b/docs/API_reference/zh/sidebar.yaml index 36ad8c70..d04c799f 100644 --- a/docs/API_reference/zh/sidebar.yaml +++ b/docs/API_reference/zh/sidebar.yaml @@ -120,6 +120,8 @@ items: file: QuecPython类库/misc.USB.md - label: USBNET - USB网卡 file: QuecPython类库/misc.USBNET.md + - label: osTimer - os定时器 + file: QuecPython类库/osTimer.md - label: modem - 设备相关 file: QuecPython类库/modem.md - label: machine - 硬件相关功能 -- Gitee