summaryrefslogtreecommitdiff
path: root/lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-11-12 19:14:09 +1100
committerjacqueline <me@jacqueline.id.au>2023-11-12 19:14:09 +1100
commit8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de (patch)
tree02b6cf23f591915747ec2994381854a79979c4a0 /lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c
parent8471046a95ab9e00f7d42b56dbbc9ce3e5b424b9 (diff)
downloadtangara-fw-8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de.tar.gz
Convert the main menu screen to lua lol
Diffstat (limited to 'lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c')
-rw-r--r--lib/esp-idf-lua/examples/custom_lib/main/rtoslib.c24
1 files changed, 24 insertions, 0 deletions
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 <freertos/FreeRTOS.h>
+#include <freertos/task.h>
+
+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;
+}