0.0
No commit activity in last 3 years
No release in over 3 years
Ruby FFI bindings for the wiringPi library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
>= 12.33
~> 3.8
>= 0.9.20

Runtime

~> 1.0
 Project Readme

ffi-wiring-pi

Gem VersionBuild Status

Description

Ruby FFI bindings for the wiringPi library.

Features

  • Can setup and work with GPIO
  • In progress: bindings to rpi_ws281x library to work with NeoPixel (ws2811 & ws2812) LED strips

Examples

Setup GPIO:

require 'ffi/wiring_pi'

# Will setup with wiringPi pin numbering scheme
FFI::WiringPi::GPIO.setup
FFI::WiringPi::GPIO.set_pin_mode(0, FFI::WiringPi::GPIO::OUTPUT)
FFI::WiringPi::GPIO.write(0, true)
# Or
FFI::WiringPi::GPIO.up(0)
# Or
pin = FFI::WiringPi::GPIO.get(0)
pin.up!

# Or

extend FFI::WiringPi::GPIO

setup
pin = get 0
pin.up!

pin2 = get 1, INPUT
p pin2.value

Requirements

Install

$ gem install ffi-wiring_pi

rpi_ws_281x

$ gem show ffi-wiring_pi

$ <gem path>/build_rpi_ws281x.sh
matrix = FFI::WiringPi::Neopixel::Matrix.new
matrix[:frequency] = 800_000 
matrix[:dmanum] = 10 # ??
matrix[:channel0][:gpionum] = 18 
matrix[:channel0][:count] = 44 * 11 # width * height
matrix[:channel0][:invert] = 0
matrix[:channel0][:brightness] = 255
matrix[:channel0][:strip_type] = FFi::WiringPi::Neopixel::WS2811_STRIP_RGB

count = 44 * 11
raw_pixels = FFI::MemoryPointer.new(:uint32_t, count)
raw_pixels[0] = 0x00201000
raw_pixels[1] = 0x00202020


FFI::WiringPi::Neopixel.init(matrix)
matrix[:channel0][:leds][0] = raw_pixels[0]
matrix[:channel0][:leds][1] = raw_pixels[1]


FFI::WiringPi::Neopixel.render(matrix)
sleep 10
FFI::WiringPi::Neopixel.finish(matrix)

License

Copyright (c) 2020 Mark Huk

See Licence for license information.