seriamp 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 630564090e5fbf436a4384d2aff86c3f51d8dcd60e69e82121730107dcb82deb
4
- data.tar.gz: 4dfffa50df36bf315fb476d472d9de125e01c670c823e1c881b66189e5a5351b
3
+ metadata.gz: 7afd42caaa8f0dd5815e908b40bfccd8ca042769fea3af431ae334b3d44aa140
4
+ data.tar.gz: af4041b6faf2f07ce204a15b99d4cc51b6f4bdfacc5c016006588d096513adef
5
5
  SHA512:
6
- metadata.gz: 2abd880200ab09af611fe31b31ca8299d189cf05f1448cc59773972f6c4e8929c120fdc533f2b7c246cde8a3621fbeeb6d562ef18f233b8b1ae63536708c2678
7
- data.tar.gz: f110bb9840aac1b485c8e12f42b34cbb0d4a578d9f6e3852591480b59f450715d08da33b166e3eb4381152139aef3e0b8e09a9fd2a65be31a41183cfd7b4fa70
6
+ metadata.gz: c09d03fe9b24e521eadffef9dc94305f61b90005e9719c349d9dba9ab7cb327a632352a62a3d2831f215374343147e3195fd958e01c4d750cce0a7ee4b7a8fda
7
+ data.tar.gz: a5a4f1b992fc6459ed7fa605daecc0715acb5e5938246b9915eb6af32415162b18650a6c45066602c22c27cf15f4879d91f63ab4b75eb05df82c02c0ee12760d
data/README.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Yamaha Receiver Serial Control Ruby Library
2
2
 
3
+ ## Hardware Requirements
4
+
5
+ I used USB to serial adapters with both Prolific PL2303 and FTDI chips.
6
+ Both chipsets work under Linux. The FTDI chipset appears to buffer the
7
+ incoming data - when reading from the device, it returns more than one
8
+ character at a time, whereas with the Prolific chipset only one character at
9
+ a time is returned. This means the FTDI chip can possibly offer faster
10
+ communication. Adapters based on the FTDI chip are also more expensive.
11
+
12
+ On Windows, FTDI provides drivers for at least Windows 7, however they
13
+ are not signed. Windows can be booted with the option to skip driver
14
+ signing enforcement, which makes the adapter work. I couldn't locate a
15
+ working Prolific driver for Windows 7.
16
+
17
+ These USB to serial adapters all have male connection on the RS232 end.
18
+ As such, no additional cable is needed if communicating with a receiver
19
+ that requires a straight cable and has a female terminal (such as the
20
+ Denon AVR-2308CI). For other receivers a gender changer or a cable is
21
+ necessary.
22
+
23
+ ### Sonance Sonamp 875D / 875D MK II
24
+
25
+ - 3-pin cable should be sufficient according to manual
26
+ - Null-modem cable required
27
+ - Receiver socket is female
28
+
29
+ ### Yamaha RX-V**00
30
+
31
+ - 5-pin cable required (with RTS pin connected)
32
+ - Null-modem cable required
33
+ - Receiver socket is male
34
+
35
+ ### Denon AVR-2308CI
36
+
37
+ - Straight cable required
38
+ - Receiver socket is female
39
+
40
+ ### Integra DTR
41
+
42
+ - Straight cable required
43
+
3
44
  ## Protocol Notes
4
45
 
5
46
  ### RX-V1500 Power Values
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Seriamp
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.6'
5
5
  end
@@ -42,6 +42,34 @@ module Seriamp
42
42
  empty_response
43
43
  end
44
44
 
45
+ post "/#{zone}/volume/up" do
46
+ client.public_send("#{zone}_volume_up")
47
+ client.public_send("#{zone}_volume_up")
48
+ plain_response client.main_volume_db
49
+ end
50
+
51
+ post "/#{zone}/volume/up/:step" do |step|
52
+ client.public_send("#{zone}_volume_up")
53
+ step.to_i.times do
54
+ client.public_send("#{zone}_volume_up")
55
+ end
56
+ plain_response client.main_volume_db
57
+ end
58
+
59
+ post "/#{zone}/volume/down" do
60
+ client.public_send("#{zone}_volume_down")
61
+ client.public_send("#{zone}_volume_down")
62
+ plain_response client.main_volume_db
63
+ end
64
+
65
+ post "/#{zone}/volume/down/:step" do |step|
66
+ client.public_send("#{zone}_volume_down")
67
+ step.to_i.times do
68
+ client.public_send("#{zone}_volume_down")
69
+ end
70
+ plain_response client.main_volume_db
71
+ end
72
+
45
73
  put "/#{zone}/input" do
46
74
  value = request.body.read
47
75
  client.public_send("set_#{zone}_input", value)
@@ -71,6 +99,11 @@ module Seriamp
71
99
  def empty_response
72
100
  render_json({})
73
101
  end
102
+
103
+ def plain_response(data)
104
+ headers['content-type'] = 'text/plain'
105
+ data.to_s
106
+ end
74
107
  end
75
108
  end
76
109
  end
@@ -79,6 +79,9 @@ module Seriamp
79
79
  end
80
80
  end
81
81
 
82
+ alias main_input_name input_name
83
+ alias last_main_input_name last_input_name
84
+
82
85
  %i(
83
86
  multi_ch_input effect pure_direct speaker_a speaker_b
84
87
  ).each do |meth|
@@ -74,36 +74,54 @@ module Seriamp
74
74
  when 'volume'
75
75
  which = args.shift
76
76
  if %w(main zone2 zone3).include?(which)
77
- prefix = "set_#{which}"
78
77
  value = args.shift
79
78
  else
80
- prefix = 'set_main'
81
79
  value = which
80
+ which = 'main'
82
81
  end
83
- if %w(. -).include?(value)
84
- method = "#{prefix}_mute"
85
- value = true
82
+ prefix = "set_#{which}"
83
+ if value.nil?
84
+ puts client.send("last_#{which}_volume_db")
85
+ return
86
+ end
87
+ value = value.downcase
88
+ if value == 'up'
89
+ # Just like with remote, the first volume up or down command
90
+ # doesn't do anything.
91
+ client.public_send("#{which}_volume_up")
92
+ client.public_send("#{which}_volume_up")
93
+ elsif value == 'down'
94
+ client.public_send("#{which}_volume_down")
95
+ client.public_send("#{which}_volume_down")
86
96
  else
87
- method = "#{prefix}_volume_db"
88
- if value[0] == ','
89
- value = value[1..]
97
+ if %w(. - mute).include?(value)
98
+ method = "#{prefix}_mute"
99
+ value = true
100
+ elsif value == 'unmute'
101
+ method = "#{prefix}_mute"
102
+ value = false
103
+ else
104
+ method = "#{prefix}_volume_db"
105
+ if value[0] == ','
106
+ value = value[1..]
107
+ end
108
+ value = Float(value)
90
109
  end
91
- value = Float(value)
110
+ client.public_send(method, value)
92
111
  end
93
- client.public_send(method, value)
94
- p client.get_main_volume_text
95
- p client.get_zone2_volume_text
96
- p client.get_zone3_volume_text
97
112
  when 'input'
98
113
  which = args.shift&.downcase
99
114
  if %w(main zone2 zone3).include?(which)
100
- method = "set_#{which}_input"
101
115
  input = args.shift
102
116
  else
103
- method = 'set_main_input'
104
117
  input = which
118
+ which = 'main'
119
+ end
120
+ if input.nil?
121
+ puts client.public_send("last_#{which}_input_name")
122
+ return
105
123
  end
106
- client.public_send(method, input)
124
+ client.public_send("set_#{which}_input", input)
107
125
  when 'program'
108
126
  value = args.shift.downcase
109
127
  client.set_program(value)
@@ -66,6 +66,14 @@ module Seriamp
66
66
  set_zone2_volume(value)
67
67
  end
68
68
 
69
+ def main_volume_up
70
+ remote_command('7A1A')
71
+ end
72
+
73
+ def main_volume_down
74
+ remote_command('7A1B')
75
+ end
76
+
69
77
  def zone2_volume_up
70
78
  remote_command('7ADA')
71
79
  end
data/seriamp.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "seriamp"
5
- spec.version = '0.1.4'
5
+ spec.version = '0.1.6'
6
6
  spec.authors = ['Oleg Pudeyev']
7
7
  spec.email = ['code@olegp.name']
8
8
  spec.summary = %q{Serial control for amplifiers & A/V receivers}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seriamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-30 00:00:00.000000000 Z
11
+ date: 2022-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport