wiringpi / wiringpi-ruby-legacy Goto Github PK
View Code? Open in Web Editor NEWRuby gem of the Arduino wiring-like C library WiringPi
Ruby gem of the Arduino wiring-like C library WiringPi
This version of WiringPi-Ruby is EOL, Please see: https://github.com/WiringPi/WiringPi-Ruby WiringPi: An implementation of most of the Arduino Wiring functions for the Raspberry Pi WiringPiGem: The WiringPi library wrapped up for Ruby with some OO goodness, sanity checking and other handy additions. WiringPi GPIO: require 'wiringpi' io = WiringPi::GPIO.new io.write(pin,value) io.read(pin,value) Shift out: io.write(latch_pin, LOW) io.shiftOut(data_pin, clock_pin, LSBFIRST or MSBFIRST, value) io.write(latch_pin, HIGH) Shift out an array of 1/0s (always uses LSBFIRST): io.shiftOutArray(data_pin, clock_pin, latch_pin, [0,1,0,0,1,1,1,0]) WiringPi GPIO with /sys/class/gpio: require 'wiringpi io = WiringPi::GPIO.new(WPI_MODE_SYS) # read/write/shift as usual WiringPi Serial: require 'wiringpi' s = WiringPi::Serial.new('/dev/ttyAMA0',9600) s.serialPuts('Hello world!') s.serialClose Full details at: https://projects.drogon.net/raspberry-pi/wiringpi/
Problems compiling native extensions on Raspbian. Detail currently unknown. Should roll a Raspbian SD and attempt to fix.
Requires Ruby-dev, also? Or fails with /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf
2.0.0-p0 :001 > require 'wiringpi'
LoadError: cannot load such file -- wiringpi/wiringpi
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /home/pi/.rvm/gems/ruby-2.0.0-p0/gems/wiringpi-1.1.0/lib/wiringpi.rb:1:in `<top (required)>'
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
from (irb):1
from /home/pi/.rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in `<main>'
How do i use parity with the raspberry?
Hi, I noticed the method #serialFlush is missing from the ruby library, it seems to me that the wrapper for the underlying C method is as well (but C and C lib wrapping is something completely obscure to me as far as now).
Is there any ruby way to flush the data coming from the serial?
Thanks for help
Andrea
Hi,
Got a small issue when installing WiringPi-Ruby, all compilation and gem installation went well (except the include path to the WiringPi headers were wrong (?)).
But when I tried running it I got 'Undefined symbol' for wiringPiSetup, after checking with nm,
none of the WiringPi functions were "linked" inside the .so.
But all this seems "normal" as neither the Makefile nor any other files have anything related to libwiringpi.a;
which makes me think that I've done something wrong...
I ended up modifying the Makefile created by ruby :/ to explicitly link to libwiringpi..
Looks like everything works now, but I still feel like something is wrong :/
Thanks for your work !
There's an update to the wiringpi library that auto-detects the revision of raspberry pi and adapts the pin number mappings to take into account the changed pinout of the header. Any plan to upgrade? I just looked at what it might take to do a pullup request, but I'm not familiar enough with swig and the ruby to c interface to do it with confidence...
Hello
I hope this is the right place to ask:
Gordons wiring_pi implementation does support the use of a hd44780 display ( https://projects.drogon.net/raspberry-pi/wiringpi/lcd-library/ )
Is it poossible to use it with this gem too? I have written a little ruby daemon, and it would be awesome to access the display directly without calling an external phyton script or something like that.
Greetings
Dakky
I have implemented a small pure-ruby-library(150 lines) for spi-access.
usage:
require "wiringpi/spi"
spi = WiringPi::Spi.new("/dev/spidev0.0",speed: 1000000)
result = spi.dataRW([1,2,3,0,4],delay: 100,bytedelay: 10)
spi.close
The lib requires the package ruby-1.9x and ruby-ffi, both is available in rapbian wheezy
Do you think its worth to integrate it into this project?
con:
pro:
By the way, the same arguments also count for any other functionality of wiringPi ;-))
Am i doing somehting wrong? or is this just a bug?
irb(main):007:0> require 'wiringpi2'
=> false
irb(main):008:0> s = WiringPi::SPI.new(0,500000)
NameError: uninitialized constant WiringPi::SPI::Wiringpi
from /var/lib/gems/1.9.1/gems/wiringpi2-2.0.1/lib/wiringpi/spi.rb:6:in `initialize'
from (irb):8:in `new'
from (irb):8
from /usr/bin/irb:12:in `<main>'
irb(main):009:0>
LoadError: /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi/wiringpi.so: undefined symbol: digitalRead - /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi/wiringpi.so
from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in require' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in
require'
from /root/.gem/ruby/2.0.0/gems/wiringpi-1.1.0/lib/wiringpi.rb:1:in <top (required)>' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in
require'
from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in rescue in require' from /usr/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:35:in
require'
from (irb):1
from /usr/bin/irb:12:in `
When running the following Ruby file as root:
#!/usr/bin/env ruby
require 'wiringpi'
io = WiringPi::GPIO.new(WPI_MODE_GPIO)
pin = 18
range = (15..255).to_a
range += range.reverse
def sleep_func(i)
sleep(0.004) if (i > 150)
sleep(0.005) if (i > 125) && (i < 151)
sleep(0.007) if (i > 100) && (i < 126)
sleep(0.010) if (i > 75) && (i < 101)
sleep(0.014) if (i > 50) && (i < 76)
sleep(0.018) if (i > 25) && (i < 51)
sleep(0.019) if (i > 1) && (i < 26)
end
loop do
range.each do |i|
io.pwmWrite pin, ((i/255.0) * 1000).to_i
sleep_func i
end
sleep 1
end
I get this error:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': cannot load such file -- wiringpi
(LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require'
from ./pulse.rb:3:in '{main}'
The squiggly brackets are <>. The markdown didn't like them, hehe.
I read Gadgetoid's issue and dutifully installed ruby-dev, but the same error still occurs.
Not sure if it's bad coding, bad installing or something else. I'm a bit of a 'Ruby Newby', so please forgive me if I'm being stupid :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.