rpi 0.4.8 → 0.5.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 +6 -132
- metadata +24 -24
- 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: 77b014df263b389a23ca63fd6004028709863b2f
|
4
|
+
data.tar.gz: 5935ff94f91c371b67c2f3da94116210e901903e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8a9f351e2caa531490a6e14ee93e5fc522792f8f0e3ffc0897983e7c30068bf038b67ca54c9582ed43e3fcfc718f560baf5fa35120068d47cacc7f0a8a398a
|
7
|
+
data.tar.gz: ba62392047290f6318eae029c18f4009514fea7e8e9d42a31ac91fa6be81002ef4d72637ef0a95932ff6f5f54c05ed29f9f7587a91bc3fdecb31e416ec739798
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rpi.rb
CHANGED
@@ -2,103 +2,11 @@
|
|
2
2
|
|
3
3
|
# file: rpi.rb
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'rpi_pinout'
|
6
6
|
|
7
7
|
|
8
8
|
class RPi
|
9
|
-
include PiPiper
|
10
|
-
|
11
|
-
@leds = []
|
12
|
-
|
13
|
-
class PinX < Pin
|
14
|
-
|
15
|
-
HIGH = 1
|
16
|
-
LOW = 0
|
17
|
-
|
18
|
-
def initialize(id)
|
19
|
-
@id = id
|
20
|
-
super(pin: id, direction: :out)
|
21
|
-
@on, @blinking = false, false
|
22
|
-
end
|
23
|
-
|
24
|
-
def on(durationx=nil, duration: nil)
|
25
|
-
super();
|
26
|
-
@on = true
|
27
|
-
duration ||= durationx
|
28
|
-
|
29
|
-
@off_thread.exit if @off_thread
|
30
|
-
@on_thread = Thread.new {(sleep duration; self.off()) } if duration
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def off(durationx=nil, duration: nil)
|
35
|
-
|
36
|
-
super();
|
37
|
-
return if @internal_call
|
38
|
-
|
39
|
-
@on, @blinking = false, false
|
40
|
-
duration ||= durationx
|
41
|
-
|
42
|
-
@on_thread.exit if @on_thread
|
43
|
-
@off_thread = Thread.new { (sleep duration; self.on()) } if duration
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
alias high on # opposite of low
|
48
|
-
alias open on # opposite of close
|
49
|
-
alias lock on # opposite of unlock
|
50
|
-
|
51
|
-
alias stop off
|
52
|
-
alias low off
|
53
|
-
alias close off
|
54
|
-
alias unlock off
|
55
|
-
|
56
|
-
def blink(seconds=0.5, duration: nil)
|
57
|
-
|
58
|
-
@blinking = true
|
59
|
-
t2 = Time.now + duration if duration
|
60
|
-
|
61
|
-
Thread.new do
|
62
|
-
while @blinking do
|
63
|
-
|
64
|
-
set_pin HIGH
|
65
|
-
sleep seconds / 2.0
|
66
|
-
break if !@blinking
|
67
|
-
sleep seconds / 2.0
|
68
|
-
break if !@blinking
|
69
|
-
|
70
|
-
set_pin LOW;
|
71
|
-
sleep seconds / 2.0
|
72
|
-
break if !@blinking
|
73
|
-
sleep seconds / 2.0
|
74
|
-
|
75
|
-
break if !@blinking
|
76
|
-
|
77
|
-
self.off if duration and Time.now >= t2
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
alias oscillate blink
|
84
|
-
|
85
|
-
def on?() @on end
|
86
|
-
def off?() !@on end
|
87
|
-
|
88
|
-
# set val with 0 (off) or 1 (on)
|
89
|
-
#
|
90
|
-
def set_pin(val)
|
91
|
-
|
92
|
-
@internal_call = true
|
93
|
-
self.update_value val
|
94
|
-
@internal_call = false
|
95
|
-
end
|
96
9
|
|
97
|
-
def to_s()
|
98
|
-
@id
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
10
|
class Void
|
103
11
|
def on(duration=nil) end
|
104
12
|
def off() end
|
@@ -118,58 +26,24 @@ class RPi
|
|
118
26
|
when Array
|
119
27
|
x
|
120
28
|
end
|
121
|
-
|
122
|
-
unexport_all a
|
123
29
|
|
124
|
-
@pins = a.map {|pin|
|
30
|
+
@pins = a.map {|pin| RPiPinOut.new pin }
|
125
31
|
|
126
32
|
def @pins.[](i)
|
127
33
|
|
128
|
-
if i.
|
129
|
-
puts "RPi warning:
|
34
|
+
if i.to_i >= self.length then
|
35
|
+
puts "RPi warning: RPiPinOut instance #{i.inspect} not found"
|
130
36
|
Void.new
|
131
37
|
else
|
132
|
-
|
38
|
+
self.at(i)
|
133
39
|
end
|
134
40
|
end
|
135
|
-
|
136
|
-
at_exit do
|
137
|
-
|
138
|
-
# to avoid "Device or resource busy @ fptr_finalize - /sys/class/gpio/export"
|
139
|
-
# we unexport the pins we used
|
140
|
-
|
141
|
-
unexport_all a
|
142
|
-
end
|
41
|
+
|
143
42
|
end
|
144
43
|
|
145
44
|
def pin() @pins.first end
|
146
45
|
def pins() @pins end
|
147
46
|
|
148
|
-
def unexport_all(pins)
|
149
|
-
|
150
|
-
pins.each do |pin|
|
151
|
-
|
152
|
-
next unless File.exists? '/sys/class/gpio/gpio' + pin.to_s
|
153
|
-
|
154
|
-
uexp = open("/sys/class/gpio/unexport", "w")
|
155
|
-
uexp.write(pin)
|
156
|
-
uexp.close
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
def on_exit
|
162
|
-
unexport_all @pins
|
163
|
-
end
|
164
|
-
|
165
|
-
def self.unexport(a)
|
166
|
-
a.each do |pin|
|
167
|
-
|
168
|
-
uexp = open("/sys/class/gpio/unexport", "w")
|
169
|
-
uexp.write(pin)
|
170
|
-
uexp.close
|
171
|
-
end
|
172
|
-
end
|
173
47
|
|
174
48
|
end
|
175
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -12,49 +12,49 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE3MDUxMDE4NDg1NloXDTE4MDUxMDE4NDg1NlowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
ggEBAOFkwT/if5CgcXMrn7cdmr9XX6sY4EPLbjSB6VWIwwfhWOubsKMy6ReBR6hm
|
19
|
+
2PgZk4exPjhgc07ODACcMAMp9uvlYiwHPmnmATfEOFBRIR6sGOZCUVIlvelkAf+7
|
20
|
+
6ELA85iDFcxUlr7DIYr6BM8w7bmC+qzyrwWDyV0mnP1qbfpS0QZ5Lii4wW8Te9vX
|
21
|
+
6FMN3Yodtfvdr50FSdNGHJC0w6+tX5lphAo2i3vkz4KOkBdOR3DRwyAw/nDbZsuE
|
22
|
+
M9Yqtr/UoTes/BeqgeR5IpNvSDcsSXNVw+BsUjMzElnr4uTOOrlQOHs+f2R2s7B+
|
23
|
+
DP26Wb77cQ+ntbT907SOaqrMAJUCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUB7WTIBd3fdE68snzyGPPygagrHMwJgYDVR0RBB8w
|
25
25
|
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAYnIMsxNv
|
27
|
+
iHynTuej7HpUtOrcbGX4D3kDqNBYNdKorkFWU5+jQWzVuLcr+NWIKZGJOLyUfQBM
|
28
|
+
V3v5v3ZPNWC89ClgIk8xfgPyR1SIoKOqusfJpB0GmOJuy7f3zfFUKs82dOPkdWlo
|
29
|
+
NzwfsF9MmFLkPcCw2hFBBvJsrLlHowT4WQ51I/K6aw83dXgCAjQA1DYvCjldEdEc
|
30
|
+
Fb17YZ2p7442pT1asXspSsujtWuRZrB2L6Kmmjr03Q9Eie41pkUQTaHTcWtETrbp
|
31
|
+
03+2ttzIMR7wl/1qlZlAlvMQ71TeyXUIKE3dzMV3MlQqD5jNgpweeDOVAu06J77/
|
32
|
+
C4Q94lEe/XWITQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: rpi_pinout
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '1
|
42
|
+
version: '0.1'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
45
|
+
version: 0.1.1
|
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: '1
|
52
|
+
version: '0.1'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
55
|
+
version: 0.1.1
|
56
56
|
description:
|
57
|
-
email: james@
|
57
|
+
email: james@jamesrobertson.eu
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.6.8
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: The RPi gem makes it easy to set the GPIO pins on the Raspberry Pi e.g. RPi.new([4,27]).pins.first.on
|
metadata.gz.sig
CHANGED
Binary file
|