mirror of
https://github.com/m5stack/ESP-Claw.git
synced 2026-05-20 11:51:49 -07:00
feat(demo): update lua module and board
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# Lua Button
|
||||
|
||||
This skill describes how to correctly use button when writing Lua scripts.
|
||||
|
||||
## How to call
|
||||
- Import it with `local button = require("button")`
|
||||
- Call `local handle = button.new(gpio_num [, active_level [, long_press_ms [, short_press_ms]]])` to create a button handle
|
||||
- Call `button.on(handle, event, callback)` to subscribe to a button event
|
||||
- Supported event names include `press_down`, `press_up`, `single_click`, `double_click`, `multiple_click`, `long_press_start`, `long_press_hold`, and `long_press_up`
|
||||
- Call `button.off(handle [, event])` to remove a subscription or clear callbacks
|
||||
- Call `button.dispatch()` to poll and dispatch pending button events
|
||||
- Call `button.get_key_level(handle)` to read the current key level
|
||||
- Call `button.close(handle)` when the handle is no longer needed
|
||||
|
||||
## Example
|
||||
```lua
|
||||
local button = require("button")
|
||||
|
||||
local handle = button.new(0, 0)
|
||||
button.on(handle, "single_click", function(evt)
|
||||
print(evt.event, evt.repeat_count)
|
||||
end)
|
||||
|
||||
button.dispatch()
|
||||
button.close(handle)
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"id": "lua_module_button",
|
||||
"file": "lua_module_button.md",
|
||||
"title": "lua_module_button",
|
||||
"summary": "How to create button handles, subscribe to events, and dispatch button state from Lua.",
|
||||
"cap_groups": [
|
||||
"cap_lua"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user