Lua Library for SPI and I2C

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

Lua Library for SPI and I2C

Foster Schucker
Because we are a much extended family, our Christmas comes early,
normally the week before.

One of my gifts this year was a huge selection of Breakout Garden kits
from Pimorni

https://shop.pimoroni.com/collections/breakout-garden

I'd like to connect them to my Pi (the easy part) and then mess around
with Lua making things happen (the fun part)

But there is a fair amount of bit banging to get the I2C and SPI devices
to work.

Can you suggest a library that works with the Raspberry PI that you have
used?

One of my goals is to incorporate devices like the RGB encoder or the
trackball into my Pico-8 or Love games.

Thanks for your ideas and Happy Holiday!

Foster
Reply | Threaded
Open this post in threaded view
|

Re: Lua Library for SPI and I2C

Volodymyr Bezobiuk
Hello

I have played a little bit with my RPi once but i used C library using FFI (because i couldn't find decent Lua library, iirc)

local alien = require 'alien'
local pigpio = alien.load 'pigpio'

and then like:

local gpioRead = pigpio.gpioRead
gpioRead:types{"uint", ret ="int"}
-- ....
-- skip
-- ....
local function piSclkTick()
  gpioWrite(SCLK, HIGH)
  gpioDelay(SPI_SCLK_HIGH_TIME)
  local read_bit = gpioRead(MOSI)
  gpioWrite(SCLK, LOW)
  gpioDelay(SPI_SCLK_LOW_TIME)
  return read_bit
end

etc etc
just read about how to usa FFI with Lua, and docs on pigpio library

Sincerely,
  Volodymyr



On Sun, Dec 20, 2020 at 4:57 PM Foster Schucker <[hidden email]> wrote:
Because we are a much extended family, our Christmas comes early,
normally the week before.

One of my gifts this year was a huge selection of Breakout Garden kits
from Pimorni

https://shop.pimoroni.com/collections/breakout-garden

I'd like to connect them to my Pi (the easy part) and then mess around
with Lua making things happen (the fun part)

But there is a fair amount of bit banging to get the I2C and SPI devices
to work.

Can you suggest a library that works with the Raspberry PI that you have
used?

One of my goals is to incorporate devices like the RGB encoder or the
trackball into my Pico-8 or Love games.

Thanks for your ideas and Happy Holiday!

Foster
Reply | Threaded
Open this post in threaded view
|

Re: Lua Library for SPI and I2C

Ką Mykolas
In reply to this post by Foster Schucker
Argh, sadly, eLua project sounds a little bit stale last year or so :|

On Sun, Dec 20, 2020 at 5:57 PM Foster Schucker <[hidden email]> wrote:

>
> Because we are a much extended family, our Christmas comes early,
> normally the week before.
>
> One of my gifts this year was a huge selection of Breakout Garden kits
> from Pimorni
>
> https://shop.pimoroni.com/collections/breakout-garden
>
> I'd like to connect them to my Pi (the easy part) and then mess around
> with Lua making things happen (the fun part)
>
> But there is a fair amount of bit banging to get the I2C and SPI devices
> to work.
>
> Can you suggest a library that works with the Raspberry PI that you have
> used?
>
> One of my goals is to incorporate devices like the RGB encoder or the
> trackball into my Pico-8 or Love games.
>
> Thanks for your ideas and Happy Holiday!
>
> Foster
Reply | Threaded
Open this post in threaded view
|

Re: Lua Library for SPI and I2C

aryajur
In reply to this post by Foster Schucker
I have used this in Raspberry Pi zero. I haven't tried SPI or I2C on this but this library has it in there:


Regards,
Milind

On Sun, Dec 20, 2020, 7:57 AM Foster Schucker <[hidden email]> wrote:
Because we are a much extended family, our Christmas comes early,
normally the week before.

One of my gifts this year was a huge selection of Breakout Garden kits
from Pimorni

https://shop.pimoroni.com/collections/breakout-garden

I'd like to connect them to my Pi (the easy part) and then mess around
with Lua making things happen (the fun part)

But there is a fair amount of bit banging to get the I2C and SPI devices
to work.

Can you suggest a library that works with the Raspberry PI that you have
used?

One of my goals is to incorporate devices like the RGB encoder or the
trackball into my Pico-8 or Love games.

Thanks for your ideas and Happy Holiday!

Foster