Skip to content

Commit

Permalink
[rotel] New channel to select FM/DAB/iRadio preset (openhab#13285)
Browse files Browse the repository at this point in the history
* [rotel] New channel to select FM/DAB/iRadio preset

For models RCX-1500, RDG-1520, RT-11, RT-1570, T11 and T14

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
lolodomo authored and andrasU committed Nov 12, 2022
1 parent b74b251 commit 0609245
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 118 deletions.
13 changes: 7 additions & 6 deletions bundles/org.openhab.binding.rotel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ The following channels are available:
| track | Current Track | Number | The current CD track number | |
| random | Random Mode | Switch | The current random mode | |
| repeat | Repeat Mode | String | The current repeat mode | TRACK, DISC, OFF |
| radioPreset | Radio Preset | Number | Select a radio preset | INCREASE, DECREASE, value between 1 and 30 |
| mainZone#line1 | Front Panel Line 1 | String | The first line displayed on the device front panel | |
| mainZone#line2 | Front Panel Line 2 | String | The second line displayed on the device front panel | |
| frequency, zone1#frequency, zone2#frequency, zone3#frequency, zone4#frequency | Current Frequency | Number | The current frequency (in kHz) for digital source input | |
Expand Down Expand Up @@ -198,9 +199,9 @@ Here are the list of channels available for each thing type:
| rc1590 | power, source, volume, mute, bass, treble, frequency, brightness, tcbypass, balance, otherCommand |
| rcd1570 | power, playControl, brightness |
| rcd1572 | power, playControl, track, random, repeat, brightness, otherCommand |
| rcx1500 | power, source, volume, mute, playControl |
| rcx1500 | power, source, volume, mute, playControl, radioPreset |
| rdd1580 | power, source, playControl, frequency, otherCommand |
| rdg1520 | power, source, playControl |
| rdg1520 | power, source, playControl, radioPreset |
| rsp1066 | mainZone#power, mainZone#source, mainZone#recordSource, mainZone#dsp, mainZone#volumeUpDown, mainZone#mute, mainZone#bass, mainZone#treble, mainZone#line1, mainZone#otherCommand, zone2#power, zone2#source, zone2#volumeUpDown |
| rsp1068 | mainZone#power, mainZone#source, mainZone#recordSource, mainZone#dsp, mainZone#volume, mainZone#mute, mainZone#bass, mainZone#treble, mainZone#line1, mainZone#line2, mainZone#otherCommand, zone2#power, zone2#source, zone2#volume, zone2#mute, zone3#power, zone3#source, zone3#volume, zone3#mute, zone4#power, zone4#source, zone4#volume, zone4#mute |
| rsp1069 | mainZone#power, mainZone#source, mainZone#recordSource, mainZone#dsp, mainZone#volume, mainZone#mute, mainZone#bass, mainZone#treble, mainZone#line1, mainZone#line2, mainZone#otherCommand, zone2#power, zone2#source, zone2#volume, zone2#mute, zone3#power, zone3#source, zone3#volume, zone3#mute, zone4#power, zone4#source, zone4#volume, zone4#mute |
Expand All @@ -219,11 +220,11 @@ Here are the list of channels available for each thing type:
| rsx1560 | mainZone#power, mainZone#source, mainZone#recordSource, mainZone#dsp, mainZone#volume, mainZone#mute, mainZone#bass, mainZone#treble, mainZone#line1, mainZone#line2, mainZone#otherCommand, zone2#power, zone2#source, zone2#volume, zone2#mute, zone3#power, zone3#source, zone3#volume, zone3#mute, zone4#power, zone4#source, zone4#volume, zone4#mute |
| rsx1562 | mainZone#power, mainZone#source, mainZone#recordSource, mainZone#dsp, mainZone#volume, mainZone#mute, mainZone#line1, mainZone#line2, mainZone#otherCommand, zone2#power, zone2#source, zone2#volume, zone2#mute, zone3#power, zone3#source, zone3#volume, zone3#mute, zone4#power, zone4#source, zone4#volume, zone4#mute |
| rt09 | power, source, playControl, brightness |
| rt11 | power, source, brightness |
| rt1570 | power, source, brightness |
| rt11 | power, source, radioPreset, brightness |
| rt1570 | power, source, radioPreset, brightness |
| s5 | power, brightness |
| t11 | power, source, brightness |
| t14 | power, source, brightness |
| t11 | power, source, radioPreset, brightness |
| t14 | power, source, radioPreset, brightness |
| x3 | power, source, volume, mute, bass, treble, frequency, brightness, tcbypass, balance, otherCommand |
| x5 | power, source, volume, mute, bass, treble, frequency, brightness, tcbypass, balance, otherCommand |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class RotelBindingConstants {
public static final String CHANNEL_RANDOM = "random";
public static final String CHANNEL_REPEAT = "repeat";
public static final String CHANNEL_FREQUENCY = "frequency";
public static final String CHANNEL_RADIO_PRESET = "radioPreset";
public static final String CHANNEL_LINE1 = "mainZone#line1";
public static final String CHANNEL_LINE2 = "mainZone#line2";
public static final String CHANNEL_BRIGHTNESS = "brightness";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ public enum RotelCommand {
RDS_PTY("RDS PTY", PRIMARY_CMD, (byte) 0x45),
RDS_TP("RDS TP", PRIMARY_CMD, (byte) 0x46),
RDS_TA("RDS TA", PRIMARY_CMD, (byte) 0x47),
FM_MONO_TOGGLE("FM Mono", PRIMARY_CMD, (byte) 0x26),
FM_MONO_TOGGLE("FM Mono", PRIMARY_CMD, (byte) 0x26, "fm_mono", null),
CALL_FM_PRESET("Recall FM Preset", "call_fm_preset_", "fm_"),
CALL_DAB_PRESET("Recall DAB Preset", "call_dab_preset_", "dab_"),
CALL_IRADIO_PRESET("Recall iRadio Preset", "call_iradio_preset_", null),
PRESET("Request current preset", "get_current_preset", null),
FM_PRESET("Request current FM preset number", null, "fm?"),
DAB_PRESET("Request current DAB preset number", null, "dab?"),
ZONE2_TUNE_UP("Zone 2 Tune Up", ZONE2_CMD, (byte) 0x28),
ZONE2_TUNE_DOWN("Zone 2 Tune Down", ZONE2_CMD, (byte) 0x29),
ZONE2_PRESET_UP("Zone 2 Preset Up", ZONE2_CMD, (byte) 0x6F),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public class RotelSimuConnector extends RotelConnector {
private int track = 1;
private boolean randomMode;
private RotelRepeatMode repeatMode = RotelRepeatMode.OFF;
private int fmPreset = 5;
private int dabPreset = 15;
private int iradioPreset = 25;
private boolean selectingRecord;
private int showZone;
private int dimmer;
Expand Down Expand Up @@ -834,6 +837,69 @@ public void buildFeedbackMessage(RotelCommand cmd, @Nullable Integer value) {
case REPEAT_MODE:
textAscii = buildRepeatModeAsciiResponse();
break;
case CALL_FM_PRESET:
if (value != null) {
fmPreset = value.intValue();
if (protocol == RotelProtocol.ASCII_V1) {
variableLength = true;
textAscii = buildAsciiResponse(String.format("%s%d", KEY_FM_PRESET, fmPreset),
"8,Radio FM");
} else {
accepted = false;
}
} else {
accepted = false;
}
break;
case CALL_DAB_PRESET:
if (value != null) {
dabPreset = value.intValue();
if (protocol == RotelProtocol.ASCII_V1) {
variableLength = true;
textAscii = buildAsciiResponse(String.format("%s%d", KEY_DAB_PRESET, dabPreset),
"9,Radio DAB");
} else {
accepted = false;
}
} else {
accepted = false;
}
break;
case CALL_IRADIO_PRESET:
if (value != null) {
iradioPreset = value.intValue();
variableLength = true;
textAscii = buildAsciiResponse(String.format("%s%d", KEY_IRADIO_PRESET, iradioPreset),
"12,Radio iRadio");
} else {
accepted = false;
}
break;
case PRESET:
if ("FM".equals(sources[0].getName())) {
textAscii = buildAsciiResponse(KEY_PRESET_FM, fmPreset);
} else if ("DAB".equals(sources[0].getName())) {
textAscii = buildAsciiResponse(KEY_PRESET_DAB, dabPreset);
} else if ("IRADIO".equals(sources[0].getName())) {
textAscii = buildAsciiResponse(KEY_PRESET_IRADIO, iradioPreset);
} else {
textAscii = buildAsciiResponse(KEY_PRESET_FM, 0);
}
break;
case FM_PRESET:
if ("FM".equals(sources[0].getName())) {
textAscii = buildAsciiResponse(KEY_FM, String.format("%02d", fmPreset));
} else {
textAscii = buildAsciiResponse(KEY_FM, "00");
}
break;
case DAB_PRESET:
if ("DAB".equals(sources[0].getName())) {
textAscii = buildAsciiResponse(KEY_DAB, String.format("%02d", dabPreset));
} else {
textAscii = buildAsciiResponse(KEY_DAB, "00");
}
break;
case SOURCE_MULTI_INPUT:
multiinput = !multiinput;
text = "MULTI IN " + (multiinput ? "ON" : "OFF");
Expand Down
Loading

0 comments on commit 0609245

Please sign in to comment.