From 8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de Mon Sep 17 00:00:00 2001 From: jacqueline Date: Sun, 12 Nov 2023 19:14:09 +1100 Subject: Convert the main menu screen to lua lol --- lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c (limited to 'lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c') diff --git a/lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c b/lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c new file mode 100644 index 00000000..6c5e219a --- /dev/null +++ b/lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c @@ -0,0 +1,24 @@ +#include "rtoslib.h" +#include +#include + +static int ldelay(lua_State *L) +{ + int ms = luaL_checkinteger(L, 1); + + vTaskDelay(pdMS_TO_TICKS(ms)); + + return 0; +} + +static const struct luaL_Reg lrtos_funcs[] = { + { "delay", ldelay }, + { NULL, NULL } +}; + +int luaopen_lrtos(lua_State *L) +{ + luaL_newlib(L, lrtos_funcs); + + return 1; +} -- cgit v1.2.3