rpi 0.2.3 → 0.3.0

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 +15 -5
  5. metadata +1 -1
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1478f9010eebd004a9f295f3e98b24f1775c0552
4
- data.tar.gz: 5c69eaf4a3672e278eecad1f98b09eb7f3e3bc8b
3
+ metadata.gz: 3625eff76af461b31c643c0c8260e49eef6bc1b2
4
+ data.tar.gz: ba63d08d58f6e4e7e99e44e531120e581de739ea
5
5
  SHA512:
6
- metadata.gz: 6acf844b4df7e8d1efffa06dc5cb2c95ea68ec588ae14078aa9fba98a6ad22fcb8e4e5cc29204545e0ea02f0e255a328f361372c87505dc762aaa9591ef6af3b
7
- data.tar.gz: d05aa7d3ad72eec6b261ee18538404a5124202d327cde3f07abfcb574b74f00ad8d2f45c3e20c71b04b553bfc04465aacaa6b74a0154abaf93bc8338722cfd06
6
+ metadata.gz: 1b4e0b0aa4947b2dd96d394de6064cbe337d4fa37c5529a75aeda6df042142931286664d073afca0c029234686a2507fd0a78f7dd4fbeebeac9549e3dad4deaa
7
+ data.tar.gz: 7fdf9fe5b55beb5d63af6dd6559fa69ada3bba33d1165ec076c88c6eee3c594a410a8858c987a56b6f903e09045feecd8caec3add1d54e3338511b3143659ad6
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
- @leds.each do |pin|
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
- alias on_exit unexport_all
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
@@ -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.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file