diff options
author | cheapie <no-email-for-you@example.com> | 2022-01-07 16:51:04 -0600 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2022-01-07 16:51:04 -0600 |
commit | 32641893e75f11903489a38a201bd661c8f99b50 (patch) | |
tree | 2412538cad02594cf04f7952c8a751c54155fd99 /lc_examples/ioexpander.lua | |
parent | ee316f2325e26dc532ccaa09369e9d173b5ef411 (diff) | |
download | digistuff-32641893e75f11903489a38a201bd661c8f99b50.tar digistuff-32641893e75f11903489a38a201bd661c8f99b50.tar.gz digistuff-32641893e75f11903489a38a201bd661c8f99b50.tar.bz2 digistuff-32641893e75f11903489a38a201bd661c8f99b50.tar.xz digistuff-32641893e75f11903489a38a201bd661c8f99b50.zip |
Diffstat (limited to 'lc_examples/ioexpander.lua')
-rw-r--r-- | lc_examples/ioexpander.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lc_examples/ioexpander.lua b/lc_examples/ioexpander.lua new file mode 100644 index 0000000..02a8fee --- /dev/null +++ b/lc_examples/ioexpander.lua @@ -0,0 +1,14 @@ +--Digilines I/O Expander Example + +--Connect two I/O expanders, one on channel "expander1" and one on "expander2" +--The pins on the second expander will follow the input states on the first one. +--In addition, whenever an input on the first expander changes, a line will be logged to the terminal with the new state. + +local function iostr(pin) + return (pin and "1" or "0") +end + +if event.channel == "expander1" then + digiline_send("expander2",event.msg) + print(string.format("A: %s B: %s C: %s D: %s",iostr(event.msg.a),iostr(event.msg.b),iostr(event.msg.c),iostr(event.msg.d))) +end |