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.
- checksums.yaml +4 -4
- data/lib/wiringpi/gpio.rb +19 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad09ec33d1407927308321ea40ea4693684ca75c5b0dc3b9fd3cb04cbc2ea77a
|
4
|
+
data.tar.gz: fc5c3bb200ddc42bf4c83b4267485eb1ada94633e3341a016013c09bb7bd53d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
6
|
-
|
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
|