Raspberry Pi GPIO module for LuaJIT

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Raspberry Pi GPIO module for LuaJIT

Mike Pall-38
The Raspberry Pi foundation sent me a free RPi. Many thanks to
Alex Bradbury for arranging this! As expected, LuaJIT runs just
fine on the little device. :-)

To give something back, I've written a simple GPIO module, which
allows you to control the GPIO pins from a Lua script. It uses the
LuaJIT FFI and doesn't need any extra C modules!

Provided you've already compiled LuaJIT for the RPi, here's how to
install the module:
  mkdir -p /usr/local/share/lua/5.1/rpi
  cp gpio.lua /usr/local/share/lua/5.1/rpi/gpio.lua

The attached sample script testgpio.lua blinks an LED + resistor
attached to GPIO 0 and reads the input status of GPIO 6.

[Yes, you need to be root to run that, since it works without the
help of a driver, by writing directly to the device.]

You can read/write the pins with the gpio.pin[] table. These
correspond to the numbering given on the following drawing of the
GPIO connector on the RPi: http://elinux.org/File:GPIOs.png

There's also a raw API for accessing all of the GPIO pins on the
chip. Please read the source for details and do NOT use raw pin
numbers, unless you know what they do! Don't blame me, if you fry
your RPi -- you're on your own.

Arguably, the module is quite primitive right now. There's much
more you can do with the chip. Docs are available from:
  http://elinux.org/RPi_Low-level_peripherals

Since I'm already way too busy, I'd appreciate it if someone would
step forward and take over development, put it under version
control, package it up and so on. The current sample module is
public domain. I guess the Lua community would probably most
welcome a MIT licensed module. Thank you!

--Mike

gpio.lua (2K) Download Attachment
testgpio.lua (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Raspberry Pi GPIO module for LuaJIT

Craig Barnes
Hi, thanks for this. I've thrown a copy up on GitHub[1] and intend to
package it for the Fedora 17 (not 14) remix when it's available. I'm
willing to maintain it and package for other distributions if there's
some interest. I don't yet have a Pi to test with, although hopefully
it'll arrive before Fedora 17 does.

[1]: https://github.com/craigbarnes/luajit-rpi-gpio


On 30 April 2012 20:34, Mike Pall <[hidden email]> wrote:

>
> The Raspberry Pi foundation sent me a free RPi. Many thanks to
> Alex Bradbury for arranging this! As expected, LuaJIT runs just
> fine on the little device. :-)
>
> To give something back, I've written a simple GPIO module, which
> allows you to control the GPIO pins from a Lua script. It uses the
> LuaJIT FFI and doesn't need any extra C modules!
>
> Provided you've already compiled LuaJIT for the RPi, here's how to
> install the module:
>  mkdir -p /usr/local/share/lua/5.1/rpi
>  cp gpio.lua /usr/local/share/lua/5.1/rpi/gpio.lua
>
> The attached sample script testgpio.lua blinks an LED + resistor
> attached to GPIO 0 and reads the input status of GPIO 6.
>
> [Yes, you need to be root to run that, since it works without the
> help of a driver, by writing directly to the device.]
>
> You can read/write the pins with the gpio.pin[] table. These
> correspond to the numbering given on the following drawing of the
> GPIO connector on the RPi: http://elinux.org/File:GPIOs.png
>
> There's also a raw API for accessing all of the GPIO pins on the
> chip. Please read the source for details and do NOT use raw pin
> numbers, unless you know what they do! Don't blame me, if you fry
> your RPi -- you're on your own.
>
> Arguably, the module is quite primitive right now. There's much
> more you can do with the chip. Docs are available from:
>  http://elinux.org/RPi_Low-level_peripherals
>
> Since I'm already way too busy, I'd appreciate it if someone would
> step forward and take over development, put it under version
> control, package it up and so on. The current sample module is
> public domain. I guess the Lua community would probably most
> welcome a MIT licensed module. Thank you!
>
> --Mike

Reply | Threaded
Open this post in threaded view
|

Re: Raspberry Pi GPIO module for LuaJIT

LanceKalp
This post has NOT been accepted by the mailing list yet.
In reply to this post by Mike Pall-38
LED's are point-source devices,LED Tube  which means that there will be
unlit sections between the LED Spotlight individual LED's,
and neon tubes glow along their led strip 12v entire length.