mirror of
https://github.com/m5stack/ESP-Claw.git
synced 2026-05-20 11:51:49 -07:00
feat(lua): add tone playback and runtime cleanup
Add runtime cleanup registration for Lua modules. Release the display during script teardown. Expose audio.play_tone and update related demos and skills. Add the flappy bird demo and refine the clock dial rendering.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "display_arbiter.h"
|
||||
#include "display_hal.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "lauxlib.h"
|
||||
#include "png.h"
|
||||
|
||||
@@ -24,6 +25,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *TAG = "lua_display";
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Argument helpers (mirrors the reference implementation)
|
||||
* ---------------------------------------------------------------------- */
|
||||
@@ -136,6 +139,18 @@ static display_hal_panel_if_t lua_display_parse_panel_if(lua_State *L, int index
|
||||
* Screen lifecycle
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static void lua_display_runtime_cleanup(void)
|
||||
{
|
||||
if (!display_arbiter_is_owner(DISPLAY_ARBITER_OWNER_LUA)) {
|
||||
return;
|
||||
}
|
||||
ESP_LOGI(TAG, "Lua runtime cleanup: display still owned by Lua, releasing");
|
||||
|
||||
if (display_hal_destroy() == ESP_OK) {
|
||||
display_arbiter_release(DISPLAY_ARBITER_OWNER_LUA);
|
||||
}
|
||||
}
|
||||
|
||||
static int lua_display_init(lua_State *L)
|
||||
{
|
||||
esp_lcd_panel_handle_t panel_handle =
|
||||
@@ -1464,5 +1479,9 @@ int luaopen_display(lua_State *L)
|
||||
|
||||
esp_err_t lua_module_display_register(void)
|
||||
{
|
||||
return cap_lua_register_module("display", luaopen_display);
|
||||
esp_err_t err = cap_lua_register_module("display", luaopen_display);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
return cap_lua_register_runtime_cleanup(lua_display_runtime_cleanup);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user