Skip to content

Commit

Permalink
Two new channels to enable/disable speaker A and speaker B
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Mar 15, 2024
1 parent b736b6b commit 4cdfcc4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public class RotelBindingConstants {
public static final String CHANNEL_MAIN_MUTE = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_MUTE;
public static final String CHANNEL_MAIN_BASS = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_BASS;
public static final String CHANNEL_MAIN_TREBLE = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_TREBLE;
public static final String CHANNEL_MAIN_SPEAKER_A = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_SPEAKER_A;
public static final String CHANNEL_MAIN_SPEAKER_B = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_SPEAKER_B;
public static final String CHANNEL_MAIN_OTHER_COMMAND = CHANNEL_GROUP_MAIN_ZONE + "#" + CHANNEL_OTHER_COMMAND;

public static final String CHANNEL_GROUP_ZONE1 = "zone1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public enum RotelCommand {
public static final List<RotelCommand> OTHER_CMDS_SET8 = List.of(ROOM_EQ_TOGGLE, SPEAKER_SETTING_TOGGLE,
RESET_FACTORY);
public static final List<RotelCommand> OTHER_CMDS_SET9 = List.of(RECORD_FONCTION_SELECT, TONE_CONTROL_SELECT,
ZONE_TOGGLE, SPEAKER_A_TOGGLE, SPEAKER_B_TOGGLE);
ZONE_TOGGLE);

public static final byte PRIMARY_COMMAND = (byte) 0x10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ public enum RotelFlagInfoType {
ZONE,
CENTER,
SURROUND_LEFT,
SURROUND_RIGHT
SURROUND_RIGHT,
AM,
FM,
SPEAKER_A,
SPEAKER_B
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public class RotelFlagsMapping {
RotelFlagInfoType.SURROUND_LEFT, new int[] { 5, 4 }, //
RotelFlagInfoType.SURROUND_RIGHT, new int[] { 5, 3 }));
public static final RotelFlagsMapping MAPPING6 = new RotelFlagsMapping(
Map.of(RotelFlagInfoType.ZONE, new int[] { 1, 1 }));
Map.of(RotelFlagInfoType.ZONE, new int[] { 1, 1 }, //
RotelFlagInfoType.SPEAKER_A, new int[] { 1, 3 }, //
RotelFlagInfoType.SPEAKER_B, new int[] { 1, 2 }, //
RotelFlagInfoType.FM, new int[] { 3, 5 }, //
RotelFlagInfoType.AM, new int[] { 4, 0 }));
public static final RotelFlagsMapping NO_MAPPING = new RotelFlagsMapping(Map.of());

private Map<RotelFlagInfoType, int @Nullable []> infos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,18 @@ public void buildFeedbackMessage(RotelCommand cmd, @Nullable Integer value) {
} catch (RotelException e) {
}
}
if (model.isInfoPresentInFlags(RotelFlagInfoType.SPEAKER_A)) {
try {
model.setInfoInFlags(RotelFlagInfoType.SPEAKER_A, flags, speakerA);
} catch (RotelException e) {
}
}
if (model.isInfoPresentInFlags(RotelFlagInfoType.SPEAKER_B)) {
try {
model.setInfoInFlags(RotelFlagInfoType.SPEAKER_B, flags, speakerB);
} catch (RotelException e) {
}
}
int size = 6 + model.getRespNbChars() + model.getRespNbFlags();
byte[] dataBuffer = new byte[size];
int idx = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
break;
case CHANNEL_SPEAKER_A:
case CHANNEL_MAIN_SPEAKER_A:
if (!isPowerOn()) {
success = false;
logger.debug("Command {} from channel {} ignored: device in standby", command, channel);
Expand All @@ -962,6 +963,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
break;
case CHANNEL_SPEAKER_B:
case CHANNEL_MAIN_SPEAKER_B:
if (!isPowerOn()) {
success = false;
logger.debug("Command {} from channel {} ignored: device in standby", command, channel);
Expand Down Expand Up @@ -1761,21 +1763,29 @@ public void onNewMessageEvent(EventObject event) {
speakerb = false;
updateChannelState(CHANNEL_SPEAKER_A);
updateChannelState(CHANNEL_SPEAKER_B);
updateChannelState(CHANNEL_MAIN_SPEAKER_A);
updateChannelState(CHANNEL_MAIN_SPEAKER_B);
} else if (MSG_VALUE_SPEAKER_B.equalsIgnoreCase(value)) {
speakera = false;
speakerb = true;
updateChannelState(CHANNEL_SPEAKER_A);
updateChannelState(CHANNEL_SPEAKER_B);
updateChannelState(CHANNEL_MAIN_SPEAKER_A);
updateChannelState(CHANNEL_MAIN_SPEAKER_B);
} else if (MSG_VALUE_SPEAKER_AB.equalsIgnoreCase(value)) {
speakera = true;
speakerb = true;
updateChannelState(CHANNEL_SPEAKER_A);
updateChannelState(CHANNEL_SPEAKER_B);
updateChannelState(CHANNEL_MAIN_SPEAKER_A);
updateChannelState(CHANNEL_MAIN_SPEAKER_B);
} else if (MSG_VALUE_OFF.equalsIgnoreCase(value)) {
speakera = false;
speakerb = false;
updateChannelState(CHANNEL_SPEAKER_A);
updateChannelState(CHANNEL_SPEAKER_B);
updateChannelState(CHANNEL_MAIN_SPEAKER_A);
updateChannelState(CHANNEL_MAIN_SPEAKER_B);
} else {
throw new RotelException("Invalid value");
}
Expand Down Expand Up @@ -1878,6 +1888,8 @@ private void handlePowerOff() {
updateChannelState(CHANNEL_MAIN_MUTE);
updateChannelState(CHANNEL_MAIN_BASS);
updateChannelState(CHANNEL_MAIN_TREBLE);
updateChannelState(CHANNEL_MAIN_SPEAKER_A);
updateChannelState(CHANNEL_MAIN_SPEAKER_B);

updateChannelState(CHANNEL_ALL_POWER);
updateChannelState(CHANNEL_ALL_BRIGHTNESS);
Expand Down Expand Up @@ -2509,11 +2521,13 @@ private void updateChannelState(String channel) {
}
break;
case CHANNEL_SPEAKER_A:
case CHANNEL_MAIN_SPEAKER_A:
if (isPowerOn()) {
state = OnOffType.from(speakera);
}
break;
case CHANNEL_SPEAKER_B:
case CHANNEL_MAIN_SPEAKER_B:
if (isPowerOn()) {
state = OnOffType.from(speakerb);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ protected void handleValidMessage(byte[] incomingMessage) {
// Ignore it
}
}
if (model.isInfoPresentInFlags(RotelFlagInfoType.SPEAKER_A)
&& model.isInfoPresentInFlags(RotelFlagInfoType.SPEAKER_B)) {
try {
String speakerValue = MSG_VALUE_OFF;
if (model.isInfoOnInFlags(RotelFlagInfoType.SPEAKER_A, flags)
&& model.isInfoOnInFlags(RotelFlagInfoType.SPEAKER_B, flags)) {
speakerValue = MSG_VALUE_SPEAKER_AB;
} else if (model.isInfoOnInFlags(RotelFlagInfoType.SPEAKER_A, flags)) {
speakerValue = MSG_VALUE_SPEAKER_A;
} else if (model.isInfoOnInFlags(RotelFlagInfoType.SPEAKER_B, flags)) {
speakerValue = MSG_VALUE_SPEAKER_B;
}
dispatchKeyValue(KEY_SPEAKER, speakerValue);
} catch (RotelException e1) {
// Ignore it
}
}
boolean checkMultiIn = false;
boolean checkSource = true;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
<channel id="mute" typeId="system.mute"/>
<channel id="bass" typeId="bass"/>
<channel id="treble" typeId="treble"/>
<channel id="speakera" typeId="speakera"/>
<channel id="speakerb" typeId="speakerb"/>
<channel id="line1" typeId="frontPanelLine"/>
<channel id="otherCommand" typeId="otherCommand"/>
</channels>
Expand Down

0 comments on commit 4cdfcc4

Please sign in to comment.