initial commit
This commit is contained in:
commit
c1816090d8
4 changed files with 57 additions and 0 deletions
32
main/esp32-c3-lua-test.c
Normal file
32
main/esp32-c3-lua-test.c
Normal 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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue