Project

taopaipai

0.0
No commit activity in last 3 years
No release in over 3 years
Access Raspberry Pi PGIO from Linux User Space.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Taopaipai

A dead-simple, dependency-less gem to control Raspberry GPIO pins using Linux User Space. No root-access is required as Taopaipai handles pins reservation using the filsystem.

Build Status Coverage Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'taopaipai'

And then execute:

$ bundle

Or install it yourself as:

$ gem install taopaipai

Usage

GPIO pins are exposed through the Taopaipai.gpio method :

require 'taopaipai'

pin = Taopaipai.gpio.pin(17, direction: :out, value: 0)

# Write 1 to the pin 17
pin.value(1)

# Read from the pin 27
Taopaipai.gpio.pin(27, direction: :in).value
# => 0

Notice that Taopaipai memoizes the pin states so that it never writes again to a pin unless its value or direction changed.

# Writes for the first time
pin = Taopaipai.gpio.pin(17, direction: :out, value: 1)

# Does not write anything
1000.times do
  pin.value(1)
end

# Back to 0 !
pin(17).value(0)

# Change the pin's direction and read its value
pin.direction(:in).value

To free pins so that other modules may use them :

Taopaipai.gpio.release

Other useful projects

Taopaipai was meant to be the simplest approach to control GPIO using ruby code, without the need for native extensions or FFI. If you need more powerful control over Raspberry Pi IO, you may have a look at these useful projects:

  • WiringPi (C/C++): Arduino wiring-like WiringPi Library for the Raspberry Pi
  • WiringPi-Ruby: Ruby wrapper around the WiringPi library
  • PiPiper: Event driven Raspberry Pi GPIO programming in Ruby

Contributing

  1. Fork it ( http://github.com/servebox/taopaipai/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request