pi_piper 1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/README.md +22 -3
- data/Rakefile +1 -1
- data/lib/pi_piper/spi.rb +5 -9
- data/pi_piper.gemspec +2 -2
- metadata +2 -2
data/Manifest
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
## Overview
|
2
2
|
|
3
|
-
Pi Piper brings event driven programming to the Raspberry Pi's GPIO pins.
|
3
|
+
Pi Piper brings event driven programming to the Raspberry Pi's GPIO pins. Pi Piper works with all revisions of the Raspberry Pi,
|
4
|
+
and has been tested with Ruby 1.9.3 under both [Raspbian "wheezy"](http://www.raspberrypi.org/downloads) and [Occidentalis v0.2](http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-2).
|
5
|
+
|
6
|
+
To get started:
|
7
|
+
|
8
|
+
If you do not already have Ruby installed, first you'll need to:
|
9
|
+
|
10
|
+
sudo apt-get install ruby ruby1.9.1-dev
|
11
|
+
|
12
|
+
Despite one of the packages being titled "ruby1.9.1-dev", the above command will install Ruby 1.9.3 (as of January 2013) and the Ruby dev tools.
|
13
|
+
|
14
|
+
To install Pi Piper:
|
4
15
|
|
5
16
|
sudo gem install pi_piper
|
6
17
|
|
7
18
|
### GPIO
|
19
|
+
|
20
|
+
The GPIO pins (or General Purpose I/O pins) are the primary "do anything" pins on the Raspberry Pi. Reading inputs from them is as simple as:
|
21
|
+
|
8
22
|
```ruby
|
9
23
|
require 'pi_piper'
|
10
24
|
include PiPiper
|
@@ -13,6 +27,12 @@ watch :pin => 23 do
|
|
13
27
|
puts "Pin changed from #{last_value} to #{value}"
|
14
28
|
end
|
15
29
|
|
30
|
+
#Or
|
31
|
+
|
32
|
+
after :pin => 23, :goes => :high do
|
33
|
+
puts "Button pressed"
|
34
|
+
end
|
35
|
+
|
16
36
|
PiPiper.wait
|
17
37
|
```
|
18
38
|
|
@@ -32,8 +52,7 @@ Starting with version 1.2, Pi Piper offers SPI support.
|
|
32
52
|
|
33
53
|
```ruby
|
34
54
|
PiPiper::Spi.begin do |spi|
|
35
|
-
|
36
|
-
value = ((raw[1]&3) << 8) + raw[2]
|
55
|
+
puts spi.write [0x01, 0x80, 0x00]
|
37
56
|
end
|
38
57
|
```
|
39
58
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('pi_piper', '1.3') do |p|
|
5
|
+
Echoe.new('pi_piper', '1.3.1') do |p|
|
6
6
|
p.description = "Event driven Raspberry Pi GPIO library"
|
7
7
|
p.url = "http://github.com/jwhitehorn/pi_piper"
|
8
8
|
p.author = "Jason Whitehorn"
|
data/lib/pi_piper/spi.rb
CHANGED
@@ -85,19 +85,15 @@ module PiPiper
|
|
85
85
|
end
|
86
86
|
|
87
87
|
#Begin an SPI block. All SPI communications should be wrapped in a block.
|
88
|
-
def self.begin(chip=nil)
|
88
|
+
def self.begin(chip=nil, &block)
|
89
89
|
Bcm2835.spi_begin
|
90
90
|
chip = CHIP_SELECT_0 if !chip && block_given?
|
91
91
|
spi = new(chip)
|
92
92
|
|
93
|
-
if
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
self.end
|
98
|
-
end
|
99
|
-
else
|
100
|
-
spi
|
93
|
+
if block.arity > 0
|
94
|
+
block.call spi
|
95
|
+
else
|
96
|
+
spi.instance_exec &block
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
data/pi_piper.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "pi_piper"
|
5
|
-
s.version = "1.3"
|
5
|
+
s.version = "1.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jason Whitehorn"]
|
9
|
-
s.date = "2013-
|
9
|
+
s.date = "2013-02-05"
|
10
10
|
s.description = "Event driven Raspberry Pi GPIO library"
|
11
11
|
s.email = "jason.whitehorn@gmail.com"
|
12
12
|
s.extra_rdoc_files = ["README.md", "lib/pi_piper.rb", "lib/pi_piper/bcm2835.rb", "lib/pi_piper/libbcm2835.img", "lib/pi_piper/pin.rb", "lib/pi_piper/spi.rb"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pi_piper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|