mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 02:57:35 -05:00
wip: #34 Updates the HackRF tuner editor and a few other tuner
config/editor items
This commit is contained in:
@@ -9,7 +9,9 @@ import source.tuner.airspy.AirspyTunerConfiguration;
|
|||||||
import source.tuner.airspy.AirspyTunerEditor;
|
import source.tuner.airspy.AirspyTunerEditor;
|
||||||
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
|
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
|
||||||
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
|
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
|
||||||
|
import source.tuner.hackrf.HackRFTuner;
|
||||||
import source.tuner.hackrf.HackRFTunerConfiguration;
|
import source.tuner.hackrf.HackRFTunerConfiguration;
|
||||||
|
import source.tuner.hackrf.HackRFTunerEditor;
|
||||||
import source.tuner.rtl.RTL2832Tuner;
|
import source.tuner.rtl.RTL2832Tuner;
|
||||||
import source.tuner.rtl.e4k.E4KTunerConfiguration;
|
import source.tuner.rtl.e4k.E4KTunerConfiguration;
|
||||||
import source.tuner.rtl.e4k.E4KTunerEditor;
|
import source.tuner.rtl.e4k.E4KTunerEditor;
|
||||||
@@ -62,7 +64,7 @@ public class TunerConfigurationFactory
|
|||||||
case FUNCUBE_DONGLE_PRO_PLUS:
|
case FUNCUBE_DONGLE_PRO_PLUS:
|
||||||
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
||||||
case HACKRF:
|
case HACKRF:
|
||||||
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
return new HackRFTunerEditor( model, (HackRFTuner)tuner );
|
||||||
case RAFAELMICRO_R820T:
|
case RAFAELMICRO_R820T:
|
||||||
return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
|
return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
package source.tuner.hackrf;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import source.tuner.hackrf.HackRFTunerController.Serial;
|
|
||||||
|
|
||||||
public class HackRFInformationPanel extends JPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( HackRFInformationPanel.class );
|
|
||||||
|
|
||||||
private HackRFTunerController mController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays HackRF firmware, serial number and part identifier
|
|
||||||
*/
|
|
||||||
public HackRFInformationPanel( HackRFTunerController controller )
|
|
||||||
{
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2",
|
|
||||||
"[right,grow][grow]",
|
|
||||||
"[][][][grow]" ) );
|
|
||||||
|
|
||||||
Serial serial = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serial = mController.getSerial();
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "couldn't read HackRF serial number", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( serial != null )
|
|
||||||
{
|
|
||||||
add( new JLabel( "Serial:" ) );
|
|
||||||
add( new JLabel( serial.getSerialNumber() ) );
|
|
||||||
add( new JLabel( "Part:" ) );
|
|
||||||
add( new JLabel( serial.getPartID() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
add( new JLabel( "Serial:" ) );
|
|
||||||
add( new JLabel( "Unknown" ) );
|
|
||||||
add( new JLabel( "Part:" ) );
|
|
||||||
add( new JLabel( "Unknown" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
String firmware = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
firmware = mController.getFirmwareVersion();
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "couldn't read HackRF firmware version", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
add( new JLabel( "Firmware:" ) );
|
|
||||||
|
|
||||||
if( firmware != null )
|
|
||||||
{
|
|
||||||
add( new JLabel( firmware ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
add( new JLabel( "Unknown" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,557 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.hackrf;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.awt.event.FocusListener;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ComboBoxModel;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.SpinnerModel;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import javax.usb.UsbException;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
|
|
||||||
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
|
||||||
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
|
||||||
|
|
||||||
public class HackRFTunerConfigurationPanel extends JPanel
|
|
||||||
{
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( HackRFTunerConfigurationPanel.class );
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
private HackRFTunerController mController;
|
|
||||||
private HackRFTunerConfiguration mSelectedConfig;
|
|
||||||
|
|
||||||
private JButton mNewConfiguration;
|
|
||||||
private JButton mDeleteConfiguration;
|
|
||||||
private JComboBox<HackRFTunerConfiguration> mComboConfigurations;
|
|
||||||
|
|
||||||
private JTextField mName;
|
|
||||||
|
|
||||||
private JSpinner mFrequencyCorrection;
|
|
||||||
private JToggleButton mAmplifier;
|
|
||||||
private JComboBox<HackRFLNAGain> mComboLNAGain;
|
|
||||||
private JComboBox<HackRFVGAGain> mComboVGAGain;
|
|
||||||
|
|
||||||
private JComboBox<HackRFSampleRate> mComboSampleRate;
|
|
||||||
|
|
||||||
public HackRFTunerConfigurationPanel( SettingsManager settingsManager,
|
|
||||||
HackRFTunerController controller )
|
|
||||||
{
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the gui components
|
|
||||||
*/
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[grow,right][grow]", "[][][][][][][grow]" ) );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner configuration selector
|
|
||||||
*/
|
|
||||||
mComboConfigurations = new JComboBox<HackRFTunerConfiguration>();
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
/* Determine which tuner configuration should be selected/displayed */
|
|
||||||
// TunerConfigurationAssignment savedConfig = null;
|
|
||||||
String serial = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serial = mController.getSerial().getSerialNumber();
|
|
||||||
}
|
|
||||||
catch ( UsbException e2 )
|
|
||||||
{
|
|
||||||
mLog.error( "couldn't read hackrf serial number", e2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// if( serial != null )
|
|
||||||
// {
|
|
||||||
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
|
|
||||||
// TunerType.HACKRF, serial );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if( savedConfig != null )
|
|
||||||
// {
|
|
||||||
// mSelectedConfig = getNamedConfiguration(
|
|
||||||
// savedConfig.getTunerConfigurationName() );
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* If we couldn't determine the saved/selected config, use the first one */
|
|
||||||
if( mSelectedConfig == null )
|
|
||||||
{
|
|
||||||
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
|
|
||||||
|
|
||||||
//Store this config as the default for this tuner at this address
|
|
||||||
|
|
||||||
// if( serial != null )
|
|
||||||
// {
|
|
||||||
// mSettingsManager
|
|
||||||
// .setSelectedTunerConfiguration( TunerType.HACKRF,
|
|
||||||
// serial, mSelectedConfig );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedItem( mSelectedConfig );
|
|
||||||
|
|
||||||
mComboConfigurations.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
HackRFTunerConfiguration selected =
|
|
||||||
(HackRFTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
update( selected );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add( new JLabel( "Config:" ) );
|
|
||||||
add( mComboConfigurations, "growx,push" );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner Configuration Name
|
|
||||||
*/
|
|
||||||
mName = new JTextField();
|
|
||||||
mName.setText( mSelectedConfig.getName() );
|
|
||||||
|
|
||||||
mName.addFocusListener( new FocusListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void focusLost( FocusEvent e )
|
|
||||||
{
|
|
||||||
mSelectedConfig.setName( mName.getText() );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void focusGained( FocusEvent e ) {}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Name:" ) );
|
|
||||||
add( mName, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frequency Correction
|
|
||||||
*/
|
|
||||||
SpinnerModel model =
|
|
||||||
new SpinnerNumberModel( 0.0, //initial value
|
|
||||||
-1000.0, //min
|
|
||||||
1000.0, //max
|
|
||||||
0.1 ); //step
|
|
||||||
|
|
||||||
mFrequencyCorrection = new JSpinner( model );
|
|
||||||
|
|
||||||
JSpinner.NumberEditor editor =
|
|
||||||
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
|
||||||
|
|
||||||
DecimalFormat format = editor.getFormat();
|
|
||||||
format.setMinimumFractionDigits( 1 );
|
|
||||||
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
|
||||||
|
|
||||||
mFrequencyCorrection.setValue( mSelectedConfig.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mFrequencyCorrection.addChangeListener( new ChangeListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged( ChangeEvent e )
|
|
||||||
{
|
|
||||||
final double value = ((SpinnerNumberModel)mFrequencyCorrection
|
|
||||||
.getModel()).getNumber().doubleValue();
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setFrequencyCorrection( value );
|
|
||||||
mSelectedConfig.setFrequencyCorrection( value );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"HackRF Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "HackRF Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value, e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Correction PPM:" ) );
|
|
||||||
add( mFrequencyCorrection, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample Rate
|
|
||||||
*/
|
|
||||||
mComboSampleRate = new JComboBox<>( HackRFSampleRate.values() );
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
HackRFSampleRate sampleRate =
|
|
||||||
(HackRFSampleRate)mComboSampleRate.getSelectedItem();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
mController.setSampleRate( sampleRate );
|
|
||||||
|
|
||||||
mSelectedConfig.setSampleRate( sampleRate );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e2 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"HackRF Tuner Controller - couldn't apply the sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "] " +
|
|
||||||
e2.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "HackRF Tuner Controller - couldn't apply sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "]", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
add( new JLabel( "Sample Rate:" ) );
|
|
||||||
add( mComboSampleRate, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gain Controls
|
|
||||||
*/
|
|
||||||
JPanel gainPanel = new JPanel();
|
|
||||||
gainPanel.setLayout( new MigLayout( "",
|
|
||||||
"[][right][grow,fill][right][grow,fill]", "[grow,fill]" ) );
|
|
||||||
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
|
|
||||||
|
|
||||||
/* Amplifier */
|
|
||||||
mAmplifier = new JToggleButton( "Amp" );
|
|
||||||
mAmplifier.setSelected( mSelectedConfig.getAmplifierEnabled() );
|
|
||||||
mAmplifier.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setAmplifierEnabled( mAmplifier.isSelected() );
|
|
||||||
mSelectedConfig.setAmplifierEnabled( mAmplifier.isSelected() );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
mLog.error( "couldn't enable/disable amplifier", e );
|
|
||||||
mAmplifier.setEnabled( !mAmplifier.isSelected() );
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"Couldn't change amplifier setting",
|
|
||||||
"Error changing amplifier setting",
|
|
||||||
JOptionPane.ERROR_MESSAGE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
gainPanel.add( mAmplifier );
|
|
||||||
|
|
||||||
/* LNA Gain Control */
|
|
||||||
mComboLNAGain = new JComboBox<HackRFLNAGain>( HackRFLNAGain.values() );
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboLNAGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HackRFLNAGain lnaGain =
|
|
||||||
(HackRFLNAGain)mComboLNAGain.getSelectedItem();
|
|
||||||
|
|
||||||
if ( lnaGain == null )
|
|
||||||
{
|
|
||||||
lnaGain = HackRFLNAGain.GAIN_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboLNAGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setLNAGain( lnaGain );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setLNAGain( lnaGain );
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"HackRF Tuner Controller - couldn't apply the LNA "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "HackRF Tuner Controller - couldn't apply LNA "
|
|
||||||
+ "gain setting - ", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboLNAGain.setToolTipText( "<html>LNA Gain. Adjust to set "
|
|
||||||
+ "the IF gain</html>" );
|
|
||||||
gainPanel.add( new JLabel( "LNA" ) );
|
|
||||||
gainPanel.add( mComboLNAGain );
|
|
||||||
|
|
||||||
/* VGA Gain Control */
|
|
||||||
mComboVGAGain = new JComboBox<HackRFVGAGain>( HackRFVGAGain.values() );
|
|
||||||
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
|
|
||||||
mComboVGAGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HackRFVGAGain vgaGain = (HackRFVGAGain)mComboVGAGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( vgaGain == null )
|
|
||||||
{
|
|
||||||
vgaGain = HackRFVGAGain.GAIN_4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboVGAGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setVGAGain( vgaGain );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setVGAGain( vgaGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"HackRF Tuner Controller - couldn't apply the VGA "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "HackRF Tuner Controller - couldn't apply VGA "
|
|
||||||
+ "gain setting", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboVGAGain.setToolTipText( "<html>VGA Gain. Adjust to set the "
|
|
||||||
+ "baseband gain</html>" );
|
|
||||||
gainPanel.add( new JLabel( "VGA" ) );
|
|
||||||
gainPanel.add( mComboVGAGain, "wrap" );
|
|
||||||
|
|
||||||
add( gainPanel, "span,growx" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new configuration
|
|
||||||
*/
|
|
||||||
mNewConfiguration = new JButton( "New" );
|
|
||||||
|
|
||||||
mNewConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
// TunerConfiguration config =
|
|
||||||
// mSettingsManager
|
|
||||||
// .addNewTunerConfiguration(
|
|
||||||
// TunerType.HACKRF,
|
|
||||||
// "New Configuration" );
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
// mComboConfigurations.setSelectedItem( config );
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mNewConfiguration, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the currently selected configuration
|
|
||||||
*/
|
|
||||||
mDeleteConfiguration = new JButton( "Delete" );
|
|
||||||
|
|
||||||
mDeleteConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
HackRFTunerConfiguration selected =
|
|
||||||
(HackRFTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
int n = JOptionPane.showConfirmDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"Are you sure you want to delete '"
|
|
||||||
+ selected.getName() + "'?",
|
|
||||||
"Are you sure?",
|
|
||||||
JOptionPane.YES_NO_OPTION );
|
|
||||||
|
|
||||||
if( n == JOptionPane.YES_OPTION )
|
|
||||||
{
|
|
||||||
// mSettingsManager
|
|
||||||
// .deleteTunerConfiguration( selected );
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedIndex( 0 );
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mDeleteConfiguration, "growx,push,wrap" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates gui controls with the values from the tuner configuration
|
|
||||||
* @param config - tuner configuration
|
|
||||||
*/
|
|
||||||
private void update( HackRFTunerConfiguration config )
|
|
||||||
{
|
|
||||||
mSelectedConfig = config;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.apply( config );
|
|
||||||
|
|
||||||
mName.setText( config.getName() );
|
|
||||||
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
|
|
||||||
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
|
|
||||||
// mSettingsManager.setSelectedTunerConfiguration(
|
|
||||||
// TunerType.HACKRF, mController.getSerial().getSerialNumber(), config );
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
HackRFTunerConfigurationPanel.this,
|
|
||||||
"HackRF Tuner Controller - couldn't "
|
|
||||||
+ "apply the tuner configuration settings - " +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "HackRF Tuner Controller - couldn't apply "
|
|
||||||
+ "config [" + config.getName() + "]", e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a combo box model for the tuner configuration combo component
|
|
||||||
* by assembling a list of the tuner configurations appropriate for this
|
|
||||||
* specific tuner
|
|
||||||
*/
|
|
||||||
private ComboBoxModel<HackRFTunerConfiguration> getModel()
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.HACKRF );
|
|
||||||
|
|
||||||
DefaultComboBoxModel<HackRFTunerConfiguration> model =
|
|
||||||
new DefaultComboBoxModel<HackRFTunerConfiguration>();
|
|
||||||
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// model.addElement( (HackRFTunerConfiguration)config );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a specific (named) tuner configuration
|
|
||||||
*/
|
|
||||||
private HackRFTunerConfiguration getNamedConfiguration( String name )
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.HACKRF );
|
|
||||||
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// if( config.getName().contentEquals( name ) )
|
|
||||||
// {
|
|
||||||
// return (HackRFTunerConfiguration)config;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves current tuner configuration settings
|
|
||||||
*/
|
|
||||||
private void save()
|
|
||||||
{
|
|
||||||
// mSettingsManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
464
src/source/tuner/hackrf/HackRFTunerEditor.java
Normal file
464
src/source/tuner/hackrf/HackRFTunerEditor.java
Normal file
@@ -0,0 +1,464 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* SDR Trunk
|
||||||
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
******************************************************************************/
|
||||||
|
package source.tuner.hackrf;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.SpinnerModel;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
import javax.usb.UsbException;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import source.SourceException;
|
||||||
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEditor;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent.Event;
|
||||||
|
import source.tuner.configuration.TunerConfigurationModel;
|
||||||
|
import source.tuner.hackrf.HackRFTunerController.BoardID;
|
||||||
|
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
|
||||||
|
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
||||||
|
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
||||||
|
import source.tuner.hackrf.HackRFTunerController.Serial;
|
||||||
|
|
||||||
|
public class HackRFTunerEditor extends TunerConfigurationEditor
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( HackRFTunerEditor.class );
|
||||||
|
|
||||||
|
private JTextField mConfigurationName;
|
||||||
|
private JButton mTunerInfo;
|
||||||
|
private JComboBox<HackRFSampleRate> mComboSampleRate;
|
||||||
|
private JSpinner mFrequencyCorrection;
|
||||||
|
private JToggleButton mAmplifier;
|
||||||
|
private JComboBox<HackRFLNAGain> mComboLNAGain;
|
||||||
|
private JComboBox<HackRFVGAGain> mComboVGAGain;
|
||||||
|
private boolean mLoading;
|
||||||
|
|
||||||
|
private HackRFTunerController mController;
|
||||||
|
|
||||||
|
public HackRFTunerEditor( TunerConfigurationModel tunerConfigurationModel, HackRFTuner tuner )
|
||||||
|
{
|
||||||
|
super( tunerConfigurationModel );
|
||||||
|
|
||||||
|
mController = tuner.getController();
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private HackRFTunerConfiguration getConfiguration()
|
||||||
|
{
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
return (HackRFTunerConfiguration)getItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]",
|
||||||
|
"[][][][][][][grow]" ) );
|
||||||
|
|
||||||
|
add( new JLabel( "HackRF Tuner Configuration" ), "span,align center" );
|
||||||
|
|
||||||
|
mConfigurationName = new JTextField();
|
||||||
|
mConfigurationName.setEnabled( false );
|
||||||
|
mConfigurationName.addFocusListener( new FocusListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void focusLost( FocusEvent e )
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void focusGained( FocusEvent e ) {}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "Name:" ) );
|
||||||
|
add( mConfigurationName, "span 2" );
|
||||||
|
|
||||||
|
mTunerInfo = new JButton( "Tuner Info" );
|
||||||
|
mTunerInfo.setEnabled( false );
|
||||||
|
mTunerInfo.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, getTunerInfo(),
|
||||||
|
"Tuner Info", JOptionPane.INFORMATION_MESSAGE );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mTunerInfo );
|
||||||
|
|
||||||
|
mComboSampleRate = new JComboBox<>( HackRFSampleRate.values() );
|
||||||
|
mComboSampleRate.setEnabled( false );
|
||||||
|
mComboSampleRate.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
HackRFSampleRate sampleRate =
|
||||||
|
(HackRFSampleRate)mComboSampleRate.getSelectedItem();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
mController.setSampleRate( sampleRate );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e2 )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, "HackRF Tuner Controller"
|
||||||
|
+ " - couldn't apply the sample rate setting [" + sampleRate.getLabel() +
|
||||||
|
"] " + e2.getLocalizedMessage() );
|
||||||
|
|
||||||
|
mLog.error( "HackRF Tuner Controller - couldn't apply sample rate setting [" +
|
||||||
|
sampleRate.getLabel() + "]", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( new JLabel( "Sample Rate:" ) );
|
||||||
|
add( mComboSampleRate );
|
||||||
|
|
||||||
|
SpinnerModel model = new SpinnerNumberModel( 0.0, //initial value
|
||||||
|
-1000.0, //min
|
||||||
|
1000.0, //max
|
||||||
|
0.1 ); //step
|
||||||
|
|
||||||
|
mFrequencyCorrection = new JSpinner( model );
|
||||||
|
mFrequencyCorrection.setEnabled( false );
|
||||||
|
JSpinner.NumberEditor editor = (JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
||||||
|
|
||||||
|
DecimalFormat format = editor.getFormat();
|
||||||
|
format.setMinimumFractionDigits( 1 );
|
||||||
|
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
||||||
|
|
||||||
|
mFrequencyCorrection.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
final double value = ((SpinnerNumberModel)mFrequencyCorrection
|
||||||
|
.getModel()).getNumber().doubleValue();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mController.setFrequencyCorrection( value );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( SourceException e1 )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, "HackRF Tuner Controller"
|
||||||
|
+ " - couldn't apply frequency correction value: " + value +
|
||||||
|
e1.getLocalizedMessage() );
|
||||||
|
|
||||||
|
mLog.error( "HackRF Tuner Controller - couldn't apply frequency correction "
|
||||||
|
+ "value: " + value, e1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "PPM:" ) );
|
||||||
|
add( mFrequencyCorrection );
|
||||||
|
|
||||||
|
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
|
||||||
|
add( new JLabel( "Gain" ) );
|
||||||
|
add( new JLabel( "" ), "span 2" ); //filler
|
||||||
|
|
||||||
|
mAmplifier = new JToggleButton( "Amplifier" );
|
||||||
|
mAmplifier.setEnabled( false );
|
||||||
|
mAmplifier.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mController.setAmplifierEnabled( mAmplifier.isSelected() );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
mLog.error( "couldn't enable/disable amplifier", e );
|
||||||
|
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, "Couldn't change amplifier setting",
|
||||||
|
"Error changing amplifier setting", JOptionPane.ERROR_MESSAGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mAmplifier );
|
||||||
|
|
||||||
|
mComboLNAGain = new JComboBox<HackRFLNAGain>( HackRFLNAGain.values() );
|
||||||
|
mComboLNAGain.setEnabled( false );
|
||||||
|
mComboLNAGain.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HackRFLNAGain lnaGain = (HackRFLNAGain)mComboLNAGain.getSelectedItem();
|
||||||
|
|
||||||
|
if ( lnaGain == null )
|
||||||
|
{
|
||||||
|
lnaGain = HackRFLNAGain.GAIN_0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mController.setLNAGain( lnaGain );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, "HackRF Tuner Controller"
|
||||||
|
+ " - couldn't apply the LNA gain setting - " + e.getLocalizedMessage() );
|
||||||
|
|
||||||
|
mLog.error( "HackRF Tuner Controller - couldn't apply LNA gain setting - ", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
mComboLNAGain.setToolTipText( "<html>LNA Gain. Adjust to set the IF gain</html>" );
|
||||||
|
add( new JLabel( "LNA:" ) );
|
||||||
|
add( mComboLNAGain );
|
||||||
|
|
||||||
|
mComboVGAGain = new JComboBox<HackRFVGAGain>( HackRFVGAGain.values() );
|
||||||
|
mComboVGAGain.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HackRFVGAGain vgaGain = (HackRFVGAGain)mComboVGAGain.getSelectedItem();
|
||||||
|
|
||||||
|
if( vgaGain == null )
|
||||||
|
{
|
||||||
|
vgaGain = HackRFVGAGain.GAIN_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
mController.setVGAGain( vgaGain );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( HackRFTunerEditor.this, "HackRF Tuner Controller"
|
||||||
|
+ " - couldn't apply the VGA gain setting - " + e.getLocalizedMessage() );
|
||||||
|
|
||||||
|
mLog.error( "HackRF Tuner Controller - couldn't apply VGA gain setting", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
mComboVGAGain.setToolTipText( "<html>VGA Gain. Adjust to set the baseband gain</html>" );
|
||||||
|
add( new JLabel( "VGA:" ) );
|
||||||
|
add( mComboVGAGain );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets each of the tuner configuration controls to the enabled argument state
|
||||||
|
*/
|
||||||
|
private void setControlsEnabled( boolean enabled )
|
||||||
|
{
|
||||||
|
if( mConfigurationName.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mConfigurationName.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mTunerInfo.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mTunerInfo.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mFrequencyCorrection.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mFrequencyCorrection.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboSampleRate.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboSampleRate.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mAmplifier.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mAmplifier.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboLNAGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboLNAGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboVGAGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboVGAGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTunerInfo()
|
||||||
|
{
|
||||||
|
BoardID board = BoardID.INVALID;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
board = mController.getBoardID();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
mLog.error( "couldn't read HackRF board identifier", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( "<html><h3>HackRF Tuner</h3>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Board: </b>" );
|
||||||
|
sb.append( board.getLabel() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
Serial serial = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
serial = mController.getSerial();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
mLog.error( "couldn't read HackRF serial number", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( serial != null )
|
||||||
|
{
|
||||||
|
sb.append( "<b>Serial: </b>" );
|
||||||
|
sb.append( serial.getSerialNumber() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Part: </b>" );
|
||||||
|
sb.append( serial.getPartID() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "<b>Serial: Unknown</b><br>" );
|
||||||
|
sb.append( "<b>Part: Unknown</b><br>" );
|
||||||
|
}
|
||||||
|
|
||||||
|
String firmware = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
firmware = mController.getFirmwareVersion();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
mLog.error( "couldn't read HackRF firmware version", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( firmware != null )
|
||||||
|
{
|
||||||
|
sb.append( "<b>Firmware: </b>" );
|
||||||
|
sb.append( firmware );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "<b>Firmware: Unknown</b><br>" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( TunerConfiguration tunerConfiguration )
|
||||||
|
{
|
||||||
|
super.setItem( tunerConfiguration );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
HackRFTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
|
//Toggle loading so that we don't fire a change event and schedule a settings file save
|
||||||
|
mLoading = true;
|
||||||
|
|
||||||
|
if( tunerConfiguration.isAssigned() )
|
||||||
|
{
|
||||||
|
setControlsEnabled( true );
|
||||||
|
|
||||||
|
mConfigurationName.setText( config.getName() );
|
||||||
|
mComboSampleRate.setSelectedItem( config.getSampleRate() );
|
||||||
|
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
||||||
|
mAmplifier.setSelected( config.getAmplifierEnabled() );
|
||||||
|
mComboLNAGain.setSelectedItem( config.getLNAGain() );
|
||||||
|
mComboVGAGain.setSelectedItem( config.getVGAGain() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( config.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
mLoading = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && !mLoading )
|
||||||
|
{
|
||||||
|
HackRFTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
|
config.setName( mConfigurationName.getText() );
|
||||||
|
|
||||||
|
double value = ((SpinnerNumberModel)mFrequencyCorrection
|
||||||
|
.getModel()).getNumber().doubleValue();
|
||||||
|
config.setFrequencyCorrection( value );
|
||||||
|
config.setSampleRate( (HackRFSampleRate)mComboSampleRate.getSelectedItem() );
|
||||||
|
config.setAmplifierEnabled( mAmplifier.isSelected() );
|
||||||
|
config.setLNAGain( (HackRFLNAGain)mComboLNAGain.getSelectedItem() );
|
||||||
|
config.setVGAGain( (HackRFVGAGain)mComboVGAGain.getSelectedItem() );
|
||||||
|
|
||||||
|
getTunerConfigurationModel().broadcast(
|
||||||
|
new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.hackrf;
|
|
||||||
|
|
||||||
import gui.control.JFrequencyControl;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.usb.UsbException;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
|
||||||
import source.tuner.hackrf.HackRFTunerController.BoardID;
|
|
||||||
|
|
||||||
import com.jidesoft.swing.JideTabbedPane;
|
|
||||||
|
|
||||||
public class HackRFTunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( HackRFTunerEditorPanel.class );
|
|
||||||
|
|
||||||
private JFrequencyControl mFrequencyControl;
|
|
||||||
|
|
||||||
private HackRFTuner mTuner;
|
|
||||||
private HackRFTunerController mController;
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
|
|
||||||
public HackRFTunerEditorPanel( HackRFTuner tuner,
|
|
||||||
SettingsManager resourceManager )
|
|
||||||
{
|
|
||||||
mTuner = tuner;
|
|
||||||
mController = mTuner.getController();
|
|
||||||
mSettingsManager = resourceManager;
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2",
|
|
||||||
"[right,grow][grow]",
|
|
||||||
"[][][][][][grow]" ) );
|
|
||||||
|
|
||||||
BoardID board = BoardID.INVALID;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
board = mTuner.getController().getBoardID();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
mLog.error( "couldn't read HackRF board identifier", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
add( new JLabel( board.getLabel() ), "span,align center" );
|
|
||||||
|
|
||||||
mFrequencyControl = new JFrequencyControl();
|
|
||||||
|
|
||||||
mFrequencyControl.addListener( this );
|
|
||||||
|
|
||||||
/* Add frequency control as frequency change listener. This creates a
|
|
||||||
* feedback loop, so the control does not rebroadcast the event */
|
|
||||||
mTuner.getController().addListener( mFrequencyControl );
|
|
||||||
|
|
||||||
mFrequencyControl.setFrequency( mController.getFrequency(), false );
|
|
||||||
|
|
||||||
add( mFrequencyControl, "span,align center" );
|
|
||||||
|
|
||||||
JideTabbedPane tabs = new JideTabbedPane();
|
|
||||||
tabs.setFont( this.getFont() );
|
|
||||||
tabs.setForeground( Color.BLACK );
|
|
||||||
|
|
||||||
add( tabs, "span,grow,push" );
|
|
||||||
|
|
||||||
tabs.add( "Config", new HackRFTunerConfigurationPanel(
|
|
||||||
mSettingsManager, mTuner.getController() ) );
|
|
||||||
|
|
||||||
tabs.add( "Info", new HackRFInformationPanel( mTuner.getController() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void frequencyChanged( FrequencyChangeEvent event )
|
|
||||||
{
|
|
||||||
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setFrequency( event.getValue().longValue() );
|
|
||||||
}
|
|
||||||
catch ( SourceException e )
|
|
||||||
{
|
|
||||||
mLog.error( "error setting frequency [" + event.getValue().longValue() + "]", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.rtl;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import source.tuner.rtl.RTL2832TunerController.Descriptor;
|
|
||||||
|
|
||||||
public class RTL2832InfoPanel extends JPanel
|
|
||||||
{
|
|
||||||
RTL2832TunerController mController;
|
|
||||||
|
|
||||||
public RTL2832InfoPanel( RTL2832TunerController controller )
|
|
||||||
{
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mController = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][][][grow]" ) );
|
|
||||||
|
|
||||||
Descriptor descriptor = mController.getDescriptor();
|
|
||||||
|
|
||||||
add( new JLabel( "RTL-2832 EEPROM Descriptor" ), "span,align center" );
|
|
||||||
|
|
||||||
if( descriptor == null )
|
|
||||||
{
|
|
||||||
add( new JLabel( "No descriptor" ), "wrap" ) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
add( new JLabel( "USB ID:" ) ) ;
|
|
||||||
add( new JLabel( descriptor.getVendorID() + ":" +
|
|
||||||
descriptor.getProductID() ), "wrap" ) ;
|
|
||||||
|
|
||||||
add( new JLabel( "Vendor:" ) ) ;
|
|
||||||
add( new JLabel( descriptor.getVendorLabel() ), "wrap" ) ;
|
|
||||||
|
|
||||||
add( new JLabel( "Product:" ) ) ;
|
|
||||||
add( new JLabel( descriptor.getProductLabel() ), "wrap" ) ;
|
|
||||||
|
|
||||||
add( new JLabel( "Serial:" ) ) ;
|
|
||||||
add( new JLabel( descriptor.getSerial() ), "wrap" ) ;
|
|
||||||
|
|
||||||
add( new JLabel( "IR Enabled:" ) ) ;
|
|
||||||
add( new JLabel( ( descriptor.irEnabled() ? "Yes" : "No" ) ), "wrap" ) ;
|
|
||||||
|
|
||||||
add( new JLabel( "Remote Wake:" ) ) ;
|
|
||||||
add( new JLabel( ( descriptor.remoteWakeupEnabled() ? "Yes" : "No" ) ), "wrap" ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.rtl;
|
|
||||||
|
|
||||||
public enum RTL2832TunerType
|
|
||||||
{
|
|
||||||
E4000,
|
|
||||||
FC0012,
|
|
||||||
FC0013,
|
|
||||||
R820T,
|
|
||||||
R828D,
|
|
||||||
UNKNOWN;
|
|
||||||
}
|
|
||||||
@@ -1,687 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.rtl.e4k;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.awt.event.FocusListener;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ComboBoxModel;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.SpinnerModel;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import javax.usb.UsbException;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.usb4java.LibUsbException;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.rtl.RTL2832TunerController.SampleRate;
|
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
|
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
|
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KLNAGain;
|
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KMixerGain;
|
|
||||||
|
|
||||||
public class E4KTunerConfigurationPanel extends JPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( E4KTunerConfigurationPanel.class );
|
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
private E4KTunerController mController;
|
|
||||||
private E4KTunerConfiguration mSelectedConfig;
|
|
||||||
|
|
||||||
private JButton mNewConfiguration;
|
|
||||||
private JButton mDeleteConfiguration;
|
|
||||||
private JComboBox<E4KTunerConfiguration> mComboConfigurations;
|
|
||||||
|
|
||||||
private JTextField mName;
|
|
||||||
|
|
||||||
private JSpinner mFrequencyCorrection;
|
|
||||||
private JSpinner mSampleRateCorrection;
|
|
||||||
private JComboBox<E4KGain> mComboMasterGain;
|
|
||||||
private JComboBox<E4KMixerGain> mComboMixerGain;
|
|
||||||
private JComboBox<E4KLNAGain> mComboLNAGain;
|
|
||||||
private JComboBox<E4KEnhanceGain> mComboEnhanceGain;
|
|
||||||
|
|
||||||
private JComboBox<SampleRate> mComboSampleRate;
|
|
||||||
|
|
||||||
public E4KTunerConfigurationPanel( SettingsManager settingsManager,
|
|
||||||
E4KTunerController controller )
|
|
||||||
{
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the gui components
|
|
||||||
*/
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[grow,right][grow]", "[][][][][][][grow]" ) );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner configuration selector
|
|
||||||
*/
|
|
||||||
mComboConfigurations = new JComboBox<E4KTunerConfiguration>();
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
/* Determine which tuner configuration should be selected/displayed */
|
|
||||||
// TunerConfigurationAssignment savedConfig = mSettingsManager
|
|
||||||
// .getSelectedTunerConfiguration(
|
|
||||||
// TunerType.ELONICS_E4000, mController.getUniqueID() );
|
|
||||||
//
|
|
||||||
// if( savedConfig != null )
|
|
||||||
// {
|
|
||||||
// mSelectedConfig = getNamedConfiguration(
|
|
||||||
// savedConfig.getTunerConfigurationName() );
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* If we couldn't determine the saved/selected config, use the first one */
|
|
||||||
if( mSelectedConfig == null )
|
|
||||||
{
|
|
||||||
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
|
|
||||||
|
|
||||||
//Store this config as the default for this tuner at this address
|
|
||||||
// mSettingsManager
|
|
||||||
// .setSelectedTunerConfiguration(
|
|
||||||
// TunerType.ELONICS_E4000,
|
|
||||||
// mController.getUniqueID(), mSelectedConfig );
|
|
||||||
}
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedItem( mSelectedConfig );
|
|
||||||
|
|
||||||
mComboConfigurations.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
E4KTunerConfiguration selected =
|
|
||||||
(E4KTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
update( selected );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add( new JLabel( "Config:" ) );
|
|
||||||
add( mComboConfigurations, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner Configuration Name
|
|
||||||
*/
|
|
||||||
add( new JLabel( "Name:" ) );
|
|
||||||
mName = new JTextField();
|
|
||||||
mName.setText( mSelectedConfig.getName() );
|
|
||||||
|
|
||||||
mName.addFocusListener( new FocusListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void focusLost( FocusEvent e )
|
|
||||||
{
|
|
||||||
/* Update the config name */
|
|
||||||
mSelectedConfig.setName( mName.getText() );
|
|
||||||
|
|
||||||
/* Reset this named config as the assigned config for this
|
|
||||||
* tuner */
|
|
||||||
// mSettingsManager
|
|
||||||
// .setSelectedTunerConfiguration(
|
|
||||||
// TunerType.ELONICS_E4000,
|
|
||||||
// mController.getUniqueID(), mSelectedConfig );
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void focusGained( FocusEvent e ) {}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mName, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frequency Correction
|
|
||||||
*/
|
|
||||||
SpinnerModel model =
|
|
||||||
new SpinnerNumberModel( 0.0, //initial value
|
|
||||||
-1000.0, //min
|
|
||||||
1000.0, //max
|
|
||||||
0.1 ); //step
|
|
||||||
|
|
||||||
mFrequencyCorrection = new JSpinner( model );
|
|
||||||
|
|
||||||
JSpinner.NumberEditor editor =
|
|
||||||
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
|
||||||
|
|
||||||
DecimalFormat format = editor.getFormat();
|
|
||||||
format.setMinimumFractionDigits( 1 );
|
|
||||||
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
|
||||||
|
|
||||||
mFrequencyCorrection.setValue( mSelectedConfig.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mFrequencyCorrection.addChangeListener( new ChangeListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged( ChangeEvent e )
|
|
||||||
{
|
|
||||||
final double value = ((SpinnerNumberModel)mFrequencyCorrection
|
|
||||||
.getModel()).getNumber().doubleValue();
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setFrequencyCorrection( value );
|
|
||||||
mSelectedConfig.setFrequencyCorrection( value );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value, e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Correction PPM:" ) );
|
|
||||||
add( mFrequencyCorrection, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample Rate
|
|
||||||
*/
|
|
||||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
SampleRate sampleRate =
|
|
||||||
(SampleRate)mComboSampleRate.getSelectedItem();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
mController.setSampleRate( sampleRate );
|
|
||||||
|
|
||||||
mSelectedConfig.setSampleRate( sampleRate );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( SourceException | LibUsbException eSampleRate )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply the sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "] " +
|
|
||||||
eSampleRate.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "]",
|
|
||||||
eSampleRate );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
add( new JLabel( "Sample Rate:" ) );
|
|
||||||
add( mComboSampleRate, "growx,push" );
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Sample Rate Correction
|
|
||||||
// */
|
|
||||||
// SpinnerModel sampleRateCorrectionModel =
|
|
||||||
// new SpinnerNumberModel( 0, //initial value
|
|
||||||
// -32768, //min
|
|
||||||
// 32767, //max
|
|
||||||
// 1 ); //step
|
|
||||||
//
|
|
||||||
// mSampleRateCorrection = new JSpinner( sampleRateCorrectionModel );
|
|
||||||
//
|
|
||||||
// JSpinner.NumberEditor sampleRateCorrectionEditor =
|
|
||||||
// (JSpinner.NumberEditor)mSampleRateCorrection.getEditor();
|
|
||||||
//
|
|
||||||
// DecimalFormat sampleRateCorrectionFormat =
|
|
||||||
// sampleRateCorrectionEditor.getFormat();
|
|
||||||
//
|
|
||||||
// sampleRateCorrectionFormat.setMinimumFractionDigits( 0 );
|
|
||||||
//
|
|
||||||
// sampleRateCorrectionEditor.getTextField()
|
|
||||||
// .setHorizontalAlignment( SwingConstants.CENTER );
|
|
||||||
//
|
|
||||||
// mSampleRateCorrection.addChangeListener( new ChangeListener()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void stateChanged( ChangeEvent e )
|
|
||||||
// {
|
|
||||||
// final int value = ((SpinnerNumberModel)mSampleRateCorrection
|
|
||||||
// .getModel()).getNumber().intValue();
|
|
||||||
//
|
|
||||||
// EventQueue.invokeLater( new Runnable()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void run()
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// mController.setSampleRateFrequencyCorrection( value );
|
|
||||||
// }
|
|
||||||
// catch ( SourceException | UsbException e1 )
|
|
||||||
// {
|
|
||||||
// JOptionPane.showMessageDialog(
|
|
||||||
// E4KTunerConfigurationPanel.this,
|
|
||||||
// "E4K Tuner Controller - couldn't apply "
|
|
||||||
// + "sample rate correction value: " + value +
|
|
||||||
// e1.getLocalizedMessage() );
|
|
||||||
//
|
|
||||||
// Log.error( "E4K Tuner Controller - couldn't apply "
|
|
||||||
// + "sample rate correction value: " + value +
|
|
||||||
// e1.getLocalizedMessage() );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } );
|
|
||||||
// }
|
|
||||||
// } );
|
|
||||||
//
|
|
||||||
// add( mSampleRateCorrection );
|
|
||||||
// add( new JLabel( "Sample Rate Correction (ppm)" ), "wrap" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gain Controls
|
|
||||||
*/
|
|
||||||
JPanel gainPanel = new JPanel();
|
|
||||||
gainPanel.setLayout( new MigLayout( "fill", "[right][left][right][left]", "" ) );
|
|
||||||
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
|
|
||||||
|
|
||||||
/* Master Gain Control */
|
|
||||||
mComboMasterGain = new JComboBox<E4KGain>( E4KGain.values() );
|
|
||||||
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
|
|
||||||
|
|
||||||
mComboMasterGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
E4KGain gain = (E4KGain)mComboMasterGain.getSelectedItem();
|
|
||||||
|
|
||||||
mController.setGain( (E4KGain)mComboMasterGain.getSelectedItem(), true );
|
|
||||||
|
|
||||||
if( gain == E4KGain.MANUAL )
|
|
||||||
{
|
|
||||||
mComboMixerGain.setSelectedItem(
|
|
||||||
mController.getMixerGain( true ) );
|
|
||||||
mComboMixerGain.setEnabled( true );
|
|
||||||
|
|
||||||
mComboLNAGain.setSelectedItem(
|
|
||||||
mController.getLNAGain( true ) );
|
|
||||||
mComboLNAGain.setEnabled( true );
|
|
||||||
|
|
||||||
mComboEnhanceGain.setEnabled( true );
|
|
||||||
mComboEnhanceGain.setSelectedItem(
|
|
||||||
mController.getEnhanceGain( true ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mComboMixerGain.setEnabled( false );
|
|
||||||
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
|
|
||||||
|
|
||||||
mComboLNAGain.setEnabled( false );
|
|
||||||
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
|
|
||||||
|
|
||||||
mComboEnhanceGain.setEnabled( false );
|
|
||||||
mComboEnhanceGain.setSelectedItem( gain.getEnhanceGain() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setMasterGain( gain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply the gain "
|
|
||||||
+ "setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply "
|
|
||||||
+ "gain setting", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboMasterGain.setToolTipText( "<html>Select <b>AUTOMATIC</b> for auto "
|
|
||||||
+ "gain, <b>MANUAL</b> to enable<br> independent control of "
|
|
||||||
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
|
|
||||||
+ "settings, or one of the individual gain settings for<br>"
|
|
||||||
+ "semi-manual gain control</html>" );
|
|
||||||
gainPanel.add( new JLabel( "Master" ) );
|
|
||||||
gainPanel.add( mComboMasterGain );
|
|
||||||
|
|
||||||
/* Mixer Gain Control */
|
|
||||||
mComboMixerGain = new JComboBox<E4KMixerGain>( E4KMixerGain.values() );
|
|
||||||
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
|
|
||||||
mComboMixerGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
E4KMixerGain mixerGain =
|
|
||||||
(E4KMixerGain)mComboMixerGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( mComboMixerGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setMixerGain( mixerGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setMixerGain( mixerGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply the mixer "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply mixer "
|
|
||||||
+ "gain setting", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
|
||||||
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
|
||||||
mComboMixerGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "Mixer" ) );
|
|
||||||
gainPanel.add( mComboMixerGain, "wrap" );
|
|
||||||
|
|
||||||
/* LNA Gain Control */
|
|
||||||
mComboLNAGain = new JComboBox<E4KLNAGain>( E4KLNAGain.values() );
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboLNAGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
E4KLNAGain lnaGain = (E4KLNAGain)mComboLNAGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( mComboLNAGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setLNAGain( lnaGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setLNAGain( lnaGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply the LNA "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply LNA "
|
|
||||||
+ "gain setting - ", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
|
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
|
||||||
mComboLNAGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "LNA" ) );
|
|
||||||
gainPanel.add( mComboLNAGain );
|
|
||||||
|
|
||||||
/* Enhance Gain Control */
|
|
||||||
mComboEnhanceGain = new JComboBox<E4KEnhanceGain>( E4KEnhanceGain.values() );
|
|
||||||
mComboEnhanceGain.setSelectedItem( mSelectedConfig.getEnhanceGain() );
|
|
||||||
mComboEnhanceGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
E4KEnhanceGain enhanceGain =
|
|
||||||
(E4KEnhanceGain)mComboEnhanceGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( mComboEnhanceGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setEnhanceGain( enhanceGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setEnhanceGain( enhanceGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't apply the enhance "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply enhance "
|
|
||||||
+ "gain setting", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboEnhanceGain.setToolTipText( "<html>Enhance Gain. Set master gain "
|
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
|
||||||
mComboEnhanceGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "Enhance" ) );
|
|
||||||
gainPanel.add( mComboEnhanceGain, "wrap" );
|
|
||||||
|
|
||||||
add( gainPanel, "span,grow,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new configuration
|
|
||||||
*/
|
|
||||||
mNewConfiguration = new JButton( "New" );
|
|
||||||
|
|
||||||
mNewConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
// TunerConfiguration config =
|
|
||||||
// mSettingsManager
|
|
||||||
// .addNewTunerConfiguration(
|
|
||||||
// TunerType.ELONICS_E4000,
|
|
||||||
// "New Configuration" );
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
// mComboConfigurations.setSelectedItem( config );
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mNewConfiguration, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the currently selected configuration
|
|
||||||
*/
|
|
||||||
mDeleteConfiguration = new JButton( "Delete" );
|
|
||||||
|
|
||||||
mDeleteConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
E4KTunerConfiguration selected =
|
|
||||||
(E4KTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
int n = JOptionPane.showConfirmDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"Are you sure you want to delete '"
|
|
||||||
+ selected.getName() + "'?",
|
|
||||||
"Are you sure?",
|
|
||||||
JOptionPane.YES_NO_OPTION );
|
|
||||||
|
|
||||||
if( n == JOptionPane.YES_OPTION )
|
|
||||||
{
|
|
||||||
// mSettingsManager
|
|
||||||
// .deleteTunerConfiguration( selected );
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedIndex( 0 );
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mDeleteConfiguration, "growx,push,wrap" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates gui controls with the values from the tuner configuration
|
|
||||||
* @param config - tuner configuration
|
|
||||||
*/
|
|
||||||
private void update( E4KTunerConfiguration config )
|
|
||||||
{
|
|
||||||
mSelectedConfig = config;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.apply( config );
|
|
||||||
|
|
||||||
mName.setText( config.getName() );
|
|
||||||
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboEnhanceGain.setSelectedItem( mSelectedConfig.getEnhanceGain() );
|
|
||||||
|
|
||||||
/* Apply master gain last so that the Mixer, LNA, and Enhance gain
|
|
||||||
* settings are updated with the master setting where necessary */
|
|
||||||
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
|
|
||||||
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
|
|
||||||
// mSettingsManager.setSelectedTunerConfiguration(
|
|
||||||
// TunerType.ELONICS_E4000, mController.getUniqueID(), config );
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
E4KTunerConfigurationPanel.this,
|
|
||||||
"E4K Tuner Controller - couldn't "
|
|
||||||
+ "apply the tuner configuration settings - " +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "E4K Tuner Controller - couldn't apply "
|
|
||||||
+ "config [" + config.getName() + "]", e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a combo box model for the tuner configuration combo component
|
|
||||||
* by assembling a list of the tuner configurations appropriate for this
|
|
||||||
* specific tuner
|
|
||||||
*/
|
|
||||||
private ComboBoxModel<E4KTunerConfiguration> getModel()
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
|
|
||||||
|
|
||||||
DefaultComboBoxModel<E4KTunerConfiguration> model =
|
|
||||||
new DefaultComboBoxModel<E4KTunerConfiguration>();
|
|
||||||
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// model.addElement( (E4KTunerConfiguration)config );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a specific (named) tuner configuration
|
|
||||||
*/
|
|
||||||
private E4KTunerConfiguration getNamedConfiguration( String name )
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
|
|
||||||
//
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// if( config.getName().contentEquals( name ) )
|
|
||||||
// {
|
|
||||||
// return (E4KTunerConfiguration)config;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves current tuner configuration settings
|
|
||||||
*/
|
|
||||||
private void save()
|
|
||||||
{
|
|
||||||
// mSettingsManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,6 +27,7 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SpinnerModel;
|
import javax.swing.SpinnerModel;
|
||||||
@@ -131,6 +132,7 @@ public class E4KTunerEditor extends TunerConfigurationEditor
|
|||||||
add( mTunerInfo );
|
add( mTunerInfo );
|
||||||
|
|
||||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
||||||
|
mComboSampleRate.setEnabled( false );
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
mComboSampleRate.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -199,6 +201,9 @@ public class E4KTunerEditor extends TunerConfigurationEditor
|
|||||||
add( new JLabel( "PPM:" ) );
|
add( new JLabel( "PPM:" ) );
|
||||||
add( mFrequencyCorrection );
|
add( mFrequencyCorrection );
|
||||||
|
|
||||||
|
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
|
||||||
|
add( new JLabel( "Gain" ), "wrap" );
|
||||||
|
|
||||||
mComboMasterGain = new JComboBox<E4KGain>( E4KGain.values() );
|
mComboMasterGain = new JComboBox<E4KGain>( E4KGain.values() );
|
||||||
mComboMasterGain.setEnabled( false );
|
mComboMasterGain.setEnabled( false );
|
||||||
mComboMasterGain.addActionListener( new ActionListener()
|
mComboMasterGain.addActionListener( new ActionListener()
|
||||||
@@ -252,7 +257,7 @@ public class E4KTunerEditor extends TunerConfigurationEditor
|
|||||||
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
|
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
|
||||||
+ "settings, or one of the individual gain settings for<br>"
|
+ "settings, or one of the individual gain settings for<br>"
|
||||||
+ "semi-manual gain control</html>" );
|
+ "semi-manual gain control</html>" );
|
||||||
add( new JLabel( "Master" ) );
|
add( new JLabel( "Master:" ) );
|
||||||
add( mComboMasterGain );
|
add( mComboMasterGain );
|
||||||
|
|
||||||
mComboMixerGain = new JComboBox<E4KMixerGain>( E4KMixerGain.values() );
|
mComboMixerGain = new JComboBox<E4KMixerGain>( E4KMixerGain.values() );
|
||||||
@@ -279,7 +284,7 @@ public class E4KTunerEditor extends TunerConfigurationEditor
|
|||||||
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
||||||
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
||||||
mComboMixerGain.setEnabled( false );
|
mComboMixerGain.setEnabled( false );
|
||||||
add( new JLabel( "Mixer" ) );
|
add( new JLabel( "Mixer:" ) );
|
||||||
add( mComboMixerGain );
|
add( mComboMixerGain );
|
||||||
|
|
||||||
mComboLNAGain = new JComboBox<E4KLNAGain>( E4KLNAGain.values() );
|
mComboLNAGain = new JComboBox<E4KLNAGain>( E4KLNAGain.values() );
|
||||||
|
|||||||
@@ -1,695 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package source.tuner.rtl.r820t;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.awt.event.FocusListener;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ComboBoxModel;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.SpinnerModel;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import javax.usb.UsbException;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.usb4java.LibUsbException;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.rtl.RTL2832TunerController.SampleRate;
|
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
|
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
|
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
|
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
|
|
||||||
|
|
||||||
public class R820TTunerConfigurationEditorOld extends JPanel
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( R820TTunerConfigurationEditorOld.class );
|
|
||||||
|
|
||||||
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
|
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
private R820TTunerController mController;
|
|
||||||
private R820TTunerConfiguration mSelectedConfig;
|
|
||||||
|
|
||||||
private JButton mNewConfiguration;
|
|
||||||
private JButton mDeleteConfiguration;
|
|
||||||
private JComboBox<R820TTunerConfiguration> mComboConfigurations;
|
|
||||||
|
|
||||||
private JTextField mName;
|
|
||||||
|
|
||||||
private JSpinner mFrequencyCorrection;
|
|
||||||
private JSpinner mSampleRateCorrection;
|
|
||||||
private JComboBox<R820TGain> mComboMasterGain;
|
|
||||||
private JComboBox<R820TMixerGain> mComboMixerGain;
|
|
||||||
private JComboBox<R820TLNAGain> mComboLNAGain;
|
|
||||||
private JComboBox<R820TVGAGain> mComboVGAGain;
|
|
||||||
|
|
||||||
private JComboBox<SampleRate> mComboSampleRate;
|
|
||||||
|
|
||||||
public R820TTunerConfigurationEditorOld( SettingsManager settingsManager,
|
|
||||||
R820TTunerController controller )
|
|
||||||
{
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the gui components
|
|
||||||
*/
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[grow,right][grow]", "[][][][][][][grow]" ) );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner configuration selector
|
|
||||||
*/
|
|
||||||
mComboConfigurations = new JComboBox<R820TTunerConfiguration>();
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
/* Determine which tuner configuration should be selected/displayed */
|
|
||||||
// TunerConfigurationAssignment savedConfig = mSettingsManager
|
|
||||||
// .getSelectedTunerConfiguration(
|
|
||||||
// TunerType.RAFAELMICRO_R820T, mController.getUniqueID() );
|
|
||||||
//
|
|
||||||
// if( savedConfig != null )
|
|
||||||
// {
|
|
||||||
// mSelectedConfig = getNamedConfiguration(
|
|
||||||
// savedConfig.getTunerConfigurationName() );
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* If we couldn't determine the saved/selected config, use the first one */
|
|
||||||
// if( mSelectedConfig == null )
|
|
||||||
// {
|
|
||||||
// mSelectedConfig = mComboConfigurations.getItemAt( 0 );
|
|
||||||
//
|
|
||||||
// //Store this config as the default for this tuner at this address
|
|
||||||
// mSettingsManager
|
|
||||||
// .setSelectedTunerConfiguration(
|
|
||||||
// TunerType.RAFAELMICRO_R820T,
|
|
||||||
// mController.getUniqueID(), mSelectedConfig );
|
|
||||||
// }
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedItem( mSelectedConfig );
|
|
||||||
|
|
||||||
mComboConfigurations.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
R820TTunerConfiguration selected =
|
|
||||||
(R820TTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
update( selected );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add( new JLabel( "Config:" ) );
|
|
||||||
add( mComboConfigurations, "growx,push" );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner Configuration Name
|
|
||||||
*/
|
|
||||||
mName = new JTextField();
|
|
||||||
mName.setText( mSelectedConfig.getName() );
|
|
||||||
|
|
||||||
mName.addFocusListener( new FocusListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void focusLost( FocusEvent e )
|
|
||||||
{
|
|
||||||
mSelectedConfig.setName( mName.getText() );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void focusGained( FocusEvent e ) {}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Name:" ) );
|
|
||||||
add( mName, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frequency Correction
|
|
||||||
*/
|
|
||||||
SpinnerModel model =
|
|
||||||
new SpinnerNumberModel( 0.0, //initial value
|
|
||||||
-1000.0, //min
|
|
||||||
1000.0, //max
|
|
||||||
0.1 ); //step
|
|
||||||
|
|
||||||
mFrequencyCorrection = new JSpinner( model );
|
|
||||||
|
|
||||||
JSpinner.NumberEditor editor =
|
|
||||||
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
|
||||||
|
|
||||||
DecimalFormat format = editor.getFormat();
|
|
||||||
format.setMinimumFractionDigits( 1 );
|
|
||||||
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
|
||||||
|
|
||||||
mFrequencyCorrection.setValue( mSelectedConfig.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mFrequencyCorrection.addChangeListener( new ChangeListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged( ChangeEvent e )
|
|
||||||
{
|
|
||||||
final double value = ((SpinnerNumberModel)mFrequencyCorrection
|
|
||||||
.getModel()).getNumber().doubleValue();
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setFrequencyCorrection( value );
|
|
||||||
mSelectedConfig.setFrequencyCorrection( value );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply "
|
|
||||||
+ "frequency correction value: " + value, e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Correction PPM:" ) );
|
|
||||||
add( mFrequencyCorrection, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample Rate
|
|
||||||
*/
|
|
||||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
SampleRate sampleRate =
|
|
||||||
(SampleRate)mComboSampleRate.getSelectedItem();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
mController.setSampleRate( sampleRate );
|
|
||||||
|
|
||||||
mSelectedConfig.setSampleRate( sampleRate );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( SourceException | LibUsbException eSampleRate )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply the sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "] " +
|
|
||||||
eSampleRate.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply sample "
|
|
||||||
+ "rate setting [" + sampleRate.getLabel() + "]",
|
|
||||||
eSampleRate );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
add( new JLabel( "Sample Rate:" ) );
|
|
||||||
add( mComboSampleRate, "growx,push" );
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Sample Rate Correction
|
|
||||||
// */
|
|
||||||
// SpinnerModel sampleRateCorrectionModel =
|
|
||||||
// new SpinnerNumberModel( 0, //initial value
|
|
||||||
// -32768, //min
|
|
||||||
// 32767, //max
|
|
||||||
// 1 ); //step
|
|
||||||
//
|
|
||||||
// mSampleRateCorrection = new JSpinner( sampleRateCorrectionModel );
|
|
||||||
//
|
|
||||||
// JSpinner.NumberEditor sampleRateCorrectionEditor =
|
|
||||||
// (JSpinner.NumberEditor)mSampleRateCorrection.getEditor();
|
|
||||||
//
|
|
||||||
// DecimalFormat sampleRateCorrectionFormat =
|
|
||||||
// sampleRateCorrectionEditor.getFormat();
|
|
||||||
//
|
|
||||||
// sampleRateCorrectionFormat.setMinimumFractionDigits( 0 );
|
|
||||||
//
|
|
||||||
// sampleRateCorrectionEditor.getTextField()
|
|
||||||
// .setHorizontalAlignment( SwingConstants.CENTER );
|
|
||||||
//
|
|
||||||
// mSampleRateCorrection.addChangeListener( new ChangeListener()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void stateChanged( ChangeEvent e )
|
|
||||||
// {
|
|
||||||
// final int value = ((SpinnerNumberModel)mSampleRateCorrection
|
|
||||||
// .getModel()).getNumber().intValue();
|
|
||||||
//
|
|
||||||
// EventQueue.invokeLater( new Runnable()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void run()
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// mController.setSampleRateFrequencyCorrection( value );
|
|
||||||
// }
|
|
||||||
// catch ( SourceException | LibUsbException e1 )
|
|
||||||
// {
|
|
||||||
// JOptionPane.showMessageDialog(
|
|
||||||
// R820TTunerConfigurationPanel.this,
|
|
||||||
// "E4K Tuner Controller - couldn't apply "
|
|
||||||
// + "sample rate correction value: " + value +
|
|
||||||
// e1.getLocalizedMessage() );
|
|
||||||
//
|
|
||||||
// mLog.error( "E4K Tuner Controller - couldn't apply "
|
|
||||||
// + "sample rate correction value: " + value +
|
|
||||||
// e1.getLocalizedMessage() );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } );
|
|
||||||
// }
|
|
||||||
// } );
|
|
||||||
//
|
|
||||||
// add( mSampleRateCorrection );
|
|
||||||
// add( new JLabel( "Sample Rate Correction (ppm)" ), "grow,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gain Controls
|
|
||||||
*/
|
|
||||||
JPanel gainPanel = new JPanel();
|
|
||||||
gainPanel.setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
|
|
||||||
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
|
|
||||||
|
|
||||||
/* Master Gain Control */
|
|
||||||
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
|
||||||
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
|
|
||||||
|
|
||||||
mComboMasterGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
|
|
||||||
|
|
||||||
mController.setGain( (R820TGain)mComboMasterGain.getSelectedItem(), true );
|
|
||||||
|
|
||||||
if( gain == R820TGain.MANUAL )
|
|
||||||
{
|
|
||||||
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
|
|
||||||
mComboMixerGain.setEnabled( true );
|
|
||||||
|
|
||||||
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
|
|
||||||
mComboLNAGain.setEnabled( true );
|
|
||||||
|
|
||||||
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
|
|
||||||
mComboVGAGain.setEnabled( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mComboMixerGain.setEnabled( false );
|
|
||||||
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
|
|
||||||
|
|
||||||
mComboLNAGain.setEnabled( false );
|
|
||||||
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
|
|
||||||
|
|
||||||
mComboVGAGain.setEnabled( false );
|
|
||||||
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setMasterGain( gain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply the gain "
|
|
||||||
+ "setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply "
|
|
||||||
+ "gain setting - ", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboMasterGain.setToolTipText( "<html>Select <b>AUTOMATIC</b> for auto "
|
|
||||||
+ "gain, <b>MANUAL</b> to enable<br> independent control of "
|
|
||||||
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
|
|
||||||
+ "settings, or one of the individual gain settings for<br>"
|
|
||||||
+ "semi-manual gain control</html>" );
|
|
||||||
gainPanel.add( new JLabel( "Master" ) );
|
|
||||||
gainPanel.add( mComboMasterGain );
|
|
||||||
|
|
||||||
/* Mixer Gain Control */
|
|
||||||
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
|
|
||||||
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
|
|
||||||
mComboMixerGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
R820TMixerGain mixerGain =
|
|
||||||
(R820TMixerGain)mComboMixerGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( mixerGain == null )
|
|
||||||
{
|
|
||||||
mixerGain = DEFAULT_GAIN.getMixerGain();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboMixerGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setMixerGain( mixerGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setMixerGain( mixerGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply the mixer "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply mixer "
|
|
||||||
+ "gain setting - ", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
|
||||||
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
|
||||||
mComboMixerGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "Mixer" ) );
|
|
||||||
gainPanel.add( mComboMixerGain, "wrap" );
|
|
||||||
|
|
||||||
/* LNA Gain Control */
|
|
||||||
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboLNAGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
R820TLNAGain lnaGain =
|
|
||||||
(R820TLNAGain)mComboLNAGain.getSelectedItem();
|
|
||||||
|
|
||||||
if ( lnaGain == null )
|
|
||||||
{
|
|
||||||
lnaGain = DEFAULT_GAIN.getLNAGain();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboLNAGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setLNAGain( lnaGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setLNAGain( lnaGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply the LNA "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply LNA "
|
|
||||||
+ "gain setting - ", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
|
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
|
||||||
mComboLNAGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "LNA" ) );
|
|
||||||
gainPanel.add( mComboLNAGain );
|
|
||||||
|
|
||||||
/* VGA Gain Control */
|
|
||||||
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
|
|
||||||
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
|
|
||||||
mComboVGAGain.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
R820TVGAGain vgaGain =
|
|
||||||
(R820TVGAGain)mComboVGAGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( vgaGain == null )
|
|
||||||
{
|
|
||||||
vgaGain = DEFAULT_GAIN.getVGAGain();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboVGAGain.isEnabled() )
|
|
||||||
{
|
|
||||||
mController.setVGAGain( vgaGain, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
mSelectedConfig.setVGAGain( vgaGain );
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch ( UsbException e )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't apply the VGA "
|
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply VGA "
|
|
||||||
+ "gain setting", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
|
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
|
||||||
mComboVGAGain.setEnabled( false );
|
|
||||||
gainPanel.add( new JLabel( "VGA" ) );
|
|
||||||
gainPanel.add( mComboVGAGain, "wrap" );
|
|
||||||
|
|
||||||
add( gainPanel, "span" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new configuration
|
|
||||||
*/
|
|
||||||
mNewConfiguration = new JButton( "New" );
|
|
||||||
|
|
||||||
mNewConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
// TunerConfiguration config =
|
|
||||||
// mSettingsManager
|
|
||||||
// .addNewTunerConfiguration(
|
|
||||||
// TunerType.RAFAELMICRO_R820T,
|
|
||||||
// "New Configuration" );
|
|
||||||
//
|
|
||||||
// mComboConfigurations.setModel( getModel() );
|
|
||||||
//
|
|
||||||
// mComboConfigurations.setSelectedItem( config );
|
|
||||||
//
|
|
||||||
// repaint();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mNewConfiguration, "growx,push" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the currently selected configuration
|
|
||||||
*/
|
|
||||||
mDeleteConfiguration = new JButton( "Delete" );
|
|
||||||
|
|
||||||
mDeleteConfiguration.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
R820TTunerConfiguration selected =
|
|
||||||
(R820TTunerConfiguration)mComboConfigurations
|
|
||||||
.getItemAt( mComboConfigurations.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
int n = JOptionPane.showConfirmDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"Are you sure you want to delete '"
|
|
||||||
+ selected.getName() + "'?",
|
|
||||||
"Are you sure?",
|
|
||||||
JOptionPane.YES_NO_OPTION );
|
|
||||||
|
|
||||||
if( n == JOptionPane.YES_OPTION )
|
|
||||||
{
|
|
||||||
// mSettingsManager
|
|
||||||
// .deleteTunerConfiguration( selected );
|
|
||||||
|
|
||||||
mComboConfigurations.setModel( getModel() );
|
|
||||||
|
|
||||||
mComboConfigurations.setSelectedIndex( 0 );
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( mDeleteConfiguration, "growx,push,wrap" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates gui controls with the values from the tuner configuration
|
|
||||||
* @param config - tuner configuration
|
|
||||||
*/
|
|
||||||
private void update( R820TTunerConfiguration config )
|
|
||||||
{
|
|
||||||
mSelectedConfig = config;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.apply( config );
|
|
||||||
|
|
||||||
mName.setText( config.getName() );
|
|
||||||
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
|
||||||
|
|
||||||
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
|
|
||||||
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
|
|
||||||
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
|
|
||||||
|
|
||||||
/* Apply master gain last so that the Mixer, LNA, and VGA gain
|
|
||||||
* settings are updated with the master setting where necessary */
|
|
||||||
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
|
|
||||||
|
|
||||||
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
|
|
||||||
|
|
||||||
// mSettingsManager.setSelectedTunerConfiguration(
|
|
||||||
// TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
|
|
||||||
}
|
|
||||||
catch ( SourceException e1 )
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(
|
|
||||||
R820TTunerConfigurationEditorOld.this,
|
|
||||||
"R820T Tuner Controller - couldn't "
|
|
||||||
+ "apply the tuner configuration settings - " +
|
|
||||||
e1.getLocalizedMessage() );
|
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply "
|
|
||||||
+ "config [" + config.getName() + "]", e1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a combo box model for the tuner configuration combo component
|
|
||||||
* by assembling a list of the tuner configurations appropriate for this
|
|
||||||
* specific tuner
|
|
||||||
*/
|
|
||||||
private ComboBoxModel<R820TTunerConfiguration> getModel()
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
|
||||||
|
|
||||||
DefaultComboBoxModel<R820TTunerConfiguration> model =
|
|
||||||
new DefaultComboBoxModel<R820TTunerConfiguration>();
|
|
||||||
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// model.addElement( (R820TTunerConfiguration)config );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a specific (named) tuner configuration
|
|
||||||
*/
|
|
||||||
private R820TTunerConfiguration getNamedConfiguration( String name )
|
|
||||||
{
|
|
||||||
// ArrayList<TunerConfiguration> configs =
|
|
||||||
// mSettingsManager
|
|
||||||
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
|
||||||
//
|
|
||||||
// for( TunerConfiguration config: configs )
|
|
||||||
// {
|
|
||||||
// if( config.getName().contentEquals( name ) )
|
|
||||||
// {
|
|
||||||
// return (R820TTunerConfiguration)config;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves current tuner configuration settings
|
|
||||||
*/
|
|
||||||
private void save()
|
|
||||||
{
|
|
||||||
// mSettingsManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -59,8 +59,7 @@ import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
|
|||||||
|
|
||||||
public class R820TTunerEditor extends TunerConfigurationEditor
|
public class R820TTunerEditor extends TunerConfigurationEditor
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger( R820TTunerEditor.class );
|
||||||
LoggerFactory.getLogger( R820TTunerEditor.class );
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
|
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
|
||||||
@@ -69,16 +68,15 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
|
|
||||||
private JTextField mConfigurationName;
|
private JTextField mConfigurationName;
|
||||||
private JButton mTunerInfo;
|
private JButton mTunerInfo;
|
||||||
|
private JComboBox<SampleRate> mComboSampleRate;
|
||||||
private JSpinner mFrequencyCorrection;
|
private JSpinner mFrequencyCorrection;
|
||||||
private JComboBox<R820TGain> mComboMasterGain;
|
private JComboBox<R820TGain> mComboMasterGain;
|
||||||
private JComboBox<R820TMixerGain> mComboMixerGain;
|
private JComboBox<R820TMixerGain> mComboMixerGain;
|
||||||
private JComboBox<R820TLNAGain> mComboLNAGain;
|
private JComboBox<R820TLNAGain> mComboLNAGain;
|
||||||
private JComboBox<R820TVGAGain> mComboVGAGain;
|
private JComboBox<R820TVGAGain> mComboVGAGain;
|
||||||
private JComboBox<SampleRate> mComboSampleRate;
|
|
||||||
private boolean mLoading;
|
private boolean mLoading;
|
||||||
|
|
||||||
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
|
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel, RTL2832Tuner tuner )
|
||||||
RTL2832Tuner tuner )
|
|
||||||
{
|
{
|
||||||
super( tunerConfigurationModel );
|
super( tunerConfigurationModel );
|
||||||
mController = (R820TTunerController)tuner.getController();
|
mController = (R820TTunerController)tuner.getController();
|
||||||
@@ -103,9 +101,6 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
|
|
||||||
add( new JLabel( "R820T Tuner Configuration" ), "span,align center" );
|
add( new JLabel( "R820T Tuner Configuration" ), "span,align center" );
|
||||||
|
|
||||||
/**
|
|
||||||
* Tuner Configuration Name
|
|
||||||
*/
|
|
||||||
mConfigurationName = new JTextField();
|
mConfigurationName = new JTextField();
|
||||||
mConfigurationName.setEnabled( false );
|
mConfigurationName.setEnabled( false );
|
||||||
mConfigurationName.addFocusListener( new FocusListener()
|
mConfigurationName.addFocusListener( new FocusListener()
|
||||||
@@ -215,7 +210,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
/**
|
/**
|
||||||
* Gain Controls
|
* Gain Controls
|
||||||
*/
|
*/
|
||||||
add( new JLabel( "Gain" ), "span,align left" );
|
add( new JLabel( "Gain" ), "warp" );
|
||||||
|
|
||||||
/* Master Gain Control */
|
/* Master Gain Control */
|
||||||
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
||||||
|
|||||||
Reference in New Issue
Block a user