A Lua binding for bricks and bricklets by Tinkerforge GmbH. Allows working standalone (with built-in event loop) or with lua-ev.
(Lua) tinker integrates the native C API by Tinkerforge with some minor changes to allow external event handling (see directory capi).
git clone git://github.com/lipp/tinker.git
luarocks make rockspecs/tinker-scm-1.rockspec
See example directory.
NOTE: requires brickd running!
-- load module
local tinker = require'tinker'
-- create ipcon which connects to default brickd (localhost,port 4223).
local ipcon = tinker.ipcon()
-- let the ipcon create a brick/bricklet object
local lcd = ipcon:lcd20x4()
-- call some methods on the lcd object
lcd:backlight_on()
lcd:write_line(0,0,'Lua greetz all bricks')
lcd:backlight_off()
The API tries to be very close to the C API provided by tinkerforge. There are some differences though.
Creates a new ipcon (ip_connection). This is some kind of root object and factory for all bricks/bricklets you want to use.
Waits for the (internal) IO and message dispatch loops to finish.
Returns the internal socket fd (filedescriptor) which can be used to run an external event loop (e.g. lua-ev).
Reads all available data on the socket and dispatches them (e.g. calling registered callbacks) in the current thread context.
Creates a lcd20x4 bricklet object for the device with uid.
Writes 'text' on the display with the position specified.
Clears the entire display.
Enables the backlight.
Disables the backlight.
Determines whether the backlight is on.
Registers a callback, which will be called whenever a button is pressed. The callback gets the button_index passed in.