chip-gpio 0.0.2 → 0.0.3
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/chip-gpio/Pin.rb +14 -33
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2bd88f0fd76071fd6292675337841d22465f029
|
4
|
+
data.tar.gz: ce6a49044b5748da33d16d5af5a2dfb7369668c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff287ee4e02d61680d5b1c927b56eb3ee64420d81bab7c8b5e8b8846da44d25774fe96839455f25e12d19f251514856dd8ce28b11001e07052e93a873b06fc5e
|
7
|
+
data.tar.gz: 2819b7e2d8f00def73258b74b66a821bedcdaca2afaa58eaf4b81a016d304ea431a90ec895af434e3e32ac01dffd6b84e1e1b489028bc0aaeded86e0a4d472f7
|
data/lib/chip-gpio/Pin.rb
CHANGED
@@ -67,47 +67,28 @@ module ChipGPIO
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
-
def self.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
throw "Unable to parse /proc/version string" if match.nil?
|
80
|
-
throw "Unable to parse /proc/version string - could not find version numbers" if match.captures.size != 2
|
81
|
-
|
82
|
-
major = match.captures[0]
|
83
|
-
minor = match.captures[1]
|
84
|
-
|
85
|
-
if major == "4" && minor == "3"
|
86
|
-
return :v4_3
|
87
|
-
elsif major== "4" && minor == "4"
|
88
|
-
return :v4_4
|
89
|
-
else
|
90
|
-
throw "Unrecognized version #{major}.#{minor}"
|
70
|
+
def self.get_xio_base
|
71
|
+
labels = Dir::glob("/sys/class/gpio/*/label")
|
72
|
+
labels.each do |label|
|
73
|
+
value = File.read(label).strip
|
74
|
+
if value == "pcf8574a"
|
75
|
+
base_path = File.dirname(label)
|
76
|
+
base_path = File.join(base_path, 'base')
|
77
|
+
base = File.read(base_path).strip
|
78
|
+
return base.to_i
|
91
79
|
end
|
92
|
-
rescue
|
93
|
-
puts "Unable to read version from /proc/version; using #{default_version} as default"
|
94
|
-
version = default_version
|
95
80
|
end
|
96
81
|
|
97
|
-
|
82
|
+
throw "Could not find XIO base"
|
98
83
|
end
|
99
84
|
|
100
85
|
def self.get_pins
|
101
|
-
v = chip_version
|
102
86
|
cis = [132, 133, 134, 135, 136, 137, 138, 139 ]
|
87
|
+
xio = []
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
when :v4_4
|
108
|
-
xio = [1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023]
|
109
|
-
end
|
110
|
-
|
89
|
+
xio_base = get_xio_base()
|
90
|
+
(0..7).each { |i| xio << (xio_base + i) }
|
91
|
+
|
111
92
|
pins = {}
|
112
93
|
|
113
94
|
cis.each_with_index { |gpio, index| pins["CSI#{index}".to_sym] = Pin::Pin.new(gpio) }
|