simple_raspberrypi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/simple_raspberrypi.rb +24 -28
- metadata +9 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0917acd0e0bb14ccb503a045aafd2eb3394333be
|
4
|
+
data.tar.gz: 5c23476d9eaac6f1759e8bc618329cbb607636dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc9765693a8784fd2bb8a32c97c66e4ff84f856695f165997481d27267a0f61c195d9a7d3f4252a4728e10abb494b4407c6e625e14004672fac6781abd164af
|
7
|
+
data.tar.gz: a5cf9e7f8b7342008793013b1c26003d7d46569fb110acb258f3be6bc797988d0c7e96072772783f28d8b6d00fe9bb0dcaa405ee5a91eda66c91448d3851b26e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/simple_raspberrypi.rb
CHANGED
@@ -2,32 +2,32 @@
|
|
2
2
|
|
3
3
|
# file: simple_raspberrypi.rb
|
4
4
|
|
5
|
-
# desc: This gem is
|
6
|
-
# difference being the class name
|
7
|
-
#
|
8
|
-
# other gems which may use a module called RPi (i.e. rpi_gpio gem).
|
5
|
+
# desc: This gem is similar to the rpi gem, with the only
|
6
|
+
# difference being the class name and this gem depends upon
|
7
|
+
# rpi_gpio instead of the pi_piper gem which depends upon wiringpi.
|
9
8
|
|
10
|
-
require '
|
9
|
+
require 'rpi_gpio'
|
11
10
|
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@leds = []
|
17
|
-
|
18
|
-
class PinX < Pin
|
12
|
+
HIGH = 1
|
13
|
+
LOW = 0
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
class SimpleRaspberryPi
|
16
|
+
|
22
17
|
|
18
|
+
class PinX
|
19
|
+
include RPi
|
20
|
+
|
23
21
|
def initialize(id)
|
22
|
+
|
23
|
+
GPIO.setup id, :as => :output
|
24
24
|
@id = id
|
25
|
-
|
26
|
-
@state = self.value
|
25
|
+
|
27
26
|
end
|
28
27
|
|
29
28
|
def on(duration=nil)
|
30
|
-
|
29
|
+
|
30
|
+
set_pin HIGH;
|
31
31
|
@state = :on
|
32
32
|
(sleep duration; self.off) if duration
|
33
33
|
end
|
@@ -35,7 +35,7 @@ class SimpleRaspberryPi
|
|
35
35
|
def off(duration=nil)
|
36
36
|
|
37
37
|
return if self.off?
|
38
|
-
|
38
|
+
set_pin LOW
|
39
39
|
@state = :off
|
40
40
|
(sleep duration; self.on) if duration
|
41
41
|
end
|
@@ -73,7 +73,7 @@ class SimpleRaspberryPi
|
|
73
73
|
def set_pin(val)
|
74
74
|
|
75
75
|
state = @state
|
76
|
-
|
76
|
+
val == HIGH ? GPIO.set_high(@id) : GPIO.set_low(@id)
|
77
77
|
@state = state
|
78
78
|
end
|
79
79
|
|
@@ -91,6 +91,8 @@ class SimpleRaspberryPi
|
|
91
91
|
|
92
92
|
def initialize(x=[])
|
93
93
|
|
94
|
+
RPi::GPIO.set_numbering :bcm
|
95
|
+
|
94
96
|
a = case x
|
95
97
|
when Fixnum
|
96
98
|
[x]
|
@@ -132,9 +134,8 @@ class SimpleRaspberryPi
|
|
132
134
|
|
133
135
|
next unless File.exists? '/sys/class/gpio/gpio' + pin.to_s
|
134
136
|
|
135
|
-
|
136
|
-
|
137
|
-
uexp.close
|
137
|
+
File.wite "/sys/class/gpio/unexport", pin
|
138
|
+
|
138
139
|
end
|
139
140
|
|
140
141
|
end
|
@@ -144,12 +145,7 @@ class SimpleRaspberryPi
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def self.unexport(a)
|
147
|
-
a.each
|
148
|
-
|
149
|
-
uexp = open("/sys/class/gpio/unexport", "w")
|
150
|
-
uexp.write(pin)
|
151
|
-
uexp.close
|
152
|
-
end
|
148
|
+
a.each {|pin| File.wite "/sys/class/gpio/unexport", pin }
|
153
149
|
end
|
154
150
|
|
155
151
|
end
|
@@ -159,4 +155,4 @@ if __FILE__ == $0 then
|
|
159
155
|
# example
|
160
156
|
my_rpi = SimpleRaspberryPi.new %w(17 22 18 4 23 25 27) # <-- each pin connects to an LED
|
161
157
|
my_rpi.pins[ARGV.first.to_i].method(ARGV.last.to_sym).call
|
162
|
-
end
|
158
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_raspberrypi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,28 +31,28 @@ cert_chain:
|
|
31
31
|
DpcoUbnNCQrmIiU2mO0RoRPAsnFBZaDdhAlDbXuBSyuSS3Ygv+owE8Y6XHhjq6lz
|
32
32
|
VCYD0S+Rz1/Ltw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
34
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: rpi_gpio
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '0.2'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.2.0
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '0.2'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.2.0
|
56
56
|
description:
|
57
57
|
email: james@r0bertson.co.uk
|
58
58
|
executables: []
|
@@ -83,6 +83,6 @@ rubyforge_project:
|
|
83
83
|
rubygems_version: 2.4.8
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
|
-
summary:
|
87
|
-
|
86
|
+
summary: Has the same features as the rpi gem, but uses the rpi_gpio gem instead of
|
87
|
+
the pi_piper gem.
|
88
88
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|