Lua is a powerful but lightweight scripting language that can be embedded into your application. It is written in C and is provided as a library that can easily be added to your project. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
Lua is and open source package that is provided at no cost and is licensed under the MIT license. It can be downloaded from the Lua homepage.
Embedded Access can provide you with an integration layer allowing you to easily incorporate Lua into your MQX based application.
Writing Lua based scripts is quite straight forward and our integration includes all the code binding so you can incorporate MQX commands into your script. For example, here’s a short script for toggling an LED:
function sqwave(pinname,count,delay)
local led = { pin=pinname, direction=1, value = 1, functionality = 0}
for i=1, count do
led.value=1
lwgpio.init(led)
mqx._time_delay(delay)
led.value=0
lwgpio.init(led)
mqx._time_delay(delay)
end
end