initial commit

This commit is contained in:
Juraj Michalek 2024-09-25 08:54:57 +02:00
commit c1816090d8
4 changed files with 57 additions and 0 deletions

6
CMakeLists.txt Normal file
View file

@ -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)

2
main/CMakeLists.txt Normal file
View file

@ -0,0 +1,2 @@
idf_component_register(SRCS "esp32-c3-lua-test.c"
INCLUDE_DIRS ".")

32
main/esp32-c3-lua-test.c Normal file
View file

@ -0,0 +1,32 @@
#include <stdio.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#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));
}
}

17
main/idf_component.yml Normal file
View file

@ -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