seriamp 0.1.2
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 +7 -0
- data/.gitignore +3 -0
- data/LICENSE +23 -0
- data/README.md +75 -0
- data/bin/sonamp +10 -0
- data/bin/sonamp-web +31 -0
- data/bin/yamaha +12 -0
- data/bin/yamaha-web +31 -0
- data/lib/seriamp/backend/ffi.rb +109 -0
- data/lib/seriamp/backend/serial_port.rb +34 -0
- data/lib/seriamp/detect.rb +44 -0
- data/lib/seriamp/error.rb +10 -0
- data/lib/seriamp/sonamp/app.rb +62 -0
- data/lib/seriamp/sonamp/client.rb +314 -0
- data/lib/seriamp/sonamp/cmd.rb +102 -0
- data/lib/seriamp/sonamp.rb +4 -0
- data/lib/seriamp/utils.rb +17 -0
- data/lib/seriamp/version.rb +5 -0
- data/lib/seriamp/yamaha/app.rb +58 -0
- data/lib/seriamp/yamaha/client.rb +279 -0
- data/lib/seriamp/yamaha/cmd.rb +139 -0
- data/lib/seriamp/yamaha/protocol/constants.rb +183 -0
- data/lib/seriamp/yamaha/protocol/methods.rb +134 -0
- data/lib/seriamp/yamaha.rb +4 -0
- data/lib/seriamp.rb +5 -0
- data/seriamp.gemspec +17 -0
- metadata +73 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Seriamp
|
4
|
+
module Yamaha
|
5
|
+
module Protocol
|
6
|
+
module Methods
|
7
|
+
|
8
|
+
# Turns the receiver on or off.
|
9
|
+
#
|
10
|
+
# @param [ true | false ] state Desired power state.
|
11
|
+
def set_power(state)
|
12
|
+
remote_command("7A1#{state ? 'D' : 'E'}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Turns main zone power on or off.
|
16
|
+
#
|
17
|
+
# @param [ true | false ] state Desired power state.
|
18
|
+
def set_main_power(state)
|
19
|
+
remote_command("7E7#{state ? 'E' : 'F'}")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Turns zone 2 power on or off.
|
23
|
+
#
|
24
|
+
# @param [ true | false ] state Desired power state.
|
25
|
+
def set_zone2_power(state)
|
26
|
+
remote_command("7EB#{state ? 'A' : 'B'}")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Turns zone 3 power on or off.
|
30
|
+
#
|
31
|
+
# @param [ true | false ] state Desired power state.
|
32
|
+
def set_zone3_power(state)
|
33
|
+
remote_command("7AE#{state ? 'D' : 'E'}")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Sets main zone volume.
|
37
|
+
#
|
38
|
+
# @param [ Integer ] value The raw volume value.
|
39
|
+
def set_main_volume(value)
|
40
|
+
system_command("30#{'%02x' % value}")
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sets main zone volume.
|
44
|
+
#
|
45
|
+
# @param [ Float ] volume The volume in decibels.
|
46
|
+
def set_main_volume_db(volume)
|
47
|
+
value = Integer((volume + 80) * 2 + 39)
|
48
|
+
set_main_volume(value)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets zone 2 volume.
|
52
|
+
#
|
53
|
+
# @param [ Integer ] value The raw volume value.
|
54
|
+
def set_zone2_volume(value)
|
55
|
+
system_command("31#{'%02x' % value}")
|
56
|
+
end
|
57
|
+
|
58
|
+
# Sets zone 2 volume.
|
59
|
+
#
|
60
|
+
# @param [ Float ] volume The volume in decibels.
|
61
|
+
def set_zone2_volume_db(volume)
|
62
|
+
value = Integer(volume + 33 + 39)
|
63
|
+
set_zone2_volume(value)
|
64
|
+
end
|
65
|
+
|
66
|
+
def zone2_volume_up
|
67
|
+
remote_command('7ADA')
|
68
|
+
end
|
69
|
+
|
70
|
+
def zone2_volume_down
|
71
|
+
remote_command('7ADB')
|
72
|
+
end
|
73
|
+
|
74
|
+
# Sets zone 3 volume.
|
75
|
+
#
|
76
|
+
# @param [ Integer ] volume The raw volume value.
|
77
|
+
def set_zone3_volume(volume)
|
78
|
+
remote_command("234#{'%02x' % value}")
|
79
|
+
end
|
80
|
+
|
81
|
+
def zone3_volume_up
|
82
|
+
remote_command('7AFD')
|
83
|
+
end
|
84
|
+
|
85
|
+
def zone3_volume_down
|
86
|
+
remote_command('7AFE')
|
87
|
+
end
|
88
|
+
|
89
|
+
def set_subwoofer_level(level)
|
90
|
+
dispatch("#{STX}249#{'%02x' % level}#{ETX}")
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_main_volume_text
|
94
|
+
extract_text(system_command("2001"))[3...].strip
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_zone2_volume_text
|
98
|
+
extract_text(system_command("2002"))[3...].strip
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_zone3_volume_text
|
102
|
+
extract_text(system_command("2005"))[3...].strip
|
103
|
+
end
|
104
|
+
|
105
|
+
# Turns pure direct mode on or off.
|
106
|
+
#
|
107
|
+
# @param [ true | false ] state Desired state.
|
108
|
+
def set_pure_direct(state)
|
109
|
+
dispatch("#{STX}07E8#{state ? '0' : '2'}#{ETX}")
|
110
|
+
end
|
111
|
+
|
112
|
+
def set_program(value)
|
113
|
+
program_code = PROGRAM_SET.fetch(value.downcase.gsub(/[^a-z]/, '_'))
|
114
|
+
remote_command("7E#{program_code}")
|
115
|
+
end
|
116
|
+
|
117
|
+
def set_main_input(source)
|
118
|
+
source_code = MAIN_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
|
119
|
+
remote_command("7A#{source_code}")
|
120
|
+
end
|
121
|
+
|
122
|
+
def set_zone2_input(source)
|
123
|
+
source_code = ZONE2_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
|
124
|
+
remote_command("7A#{source_code}")
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_zone3_input(source)
|
128
|
+
source_code = ZONE3_INPUTS_SET.fetch(source.downcase.gsub(/[^a-z]/, '_'))
|
129
|
+
remote_command("7A#{source_code}")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/lib/seriamp.rb
ADDED
data/seriamp.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "seriamp"
|
5
|
+
spec.version = '0.1.2'
|
6
|
+
spec.authors = ['Oleg Pudeyev']
|
7
|
+
spec.email = ['code@olegp.name']
|
8
|
+
spec.summary = %q{Serial control for amplifiers & A/V receivers}
|
9
|
+
spec.description = %q{Library for controlling Yamaha A/V receivers and Sonance Sonamp amplifiers via the serial port}
|
10
|
+
spec.homepage = "https://github.com/p/seriamp"
|
11
|
+
spec.license = "BSD-2-Clause"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |path| path.start_with?('docs/') }
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seriamp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleg Pudeyev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Library for controlling Yamaha A/V receivers and Sonance Sonamp amplifiers
|
14
|
+
via the serial port
|
15
|
+
email:
|
16
|
+
- code@olegp.name
|
17
|
+
executables:
|
18
|
+
- sonamp
|
19
|
+
- sonamp-web
|
20
|
+
- yamaha
|
21
|
+
- yamaha-web
|
22
|
+
extensions: []
|
23
|
+
extra_rdoc_files: []
|
24
|
+
files:
|
25
|
+
- ".gitignore"
|
26
|
+
- LICENSE
|
27
|
+
- README.md
|
28
|
+
- bin/sonamp
|
29
|
+
- bin/sonamp-web
|
30
|
+
- bin/yamaha
|
31
|
+
- bin/yamaha-web
|
32
|
+
- lib/seriamp.rb
|
33
|
+
- lib/seriamp/backend/ffi.rb
|
34
|
+
- lib/seriamp/backend/serial_port.rb
|
35
|
+
- lib/seriamp/detect.rb
|
36
|
+
- lib/seriamp/error.rb
|
37
|
+
- lib/seriamp/sonamp.rb
|
38
|
+
- lib/seriamp/sonamp/app.rb
|
39
|
+
- lib/seriamp/sonamp/client.rb
|
40
|
+
- lib/seriamp/sonamp/cmd.rb
|
41
|
+
- lib/seriamp/utils.rb
|
42
|
+
- lib/seriamp/version.rb
|
43
|
+
- lib/seriamp/yamaha.rb
|
44
|
+
- lib/seriamp/yamaha/app.rb
|
45
|
+
- lib/seriamp/yamaha/client.rb
|
46
|
+
- lib/seriamp/yamaha/cmd.rb
|
47
|
+
- lib/seriamp/yamaha/protocol/constants.rb
|
48
|
+
- lib/seriamp/yamaha/protocol/methods.rb
|
49
|
+
- seriamp.gemspec
|
50
|
+
homepage: https://github.com/p/seriamp
|
51
|
+
licenses:
|
52
|
+
- BSD-2-Clause
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.3.15
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Serial control for amplifiers & A/V receivers
|
73
|
+
test_files: []
|