rpi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/rpi.rb +28 -3
  5. metadata +3 -3
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23287a8198e3f7fd172c1fe4fb01566c1186dc04
4
- data.tar.gz: 81c585ef7df7d192f8a4f91a4aacdf713490cd97
3
+ metadata.gz: f62158b9602f0f043558974975649af84da05aa4
4
+ data.tar.gz: fc175f03388e4d6211f3f7ebf1ce59912addbdbf
5
5
  SHA512:
6
- metadata.gz: 783a49e803dcd7fe0f32569f02a7e6903ae52822f64eb50fc45242b4a3ee16e4ce4769640567d33edec52ccb304076158c11a5299abac0ac11c1de270c1ce23c
7
- data.tar.gz: 9e8374d93a8ae3d5f96bf607bb202e3f5124f668690a4a28cf487fd58b294e2a894734a4b1e06c73a7b54dc736ee32328305218b6beb447ba454ece1630ca213
6
+ metadata.gz: 6378a3f523e71e579f0396c24da331825f361c83bf74f2c3d00397a89e21fa2f647358457999f559af38e53d2d76f0f840d124f4042117a022476368e67ca56c
7
+ data.tar.gz: 93657657048cd18d0db7034c6a0b8ffc933a37185a1e1e1fb7380073a5960d87256c62b5149dc125633f1199a42452d8420ee4ae0c44e45ffd75b1e7c857e1a6
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/rpi.rb CHANGED
@@ -62,11 +62,28 @@ class RPi
62
62
  @state = state
63
63
  end
64
64
  end
65
+
66
+ class Void
67
+ def on(duration=nil) end
68
+ def off() end
69
+ def blink(seconds=0, duration=nil) end
70
+ alias stop off
71
+ end
65
72
 
66
73
  def initialize(a=[])
67
74
 
68
75
  @leds = a.map {|pin| Led.new pin }
69
76
 
77
+ def @leds.[](i)
78
+
79
+ if i.to_i >= self.length then
80
+ puts "RPi warning: Led instance #{i.inspect} not found"
81
+ Void.new
82
+ else
83
+ self.at(i)
84
+ end
85
+ end
86
+
70
87
  at_exit do
71
88
 
72
89
  # to avoid "Device or resource busy @ fptr_finalize - /sys/class/gpio/export"
@@ -82,8 +99,16 @@ class RPi
82
99
  end
83
100
  end
84
101
 
85
- def led() @leds end
86
-
102
+ def led() @leds end
103
+
104
+ def self.unexport(a)
105
+ a.each do |pin|
106
+
107
+ uexp = open("/sys/class/gpio/unexport", "w")
108
+ uexp.write(pin)
109
+ uexp.close
110
+ end
111
+ end
87
112
 
88
113
  end
89
114
 
@@ -92,4 +117,4 @@ if __FILE__ == $0 then
92
117
  # example
93
118
  my_rpi = RPi.new %w(17 22 18 4 23 25 27) # <-- each pin connects to an LED
94
119
  my_rpi.led[ARGV.first.to_i].method(ARGV.last.to_sym).call
95
- end
120
+ end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Wx7qSZTfBXcuGk2ymZ2BpCgaIse2YK04JVIWsaTEFsbO44uMfK+sRtGmTmyf/12f
32
32
  KzQM/zlgQa5pBA==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-02-15 00:00:00.000000000 Z
34
+ date: 2015-06-25 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pi_piper
@@ -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.2.2
83
+ rubygems_version: 2.4.6
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: The RPi gem makes it easy to set blinking LEDs on the Raspberry Pi
metadata.gz.sig CHANGED
Binary file