mono_matrix 0.0.3 → 1.0.0
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/.semver +2 -2
- data/README.md +6 -2
- data/bin/mono_matrix +5 -0
- data/lib/mono_matrix.rb +47 -46
- data/lib/mono_matrix/console.rb +13 -0
- data/mono_matrix.gemspec +4 -1
- data/spec/mock/serial_port.rb +0 -0
- data/spec/mono_matrix.rb +0 -0
- metadata +26 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ebd7171772c374bf391382184333397d0d94dae
|
4
|
+
data.tar.gz: 957c1fcddb1b74387115f350845dbb71eabc15b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962b6aa8aace3c5b6e3f598f6e0def48a55a3422af2eb074280e23294ca4926dcc0087a89be727968acee0d5b5ee10aa0afeafa0d3f6654a2f94e62b608f228c
|
7
|
+
data.tar.gz: 235a06482e0562cbf269d97a327625dc7f8e97a317212296267480f4379c990339df626be2ab0a39e92ead87839d630ecee3e23a5891a7840924a1165391bbba
|
data/.semver
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# mono_matrix
|
2
|
+
[](http://badge.fury.io/rb/mono_matrix)
|
2
3
|
|
3
|
-
A simple way to control your Monoprice HDX 4x2 Switcher/Splitter
|
4
|
+
A simple way to control your Monoprice HDX 4x2 Switcher/Splitter. Originally created for
|
5
|
+
https://github.com/defektive/hdx-api
|
6
|
+
|
7
|
+
[](https://codeclimate.com/github/defektive/mono_matrix)
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -20,7 +24,7 @@ $ gem install monoprice_matrix
|
|
20
24
|
|
21
25
|
```
|
22
26
|
|
23
|
-
matrix = MonoMatrix.new "/dev/ttyUSB0"
|
27
|
+
matrix = MonoMatrix::Switcher.new "/dev/ttyUSB0"
|
24
28
|
|
25
29
|
# set output A to use input 1
|
26
30
|
matrix.switch "A", 1
|
data/bin/mono_matrix
ADDED
data/lib/mono_matrix.rb
CHANGED
@@ -1,54 +1,55 @@
|
|
1
|
-
|
2
1
|
require 'serialport'
|
3
2
|
|
4
|
-
class MonoMatrix
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
@tty = tty
|
9
|
-
end
|
4
|
+
module MonoMatrix
|
5
|
+
class Switcher
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
7
|
+
def initialize(tty)
|
8
|
+
# Instance variables
|
9
|
+
@tty = tty
|
10
|
+
|
11
|
+
|
12
|
+
@end_bytes = ["\xD5","\x7B"]
|
13
|
+
@channels = {
|
14
|
+
"A" => [
|
15
|
+
["\x00", "\xFF"],
|
16
|
+
["\x01", "\xFE"],
|
17
|
+
["\x02", "\xFD"],
|
18
|
+
["\x03", "\xFC"]
|
19
|
+
],
|
20
|
+
|
21
|
+
"B" => [
|
22
|
+
["\x04", "\xFB"],
|
23
|
+
["\x05", "\xFA"],
|
24
|
+
["\x06", "\xF9"],
|
25
|
+
["\x07", "\xF8"]
|
26
|
+
]
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def switch(channel, input)
|
31
|
+
channel = channel.upcase
|
32
|
+
input = input.to_i - 1
|
33
|
+
|
34
|
+
# A = 1 "\x00\xFF\xD5\x7B";
|
35
|
+
# A = 2 "\x01\xFE\xD5\x7B";
|
36
|
+
# A = 3 "\x02\xFD\xD5\x7B";
|
37
|
+
# A = 4 "\x03\xFC\xD5\x7B";
|
38
|
+
# B = 1 "\x04\xFB\xD5\x7B";
|
39
|
+
# B = 2 "\x05\xFA\xD5\x7B";
|
40
|
+
# B = 3 "\x06\xF9\xD5\x7B";
|
41
|
+
# B = 4 "\x07\xF8\xD5\x7B";
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
bytes
|
43
|
-
|
44
|
-
bytes = ["\x07", "\xF8"] + end_bytes
|
43
|
+
|
44
|
+
bytes = @channels[channel][input] + @end_bytes if @channels[channel] && @channels[channel][input]
|
45
|
+
|
46
|
+
if bytes
|
47
|
+
puts channel +" to "+ input.to_s
|
48
|
+
serialConnection = SerialPort.new @tty, 9600
|
49
|
+
bytes.each {|byte| serialConnection.write byte}
|
50
|
+
bytes.each {|byte| serialConnection.write byte}
|
51
|
+
serialConnection.close
|
45
52
|
end
|
46
53
|
end
|
47
|
-
puts channel +" to "+ input.to_s
|
48
|
-
serialConnection = SerialPort.new @tty, 9600
|
49
|
-
bytes.each {|byte| serialConnection.write byte}
|
50
|
-
bytes.each {|byte| serialConnection.write byte}
|
51
|
-
serialConnection.close
|
52
54
|
end
|
53
|
-
|
54
|
-
end
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'mono_matrix'
|
3
|
+
|
4
|
+
module MonoMatrix
|
5
|
+
class Console < Thor
|
6
|
+
desc "example FILE", "an example task"
|
7
|
+
method_option :device, :aliases => "-d", :desc => "Set the serial device to use", :default => "/dev/ttyAMA0"
|
8
|
+
def switch(output, input)
|
9
|
+
m = MonoMatrix::Switcher.new options[:device]
|
10
|
+
m.switch output, input
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/mono_matrix.gemspec
CHANGED
@@ -6,7 +6,9 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = MonoMatrix::VERSION
|
7
7
|
s.date = '2014-11-26'
|
8
8
|
s.summary = "Control monoprice 4x2 swithcer/splitter via serial"
|
9
|
-
s.description = "A simple way to control your Monoprice 4x2 HDX***
|
9
|
+
s.description = "A simple way to control your Monoprice 4x2 HDX***
|
10
|
+
Created for use in https://github.com/defektive/hdx-api
|
11
|
+
"
|
10
12
|
s.authors = ["defektive"]
|
11
13
|
s.email = 'sirbradleyd@gmail.com'
|
12
14
|
s.homepage = 'http://rubygems.org/gems/mono_matrix'
|
@@ -18,6 +20,7 @@ Gem::Specification.new do |s|
|
|
18
20
|
s.require_paths = ["lib"]
|
19
21
|
|
20
22
|
s.add_runtime_dependency "serialport", '~> 1.3', '>= 1.3.1'
|
23
|
+
s.add_runtime_dependency "thor", '~> 0.19'
|
21
24
|
s.add_development_dependency "rake", '~>10.4'
|
22
25
|
s.add_development_dependency "semver2", '~>3.4'
|
23
26
|
s.add_development_dependency "rubygems-update", '~>2.4'
|
File without changes
|
data/spec/mono_matrix.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mono_matrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- defektive
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.3.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: thor
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.19'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.19'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: rake
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,9 +86,11 @@ dependencies:
|
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: '2.4'
|
75
|
-
description: A simple way to control your Monoprice 4x2 HDX
|
89
|
+
description: "A simple way to control your Monoprice 4x2 HDX***\n Created for use
|
90
|
+
in https://github.com/defektive/hdx-api\n "
|
76
91
|
email: sirbradleyd@gmail.com
|
77
|
-
executables:
|
92
|
+
executables:
|
93
|
+
- mono_matrix
|
78
94
|
extensions: []
|
79
95
|
extra_rdoc_files: []
|
80
96
|
files:
|
@@ -84,9 +100,13 @@ files:
|
|
84
100
|
- LICENSE.txt
|
85
101
|
- README.md
|
86
102
|
- Rakefile
|
103
|
+
- bin/mono_matrix
|
87
104
|
- lib/mono_matrix.rb
|
105
|
+
- lib/mono_matrix/console.rb
|
88
106
|
- lib/mono_matrix/version.rb
|
89
107
|
- mono_matrix.gemspec
|
108
|
+
- spec/mock/serial_port.rb
|
109
|
+
- spec/mono_matrix.rb
|
90
110
|
homepage: http://rubygems.org/gems/mono_matrix
|
91
111
|
licenses:
|
92
112
|
- MIT
|
@@ -111,4 +131,6 @@ rubygems_version: 2.2.2
|
|
111
131
|
signing_key:
|
112
132
|
specification_version: 4
|
113
133
|
summary: Control monoprice 4x2 swithcer/splitter via serial
|
114
|
-
test_files:
|
134
|
+
test_files:
|
135
|
+
- spec/mock/serial_port.rb
|
136
|
+
- spec/mono_matrix.rb
|