mirror of
git://projects.qi-hardware.com/nn-usb-fpga.git
synced 2025-01-09 19:50:15 +02:00
7d9b7b803c
Adding blinker demo: lua_blink_led
26 lines
737 B
Lua
26 lines
737 B
Lua
|
|
--[[ This is a short (demonstration) piece of Lua
|
|
script which calls in some C functions from a file
|
|
called candy.c; the functions are accessed via a
|
|
table called extratasks (that's defines in the
|
|
C code) and called via the names dothis and dothat -
|
|
again defined in the candy.c file
|
|
]]
|
|
|
|
-- Setting up demo variables that will be passed to C
|
|
print("Lua code running ...")
|
|
stuff = {hotel = 48, hq = 404, town = 1}
|
|
|
|
-- Loading and calling the C
|
|
require "candy"
|
|
summat = extratasks.dothis(stuff)
|
|
somemore = extratasks.dothat(summat)
|
|
|
|
-- Lua code to show you the results
|
|
print ("... back into Lua code")
|
|
print ("Values in Lua now", summat, somemore)
|
|
print ("Table contains ...")
|
|
for k,v in pairs(stuff) do
|
|
print (k,v)
|
|
end
|