Skip to content

Commit 3acaea0

Browse files
DSheirerDennis Sheirer
andauthored
#1821 Resolves issue with SDRPlay IF Gain auto/manual modes and slider adjustment. (#1822)
Co-authored-by: Dennis Sheirer <[email protected]>
1 parent be02393 commit 3acaea0

File tree

8 files changed

+56
-55
lines changed

8 files changed

+56
-55
lines changed

src/main/java/io/github/dsheirer/source/tuner/sdrplay/RspTunerEditor.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends Tu
5252
private JToggleButton mAgcButton;
5353
private JLabel mGainValueLabel;
5454
private LnaSlider mLNASlider;
55-
private GainReductionSlider mBasebandSlider;
55+
private IfGainSlider mIfGainSlider;
5656
private JButton mGainOverloadButton;
5757
private JPanel mGainPanel;
5858
private AtomicBoolean mGainOverloadAlert = new AtomicBoolean();
@@ -131,6 +131,8 @@ protected JToggleButton getAgcButton()
131131
save();
132132
}
133133

134+
getIfGainSlider().setEnabled(!getAgcButton().isSelected());
135+
134136
if(mAgcButton.isSelected())
135137
{
136138
getAgcButton().setText(AUTOMATIC);
@@ -198,12 +200,11 @@ else if(!alert && mGainOverloadAlert.compareAndSet(true, false))
198200
getGainOverloadButton().setForeground(getForeground());
199201
getGainOverloadButton().setBackground(getBackground());
200202
}
201-
else
202-
{
203-
mLog.info("Ignoring duplicate gain alerting - alert[" + alert + "] atomic [" + mGainOverloadAlert.get() + "]");
204-
}
205203
}
206204

205+
/**
206+
* Updates the LNA slider with the number of LNA states available for the current frequency.
207+
*/
207208
protected void updateLnaSlider()
208209
{
209210
if(hasTuner())
@@ -253,7 +254,7 @@ protected LnaSlider getLNASlider()
253254
private void updateGain()
254255
{
255256
int lna = getLNASlider().getLNA();
256-
int gr = getBasebandSlider().getGR();
257+
int gr = getIfGainSlider().getGR();
257258

258259
if(hasTuner() && !isLoading())
259260
{
@@ -266,7 +267,7 @@ private void updateGain()
266267
catch(Exception e)
267268
{
268269
mLog.error("Couldn't set RSP gain to LNA:" + lna + " Gain Reduction:" + gr, e);
269-
JOptionPane.showMessageDialog(mBasebandSlider, "Couldn't set RSP gain value to LNA:" + lna + " Gain Reduction:" + gr);
270+
JOptionPane.showMessageDialog(mIfGainSlider, "Couldn't set RSP gain value to LNA:" + lna + " Gain Reduction:" + gr);
270271
}
271272
}
272273
}
@@ -285,17 +286,17 @@ protected void updateGainLabel()
285286
}
286287

287288
/**
288-
* Baseband Gain Reduction Slider
289+
* IF Gain Slider
289290
*/
290-
protected GainReductionSlider getBasebandSlider()
291+
protected IfGainSlider getIfGainSlider()
291292
{
292-
if(mBasebandSlider == null)
293+
if(mIfGainSlider == null)
293294
{
294-
mBasebandSlider = new GainReductionSlider();
295-
mBasebandSlider.setEnabled(true);
296-
mBasebandSlider.setMajorTickSpacing(1);
297-
mBasebandSlider.setPaintTicks(true);
298-
mBasebandSlider.addChangeListener(event ->
295+
mIfGainSlider = new IfGainSlider();
296+
mIfGainSlider.setEnabled(true);
297+
mIfGainSlider.setMajorTickSpacing(1);
298+
mIfGainSlider.setPaintTicks(true);
299+
mIfGainSlider.addChangeListener(event ->
299300
{
300301
JSlider source = (JSlider)event.getSource();
301302

@@ -306,7 +307,7 @@ protected GainReductionSlider getBasebandSlider()
306307
});
307308
}
308309

309-
return mBasebandSlider;
310+
return mIfGainSlider;
310311
}
311312

312313
/**
@@ -342,14 +343,14 @@ public void setLNA(int lna)
342343
}
343344

344345
/**
345-
* JSlider implementation that inverts the scale to support Gain Reduction values.
346+
* JSlider implementation that inverts the scale to support IF Gain (aka Gain Reduction) values.
346347
*/
347-
public class GainReductionSlider extends JSlider
348+
public class IfGainSlider extends JSlider
348349
{
349350
/**
350351
* Constructs an instance
351352
*/
352-
public GainReductionSlider()
353+
public IfGainSlider()
353354
{
354355
super(JSlider.HORIZONTAL, 0, 39, 30);
355356
}
@@ -360,7 +361,7 @@ public GainReductionSlider()
360361
*/
361362
public int getGR()
362363
{
363-
return getBasebandSlider().getMaximum() - getBasebandSlider().getValue() + 20;
364+
return getIfGainSlider().getMaximum() - getIfGainSlider().getValue() + 20;
364365
}
365366

366367
/**

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rsp1/Rsp1TunerEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ private void init()
8282
add(getGainPanel(), "wrap");
8383
add(new JLabel("LNA:"));
8484
add(getLNASlider(), "wrap");
85-
add(new JLabel("Baseband:"));
86-
add(getBasebandSlider(), "wrap");
85+
add(new JLabel("IF:"));
86+
add(getIfGainSlider(), "wrap");
8787

8888
add(new JSeparator(), "span,growx,push");
8989
}
@@ -136,15 +136,15 @@ protected void tunerStatusUpdated()
136136
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
137137
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
138138
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
139-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
139+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
140140

141141
//Register to receive gain overload notifications
142142
getTunerController().getControlRsp().setGainOverloadListener(this);
143143
updateGainLabel();
144144
}
145145

146146
getLNASlider().setEnabled(hasTuner());
147-
getBasebandSlider().setEnabled(hasTuner());
147+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
148148
getGainValueLabel().setEnabled(hasTuner());
149149

150150
setLoading(false);
@@ -161,7 +161,7 @@ public void save()
161161
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
162162
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
163163
getConfiguration().setLNA(getLNASlider().getLNA());
164-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
164+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
165165
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
166166

167167
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rsp1a/Rsp1aTunerEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ private void init()
8686
add(getGainPanel(), "wrap");
8787
add(new JLabel("LNA:"));
8888
add(getLNASlider(), "wrap");
89-
add(new JLabel("Baseband:"));
90-
add(getBasebandSlider(), "wrap");
89+
add(new JLabel("IF:"));
90+
add(getIfGainSlider(), "wrap");
9191

9292
add(new JSeparator(), "span,growx,push");
9393

@@ -147,15 +147,15 @@ protected void tunerStatusUpdated()
147147
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
148148
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
149149
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
150-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
150+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
151151

152152
//Register to receive gain overload notifications
153153
getTunerController().getControlRsp().setGainOverloadListener(this);
154154
updateGainLabel();
155155
}
156156

157157
getLNASlider().setEnabled(hasTuner());
158-
getBasebandSlider().setEnabled(hasTuner());
158+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
159159
getGainValueLabel().setEnabled(hasTuner());
160160
getBiasTCheckBox().setEnabled(hasTuner());
161161

@@ -205,7 +205,7 @@ public void save()
205205
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
206206
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
207207
getConfiguration().setLNA(getLNASlider().getLNA());
208-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
208+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
209209
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
210210

211211
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rsp1b/Rsp1bTunerEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ private void init()
8686
add(getGainPanel(), "wrap");
8787
add(new JLabel("LNA:"));
8888
add(getLNASlider(), "wrap");
89-
add(new JLabel("Baseband:"));
90-
add(getBasebandSlider(), "wrap");
89+
add(new JLabel("IF:"));
90+
add(getIfGainSlider(), "wrap");
9191

9292
add(new JSeparator(), "span,growx,push");
9393

@@ -147,15 +147,15 @@ protected void tunerStatusUpdated()
147147
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
148148
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
149149
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
150-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
150+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
151151

152152
//Register to receive gain overload notifications
153153
getTunerController().getControlRsp().setGainOverloadListener(this);
154154
updateGainLabel();
155155
}
156156

157157
getLNASlider().setEnabled(hasTuner());
158-
getBasebandSlider().setEnabled(hasTuner());
158+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
159159
getGainValueLabel().setEnabled(hasTuner());
160160
getBiasTCheckBox().setEnabled(hasTuner());
161161
try
@@ -204,7 +204,7 @@ public void save()
204204
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
205205
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
206206
getConfiguration().setLNA(getLNASlider().getLNA());
207-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
207+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
208208
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
209209

210210
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rsp2/Rsp2TunerEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ private void init()
8888
add(getGainPanel(), "wrap");
8989
add(new JLabel("LNA:"));
9090
add(getLNASlider(), "wrap");
91-
add(new JLabel("Baseband:"));
92-
add(getBasebandSlider(), "wrap");
91+
add(new JLabel("IF:"));
92+
add(getIfGainSlider(), "wrap");
9393

9494
add(new JSeparator(), "span,growx,push");
9595

@@ -151,15 +151,15 @@ protected void tunerStatusUpdated()
151151
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
152152
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
153153
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
154-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
154+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
155155

156156
//Register to receive gain overload notifications
157157
getTunerController().getControlRsp().setGainOverloadListener(this);
158158
updateGainLabel();
159159
}
160160

161161
getLNASlider().setEnabled(hasTuner());
162-
getBasebandSlider().setEnabled(hasTuner());
162+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
163163
getGainValueLabel().setEnabled(hasTuner());
164164

165165
getBiasTCheckBox().setEnabled(hasTuner());
@@ -219,7 +219,7 @@ public void save()
219219
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
220220
getConfiguration().setAntennaSelection((Rsp2AntennaSelection)getAntennaSelectionCombo().getSelectedItem());
221221
getConfiguration().setLNA(getLNASlider().getLNA());
222-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
222+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
223223
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
224224

225225
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rspDuo/RspDuoTuner1Editor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ private void init()
9898
add(getGainPanel(), "wrap");
9999
add(new JLabel("LNA:"));
100100
add(getLNASlider(), "wrap");
101-
add(new JLabel("Baseband:"));
102-
add(getBasebandSlider(), "wrap");
101+
add(new JLabel("IF:"));
102+
add(getIfGainSlider(), "wrap");
103103

104104
add(new JSeparator(), "span,growx,push");
105105

@@ -168,15 +168,15 @@ protected void tunerStatusUpdated()
168168
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
169169
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
170170
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
171-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
171+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
172172

173173
//Register to receive gain overload notifications
174174
getTunerController().getControlRsp().setGainOverloadListener(this);
175175
updateGainLabel();
176176
}
177177

178178
getLNASlider().setEnabled(hasTuner());
179-
getBasebandSlider().setEnabled(hasTuner());
179+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
180180
getGainValueLabel().setEnabled(hasTuner());
181181

182182
getAmPortCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
@@ -249,7 +249,7 @@ public void save()
249249
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
250250
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
251251
getConfiguration().setLNA(getLNASlider().getLNA());
252-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
252+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
253253
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
254254

255255
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rspDuo/RspDuoTuner2Editor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ private void init()
9696
add(getGainPanel(), "wrap");
9797
add(new JLabel("LNA:"));
9898
add(getLNASlider(), "wrap");
99-
add(new JLabel("Baseband:"));
100-
add(getBasebandSlider(), "wrap");
99+
add(new JLabel("IF:"));
100+
add(getIfGainSlider(), "wrap");
101101

102102
add(new JSeparator(), "span,growx,push");
103103

@@ -185,15 +185,15 @@ protected void tunerStatusUpdated()
185185
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
186186
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
187187
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
188-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
188+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
189189

190190
//Register to receive gain overload notifications
191191
getTunerController().getControlRsp().setGainOverloadListener(this);
192192
updateGainLabel();
193193
}
194194

195195
getLNASlider().setEnabled(hasTuner());
196-
getBasebandSlider().setEnabled(hasTuner());
196+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
197197
getGainValueLabel().setEnabled(hasTuner());
198198

199199
getRfDabNotchCheckBox().setEnabled(hasTuner());
@@ -261,7 +261,7 @@ public void save()
261261
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
262262
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
263263
getConfiguration().setLNA(getLNASlider().getLNA());
264-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
264+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
265265
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
266266

267267
saveConfiguration();

src/main/java/io/github/dsheirer/source/tuner/sdrplay/rspDx/RspDxTunerEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ private void init()
9191
add(getGainPanel(), "wrap");
9292
add(new JLabel("LNA:"));
9393
add(getLNASlider(), "wrap");
94-
add(new JLabel("Baseband:"));
95-
add(getBasebandSlider(), "wrap");
94+
add(new JLabel("IF:"));
95+
add(getIfGainSlider(), "wrap");
9696

9797
add(new JSeparator(), "span,growx,push");
9898

@@ -160,15 +160,15 @@ protected void tunerStatusUpdated()
160160
getAgcButton().setSelected(current == null || current.equals(AgcMode.ENABLE));
161161
getAgcButton().setText((current == null || current.equals(AgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
162162
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
163-
getBasebandSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
163+
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
164164

165165
//Register to receive gain overload notifications
166166
getTunerController().getControlRsp().setGainOverloadListener(this);
167167
updateGainLabel();
168168
}
169169

170170
getLNASlider().setEnabled(hasTuner());
171-
getBasebandSlider().setEnabled(hasTuner());
171+
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
172172
getGainValueLabel().setEnabled(hasTuner());
173173

174174
getBiasTCheckBox().setEnabled(hasTuner());
@@ -240,7 +240,7 @@ public void save()
240240
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
241241
getConfiguration().setAntenna((RspDxAntenna) getAntennaCombo().getSelectedItem());
242242
getConfiguration().setLNA(getLNASlider().getLNA());
243-
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
243+
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
244244
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);
245245

246246
saveConfiguration();

0 commit comments

Comments
 (0)