嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元微信扫码支付:3 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
使用stm32f429意法开发板可以直接运行,LUA脚本非常适用于交互场景
const char LUA_SCRIPT_GLOBAL[] ="\
delay_cnt = 500 \
while 1 do \
led_off() \
delay(delay_cnt) \
led_on() \
delay(delay_cnt) \
for i = 1, 100 , 5 do \
led_on() \
printf(\"which = %d, what = %d $why\"..'connect\r\n', 123, 456)\
end \
end";
static const luaL_Reg mylib[] =
{
{"printf", lua_printf },
{"led_on", lua_led_on },
{"led_off", lua_led_off },
{"led_toggle", lua_led_toggle },
{"delay", lua_delay },
{"Delay", Delay },
{NULL, NULL }
};
int do_lua_script(void)
{
lua_State *L = NULL;
L= luaL_newstate();
while(1)
{
//button_check();
lua_pushcfunction(L, lua_led_toggle);
lua_setglobal(L, "led_toggle");
luaL_dostring(L, "led_toggle();");
}
lua_close(L);
}
int lua_run(void)
{
//do_lua_script();
int ret = 0;
lua_State *L = NULL;
L =luaL_newstate();
if(L == NULL)
abort();
luaopen_base(L);
luaopen_mylib(L);
ret= luaL_dostring(L, LUA_SCRIPT_GLOBAL);
if (ret != 0)
abort();
lua_close(L);
abort();
for(;;)
{
}
}