- static int lua_led_on(lua_State *L)
- {
- PCout(13) = 1;
- return 1;
- }
- static int lua_led_off(lua_State *L)
- {
- PCout(13) = 0;
- return 1;
- }
-
- static int lua_delay(lua_State *L)
- {
- int num;
- num= lua_tointeger(L, 1);
- delay_ms(num);
- return 1;
- }
- static const struct luaL_Reg mylib[]=
- {
- {"led_on",lua_led_on},
- {"led_off",lua_led_off},
- {"delay",lua_delay},
- {NULL,NULL}
- };
- const char LUA_SCRIPT_GLOBAL[] =" \
- off = 500 \
- on = 500 \
- while 1 do \
- led_on() \
- delay(off) \
- led_off() \
- delay(on) \
- end";
|