commit c1816090d80e334edd88666c3004ca7a649ec24f Author: Juraj Michalek Date: Wed Sep 25 08:54:57 2024 +0200 initial commit diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4131a8d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following five lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(esp32-c3-lua-test) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..fa1105e --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "esp32-c3-lua-test.c" + INCLUDE_DIRS ".") diff --git a/main/esp32-c3-lua-test.c b/main/esp32-c3-lua-test.c new file mode 100644 index 0000000..634a5d0 --- /dev/null +++ b/main/esp32-c3-lua-test.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +void app_main(void) +{ + printf("Starting Lua\n"); + lua_State *L = luaL_newstate(); + printf("Opening Lua Libs\n"); + luaL_openlibs(L); + + printf("Calling Lua code: \n"); + lua_pushinteger(L, 42); + lua_setglobal(L, "answer"); + + char * code = "print(answer)"; + + if (luaL_dostring(L, code) == LUA_OK) { + lua_pop(L, lua_gettop(L)); + } + + printf("Closing Lua\n"); + lua_close(L); + + while(1) { + vTaskDelay(pdMS_TO_TICKS(16)); + } +} diff --git a/main/idf_component.yml b/main/idf_component.yml new file mode 100644 index 0000000..7beb110 --- /dev/null +++ b/main/idf_component.yml @@ -0,0 +1,17 @@ +## IDF Component Manager Manifest File +dependencies: + georgik/lua: "^5.5.0" + ## Required IDF version + idf: + version: ">=4.1.0" + # # Put list of dependencies here + # # For components maintained by Espressif: + # component: "~1.0.0" + # # For 3rd party components: + # username/component: ">=1.0.0,<2.0.0" + # username2/component2: + # version: "~1.0.0" + # # For transient dependencies `public` flag can be set. + # # `public` flag doesn't have an effect dependencies of the `main` component. + # # All dependencies of `main` are public by default. + # public: true