Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1821 SDRPlay IF Gain Adjustment #1822

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends Tu
private JToggleButton mAgcButton;
private JLabel mGainValueLabel;
private LnaSlider mLNASlider;
private GainReductionSlider mBasebandSlider;
private IfGainSlider mIfGainSlider;
private JButton mGainOverloadButton;
private JPanel mGainPanel;
private AtomicBoolean mGainOverloadAlert = new AtomicBoolean();
Expand Down Expand Up @@ -131,6 +131,8 @@ protected JToggleButton getAgcButton()
save();
}

getIfGainSlider().setEnabled(!getAgcButton().isSelected());

if(mAgcButton.isSelected())
{
getAgcButton().setText(AUTOMATIC);
Expand Down Expand Up @@ -198,12 +200,11 @@ else if(!alert && mGainOverloadAlert.compareAndSet(true, false))
getGainOverloadButton().setForeground(getForeground());
getGainOverloadButton().setBackground(getBackground());
}
else
{
mLog.info("Ignoring duplicate gain alerting - alert[" + alert + "] atomic [" + mGainOverloadAlert.get() + "]");
}
}

/**
* Updates the LNA slider with the number of LNA states available for the current frequency.
*/
protected void updateLnaSlider()
{
if(hasTuner())
Expand Down Expand Up @@ -253,7 +254,7 @@ protected LnaSlider getLNASlider()
private void updateGain()
{
int lna = getLNASlider().getLNA();
int gr = getBasebandSlider().getGR();
int gr = getIfGainSlider().getGR();

if(hasTuner() && !isLoading())
{
Expand All @@ -266,7 +267,7 @@ private void updateGain()
catch(Exception e)
{
mLog.error("Couldn't set RSP gain to LNA:" + lna + " Gain Reduction:" + gr, e);
JOptionPane.showMessageDialog(mBasebandSlider, "Couldn't set RSP gain value to LNA:" + lna + " Gain Reduction:" + gr);
JOptionPane.showMessageDialog(mIfGainSlider, "Couldn't set RSP gain value to LNA:" + lna + " Gain Reduction:" + gr);
}
}
}
Expand All @@ -285,17 +286,17 @@ protected void updateGainLabel()
}

/**
* Baseband Gain Reduction Slider
* IF Gain Slider
*/
protected GainReductionSlider getBasebandSlider()
protected IfGainSlider getIfGainSlider()
{
if(mBasebandSlider == null)
if(mIfGainSlider == null)
{
mBasebandSlider = new GainReductionSlider();
mBasebandSlider.setEnabled(true);
mBasebandSlider.setMajorTickSpacing(1);
mBasebandSlider.setPaintTicks(true);
mBasebandSlider.addChangeListener(event ->
mIfGainSlider = new IfGainSlider();
mIfGainSlider.setEnabled(true);
mIfGainSlider.setMajorTickSpacing(1);
mIfGainSlider.setPaintTicks(true);
mIfGainSlider.addChangeListener(event ->
{
JSlider source = (JSlider)event.getSource();

Expand All @@ -306,7 +307,7 @@ protected GainReductionSlider getBasebandSlider()
});
}

return mBasebandSlider;
return mIfGainSlider;
}

/**
Expand Down Expand Up @@ -342,14 +343,14 @@ public void setLNA(int lna)
}

/**
* JSlider implementation that inverts the scale to support Gain Reduction values.
* JSlider implementation that inverts the scale to support IF Gain (aka Gain Reduction) values.
*/
public class GainReductionSlider extends JSlider
public class IfGainSlider extends JSlider
{
/**
* Constructs an instance
*/
public GainReductionSlider()
public IfGainSlider()
{
super(JSlider.HORIZONTAL, 0, 39, 30);
}
Expand All @@ -360,7 +361,7 @@ public GainReductionSlider()
*/
public int getGR()
{
return getBasebandSlider().getMaximum() - getBasebandSlider().getValue() + 20;
return getIfGainSlider().getMaximum() - getIfGainSlider().getValue() + 20;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());

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

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());
getBiasTCheckBox().setEnabled(hasTuner());

Expand Down Expand Up @@ -205,7 +205,7 @@ public void save()
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
getConfiguration().setLNA(getLNASlider().getLNA());
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());
getBiasTCheckBox().setEnabled(hasTuner());
try
Expand Down Expand Up @@ -204,7 +204,7 @@ public void save()
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
getConfiguration().setLNA(getLNASlider().getLNA());
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());

getBiasTCheckBox().setEnabled(hasTuner());
Expand Down Expand Up @@ -219,7 +219,7 @@ public void save()
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
getConfiguration().setAntennaSelection((Rsp2AntennaSelection)getAntennaSelectionCombo().getSelectedItem());
getConfiguration().setLNA(getLNASlider().getLNA());
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());

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

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());

getRfDabNotchCheckBox().setEnabled(hasTuner());
Expand Down Expand Up @@ -261,7 +261,7 @@ public void save()
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
getConfiguration().setLNA(getLNASlider().getLNA());
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);

saveConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ private void init()
add(getGainPanel(), "wrap");
add(new JLabel("LNA:"));
add(getLNASlider(), "wrap");
add(new JLabel("Baseband:"));
add(getBasebandSlider(), "wrap");
add(new JLabel("IF:"));
add(getIfGainSlider(), "wrap");

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

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

//Register to receive gain overload notifications
getTunerController().getControlRsp().setGainOverloadListener(this);
updateGainLabel();
}

getLNASlider().setEnabled(hasTuner());
getBasebandSlider().setEnabled(hasTuner());
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != AgcMode.ENABLE);
getGainValueLabel().setEnabled(hasTuner());

getBiasTCheckBox().setEnabled(hasTuner());
Expand Down Expand Up @@ -240,7 +240,7 @@ public void save()
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
getConfiguration().setAntenna((RspDxAntenna) getAntennaCombo().getSelectedItem());
getConfiguration().setLNA(getLNASlider().getLNA());
getConfiguration().setBasebandGainReduction(getBasebandSlider().getGR());
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
getConfiguration().setAgcMode(getAgcButton().isSelected() ? AgcMode.ENABLE : AgcMode.DISABLE);

saveConfiguration();
Expand Down
Loading