wiringpi-ruby 2.1.3 → 2.1.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wiringpi/gpio.rb +19 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfe5959820c3c16ef0299dc92155a7d41817840bc40a54e221eb029727706994
4
- data.tar.gz: defdc2da075386ac4b98904d5e73242c00efcc901098bb26b05e065356a29038
3
+ metadata.gz: ad09ec33d1407927308321ea40ea4693684ca75c5b0dc3b9fd3cb04cbc2ea77a
4
+ data.tar.gz: fc5c3bb200ddc42bf4c83b4267485eb1ada94633e3341a016013c09bb7bd53d9
5
5
  SHA512:
6
- metadata.gz: 6be801a9f95a83e9c18cc6f0f8c48d83eafa55f9324742cd559c01a32df1e98d72a3dbcf7ca14b43623e5a0d5167eb495cf8e1025382ed46f201ec27682df59b
7
- data.tar.gz: 49647a809f4aea88dc79a57d5742eef5cffcf0512ab32189042dbfd7de331400dfe34a9d95ce63eb47c921486c8d0a67e656b53bb098bd5b51d74f31af844078
6
+ metadata.gz: eb80e2fbdbcd1306dde3384d89481a63850fdb8c2af5f49eb07e12bbb1006dcf1b94cd550eefbe04a5f71517fbabeb3aa18443b91dbe38c0523dd56f2faf57c5
7
+ data.tar.gz: 4d2c91e5fa2ac64e0fdea715b46767f576750130e14506351ae3ab4ed52d039372b7772aad15591ba2bc02f113afea35aeeb38b30559a1f1bbe376580db65ae4
data/lib/wiringpi/gpio.rb CHANGED
@@ -2,8 +2,25 @@ module WiringPi
2
2
  class GPIO
3
3
  attr_reader :modules, :pins
4
4
 
5
- def initialize(pin_layout = GPIO_WPI, &block)
6
- @pin_layout = pin_layout
5
+ @@system_ready = false
6
+
7
+ def self.setup(pin_layout = GPIO_WPI)
8
+ return if @@system_ready
9
+
10
+ case pin_layout
11
+ when GPIO_WPI; Wiringpi.wiringPiSetup
12
+ when GPIO_NORMAL; Wiringpi.wiringPiSetupGpio
13
+ when GPIO_PHYSICAL; Wiringpi.wiringPiSetupPhys
14
+ when GPIO_SYSTEM; Wiringpi.wiringPiSetupSys
15
+ else raise 'unknown pin layout to setup'
16
+ end
17
+
18
+ @@system_ready = true
19
+ end
20
+
21
+ def initialize(&block)
22
+ raise 'system is not ready, please call WiringPi::GPIO.setup first' unless @@system_ready
23
+
7
24
  @pins = []
8
25
  @modules = []
9
26
  setup_wiring_pi
@@ -130,17 +147,5 @@ module WiringPi
130
147
  @pins[offset + module_instance.pin_base] = 'ENABLED'
131
148
  end
132
149
  end
133
-
134
- private
135
-
136
- def setup_wiring_pi
137
- case @pin_layout
138
- when GPIO_WPI; Wiringpi.wiringPiSetup
139
- when GPIO_NORMAL; Wiringpi.wiringPiSetupGpio
140
- when GPIO_PHYSICAL; Wiringpi.wiringPiSetupPhys
141
- when GPIO_SYSTEM; Wiringpi.wiringPiSetupSys
142
- else raise 'unknown pin layout to setup'
143
- end
144
- end
145
150
  end
146
151
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiringpi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rifqi