rpi 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rpi.rb +15 -5
- metadata +1 -1
- 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: 3625eff76af461b31c643c0c8260e49eef6bc1b2
|
4
|
+
data.tar.gz: ba63d08d58f6e4e7e99e44e531120e581de739ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b4e0b0aa4947b2dd96d394de6064cbe337d4fa37c5529a75aeda6df042142931286664d073afca0c029234686a2507fd0a78f7dd4fbeebeac9549e3dad4deaa
|
7
|
+
data.tar.gz: 7fdf9fe5b55beb5d63af6dd6559fa69ada3bba33d1165ec076c88c6eee3c594a410a8858c987a56b6f903e09045feecd8caec3add1d54e3338511b3143659ad6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rpi.rb
CHANGED
@@ -61,6 +61,10 @@ class RPi
|
|
61
61
|
self.update_value val
|
62
62
|
@state = state
|
63
63
|
end
|
64
|
+
|
65
|
+
def to_s()
|
66
|
+
@id
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
class Void
|
@@ -72,6 +76,8 @@ class RPi
|
|
72
76
|
|
73
77
|
def initialize(a=[])
|
74
78
|
|
79
|
+
unexport_all a
|
80
|
+
|
75
81
|
@leds = a.map {|pin| Led.new pin }
|
76
82
|
|
77
83
|
def @leds.[](i)
|
@@ -89,16 +95,18 @@ class RPi
|
|
89
95
|
# to avoid "Device or resource busy @ fptr_finalize - /sys/class/gpio/export"
|
90
96
|
# we unexport the pins we used
|
91
97
|
|
92
|
-
unexport_all
|
98
|
+
unexport_all a
|
93
99
|
end
|
94
100
|
end
|
95
101
|
|
96
102
|
def led() @leds end
|
97
103
|
|
98
|
-
def unexport_all()
|
104
|
+
def unexport_all(pins)
|
99
105
|
|
100
|
-
|
106
|
+
pins.each do |pin|
|
101
107
|
|
108
|
+
next unless File.exists? '/sys/class/gpio/gpio' + pin.to_s
|
109
|
+
|
102
110
|
uexp = open("/sys/class/gpio/unexport", "w")
|
103
111
|
uexp.write(pin)
|
104
112
|
uexp.close
|
@@ -106,7 +114,9 @@ class RPi
|
|
106
114
|
|
107
115
|
end
|
108
116
|
|
109
|
-
|
117
|
+
def on_exit
|
118
|
+
unexport_all @leds
|
119
|
+
end
|
110
120
|
|
111
121
|
def self.unexport(a)
|
112
122
|
a.each do |pin|
|
@@ -124,4 +134,4 @@ if __FILE__ == $0 then
|
|
124
134
|
# example
|
125
135
|
my_rpi = RPi.new %w(17 22 18 4 23 25 27) # <-- each pin connects to an LED
|
126
136
|
my_rpi.led[ARGV.first.to_i].method(ARGV.last.to_sym).call
|
127
|
-
end
|
137
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|