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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9a312a98099683aa6ab0e98cbb8b2534a4da409
4
- data.tar.gz: 0a3eb6f11ea90086e4acb62e9773dcb3693ec60e
3
+ metadata.gz: 0917acd0e0bb14ccb503a045aafd2eb3394333be
4
+ data.tar.gz: 5c23476d9eaac6f1759e8bc618329cbb607636dc
5
5
  SHA512:
6
- metadata.gz: 68cbdc71877e9c817641075f4b5cf57c4f29b7c840ca552083cc976a58961d0b992abefd3520fe0e24f4014abae5d6371489716a8844121b7caaeb49e4477981
7
- data.tar.gz: b1ef413be15c4e4fb2f2f57024bac7b9920124b706efe239382322fe2f90ced51afd73f7c1977fc75c7ebd44fa3b127f038738ff9d2da73b46f412ffb2ae4cae
6
+ metadata.gz: 9cc9765693a8784fd2bb8a32c97c66e4ff84f856695f165997481d27267a0f61c195d9a7d3f4252a4728e10abb494b4407c6e625e14004672fac6781abd164af
7
+ data.tar.gz: a5cf9e7f8b7342008793013b1c26003d7d46569fb110acb258f3be6bc797988d0c7e96072772783f28d8b6d00fe9bb0dcaa405ee5a91eda66c91448d3851b26e
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,32 +2,32 @@
2
2
 
3
3
  # file: simple_raspberrypi.rb
4
4
 
5
- # desc: This gem is the same as the rpi gem, with the only
6
- # difference being the class name. Use this as an alternative
7
- # to the rpi gem to avoid the possiblity of conflict with any
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 'pi_piper'
9
+ require 'rpi_gpio'
11
10
 
12
11
 
13
- class SimpleRaspberryPi
14
- include PiPiper
15
-
16
- @leds = []
17
-
18
- class PinX < Pin
12
+ HIGH = 1
13
+ LOW = 0
19
14
 
20
- HIGH = 1
21
- LOW = 0
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
- super(pin: id, direction: :out)
26
- @state = self.value
25
+
27
26
  end
28
27
 
29
28
  def on(duration=nil)
30
- super();
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
- super()
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
- self.update_value val
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
- uexp = open("/sys/class/gpio/unexport", "w")
136
- uexp.write(pin)
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 do |pin|
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.1.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-02-21 00:00:00.000000000 Z
34
+ date: 2016-04-09 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
- name: pi_piper
37
+ name: rpi_gpio
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '1.9'
42
+ version: '0.2'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 1.9.9
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: '1.9'
52
+ version: '0.2'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 1.9.9
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: Use this gem as an alternative to the rpi gem if you are experiencing class
87
- or module conflict while using other gems which use the name RPi.
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