From bf7904dfc97dc017e89de4fe73bfeca080b4fbe1 Mon Sep 17 00:00:00 2001 From: vany5921 <908744431@qq.com> Date: Thu, 15 Aug 2019 21:05:40 +0800 Subject: [PATCH] add ZH-CN api --- docs/en/api/eeprom.md | 4 ++ docs/en/api/ticker.md | 8 ++- docs/zh_CN/api/ticker.md | 140 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 docs/zh_CN/api/ticker.md diff --git a/docs/en/api/eeprom.md b/docs/en/api/eeprom.md index 032898a4..3c3cba21 100644 --- a/docs/en/api/eeprom.md +++ b/docs/en/api/eeprom.md @@ -7,6 +7,7 @@ **Description:** Load before use + Open EEPROM,Size is the maximum address + 1 of the data bytes to be read and written, ranging from 1 to 4096. **Function argument** @@ -24,6 +25,7 @@ Open EEPROM,Size is the maximum address + 1 of the data bytes to be read and wri **Description:** Load before use + Write data to storage space. **Function argument** @@ -42,6 +44,7 @@ Write data to storage space. **Description:** Load before use + This function needs to be called every time an address is written. **Function argument** @@ -57,6 +60,7 @@ None **Description:** Load before use + Reading data from storage space. **Function argument** diff --git a/docs/en/api/ticker.md b/docs/en/api/ticker.md index 47dda798..cc42fc11 100644 --- a/docs/en/api/ticker.md +++ b/docs/en/api/ticker.md @@ -7,6 +7,7 @@ **Description:** Load before use + Execute a command in seconds, which is executed only once. **Function argument** @@ -25,6 +26,7 @@ Execute a command in seconds, which is executed only once. **Description:** Load before use + Execute a command in milliseconds, which is executed only once. **Function argument** @@ -43,6 +45,7 @@ Execute a command in milliseconds, which is executed only once. **Description:** Load before use + Execute commands with parameters after every seconds. **Function argument** @@ -62,6 +65,7 @@ Execute commands with parameters after every seconds. **Description:** Load before use + Execute commands with parameters after every milliseconds. **Function argument** @@ -81,6 +85,7 @@ Execute commands with parameters after every milliseconds. **Description:** Load before use + Execute the command after every second with no parameters. **Function argument** @@ -99,13 +104,14 @@ Execute the command after every second with no parameters. **Description:** Load before use + Execute the command after every milliseconds with no parameters. **Function argument** | Function argument |Type |Description | | --- | --- | --- | -| seconds | float | Set time | +| milliseconds | float | Set time | | callback | callback_t | Custom callback function | ## Usage {docsify-ignore} diff --git a/docs/zh_CN/api/ticker.md b/docs/zh_CN/api/ticker.md new file mode 100644 index 00000000..ff6f21ad --- /dev/null +++ b/docs/zh_CN/api/ticker.md @@ -0,0 +1,140 @@ +## once() + +**函数原型:** + +void once(float seconds, callback_t callback) + +**功能:** + +使用前加载 + +在设定的时间点(s)只执行一次回调函数. + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| seconds | float | 设置秒 | +| callback | callback_t | 回调函数 | + +## once_ms() + +**函数原型:** + +void once_ms(uint32_t milliseconds, callback_t callback) + +**功能:** + +使用前加载 + +在设定的时间点(ms)回调函数只运行一次. + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| milliseconds | float | 毫秒 | +| callback | callback_t | 回调函数 | + +## attach() + +**函数原型:** + +void attach(float seconds, void (*callback)(TArg), TArg arg) + +**功能:** + +使用前加载 + +每隔一段时间(s)执行一次带参数的回调函数. + +**函数参数** + +| 参数 |类型 | 描述 | +| --- | --- | --- | +| seconds | float | 秒 | +| *callback | callback_t | 带参数回调函数 | +| TArg | arg | 函数参数 | + +## attach_ms() + +**函数原型:** + +void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg) + +**功能:** + +使用前加载 + +每隔一段时间(ms)执行一次带参数的回调函数 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| milliseconds | float | 毫秒 | +| *callback | callback_t | 带参数回调函数 | +| TArg | arg | 参数 | + +## attach() + +**函数原型:** + +void attach(float seconds, callback_t callback) + +**功能:** + +使用前加载 + +每隔一定时间(s)执行一次回调函数 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| seconds | float | 秒 | +| callback | callback_t | 回调函数 | + +## attach_ms() + +**函数原型:** + +void attach_ms(uint32_t milliseconds, callback_t callback) + +**功能:** + +使用前加载 + +每隔一定时间(ms)执行一次回调函数 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| milliseconds | float | 毫秒 | +| callback | callback_t | 回调函数 | + +## Usage {docsify-ignore} + +```arduino +#include +#include + +Ticker tickerSetHigh; +Ticker tickerSetLow; + +void display(int number) { + M5.Lcd.setCursor(0, 0); + M5.Lcd.print(number); +} +void setup() { + M5.begin(); + tickerSetLow.attach_ms(1000, display, 0); + tickerSetHigh.attach_ms(2000, display, 1); +} +void loop() { +} + + + +``` \ No newline at end of file