Files

140 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

2019-08-15 19:29:40 +08:00
## once()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void once(float seconds, callback_t callback)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute a command in seconds, which is executed only once.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
| seconds | float | Set time |
| callback | callback_t | Custom callback function |
## once_ms()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void once_ms(uint32_t milliseconds, callback_t callback)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute a command in milliseconds, which is executed only once.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
| milliseconds | float | Set time |
| callback | callback_t | Custom callback function |
## attach()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void attach(float seconds, void (*callback)(TArg), TArg arg)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute commands with parameters after every seconds.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
| seconds | float | Set time |
| *callback | callback_t | Custom callback function |
| TArg | arg | function arguments |
## attach_ms()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute commands with parameters after every milliseconds.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
| milliseconds | float | Set time |
| *callback | callback_t | Custom callback function |
| TArg | arg | function arguments |
## attach()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void attach(float seconds, callback_t callback)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute the command after every second with no parameters.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
| seconds | float | Set time |
| callback | callback_t | Custom callback function |
## attach_ms()
**Syntax:**
2020-11-05 11:39:06 +08:00
`void attach_ms(uint32_t milliseconds, callback_t callback)`
2019-08-15 19:29:40 +08:00
**Description:**
Load <Ticker.h> before use
2019-08-15 21:05:40 +08:00
2019-08-15 19:29:40 +08:00
Execute the command after every milliseconds with no parameters.
**Function argument**
| Function argument |Type |Description |
| --- | --- | --- |
2019-08-15 21:05:40 +08:00
| milliseconds | float | Set time |
2019-08-15 19:29:40 +08:00
| callback | callback_t | Custom callback function |
## Usage {docsify-ignore}
2021-02-26 17:27:20 +08:00
```clike
2019-08-15 19:29:40 +08:00
#include <M5Stack.h>
#include <Ticker.h>
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() {
}
```