mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
wip: #34 Adds the E4000 tuner editor and updates a few other tuner
editor pieces.
This commit is contained in:
@@ -52,7 +52,9 @@ import source.tuner.airspy.AirspyTunerController.Gain;
|
|||||||
import source.tuner.airspy.AirspyTunerController.GainMode;
|
import source.tuner.airspy.AirspyTunerController.GainMode;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
import source.tuner.configuration.TunerConfigurationEditor;
|
import source.tuner.configuration.TunerConfigurationEditor;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent;
|
||||||
import source.tuner.configuration.TunerConfigurationModel;
|
import source.tuner.configuration.TunerConfigurationModel;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent.Event;
|
||||||
|
|
||||||
public class AirspyTunerEditor extends TunerConfigurationEditor
|
public class AirspyTunerEditor extends TunerConfigurationEditor
|
||||||
{
|
{
|
||||||
@@ -113,8 +115,6 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
|
|||||||
|
|
||||||
add( new JLabel( "Airspy Tuner Configuration" ), "span,align center" );
|
add( new JLabel( "Airspy Tuner Configuration" ), "span,align center" );
|
||||||
|
|
||||||
// tabs.add( "Info", new AirspyInformationPanel( mController ) );
|
|
||||||
|
|
||||||
mConfigurationName = new JTextField();
|
mConfigurationName = new JTextField();
|
||||||
mConfigurationName.setEnabled( false );
|
mConfigurationName.setEnabled( false );
|
||||||
mConfigurationName.addFocusListener( new FocusListener()
|
mConfigurationName.addFocusListener( new FocusListener()
|
||||||
@@ -569,6 +569,9 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
|
|||||||
config.setLNAGain( mLNAGain.getValue() );
|
config.setLNAGain( mLNAGain.getValue() );
|
||||||
config.setMixerAGC( mMixerAGC.isSelected() );
|
config.setMixerAGC( mMixerAGC.isSelected() );
|
||||||
config.setLNAAGC( mLNAAGC.isSelected() );
|
config.setLNAAGC( mLNAAGC.isSelected() );
|
||||||
|
|
||||||
|
getTunerConfigurationModel().broadcast(
|
||||||
|
new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,15 @@ import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
|
|||||||
import source.tuner.hackrf.HackRFTunerConfiguration;
|
import source.tuner.hackrf.HackRFTunerConfiguration;
|
||||||
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.r820t.R820TTunerConfiguration;
|
import source.tuner.rtl.r820t.R820TTunerConfiguration;
|
||||||
import source.tuner.rtl.r820t.R820TTunerEditor;
|
import source.tuner.rtl.r820t.R820TTunerEditor;
|
||||||
|
|
||||||
public class TunerConfigurationFactory
|
public class TunerConfigurationFactory
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Creates a tuner configuration for the specified tuner type, unique ID and name
|
||||||
|
*/
|
||||||
public static TunerConfiguration getTunerConfiguration( TunerType type,
|
public static TunerConfiguration getTunerConfiguration( TunerType type,
|
||||||
String uniqueID, String name )
|
String uniqueID, String name )
|
||||||
{
|
{
|
||||||
@@ -41,6 +45,9 @@ public class TunerConfigurationFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a tuner editor gui for the specified tuner
|
||||||
|
*/
|
||||||
public static Editor<TunerConfiguration> getEditor( Tuner tuner,
|
public static Editor<TunerConfiguration> getEditor( Tuner tuner,
|
||||||
TunerConfigurationModel model )
|
TunerConfigurationModel model )
|
||||||
{
|
{
|
||||||
@@ -49,20 +56,18 @@ public class TunerConfigurationFactory
|
|||||||
case AIRSPY_R820T:
|
case AIRSPY_R820T:
|
||||||
return new AirspyTunerEditor( model, (AirspyTuner)tuner );
|
return new AirspyTunerEditor( model, (AirspyTuner)tuner );
|
||||||
case ELONICS_E4000:
|
case ELONICS_E4000:
|
||||||
break;
|
return new E4KTunerEditor( model, (RTL2832Tuner)tuner );
|
||||||
case FUNCUBE_DONGLE_PRO:
|
case FUNCUBE_DONGLE_PRO:
|
||||||
break;
|
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
||||||
case FUNCUBE_DONGLE_PRO_PLUS:
|
case FUNCUBE_DONGLE_PRO_PLUS:
|
||||||
break;
|
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
||||||
case HACKRF:
|
case HACKRF:
|
||||||
break;
|
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
||||||
case RAFAELMICRO_R820T:
|
case RAFAELMICRO_R820T:
|
||||||
return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
|
return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
default:
|
default:
|
||||||
break;
|
throw new IllegalArgumentException( "Unrecognized Tuner: " + tuner.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ public class TunerConfigurationModel extends AbstractTableModel
|
|||||||
{
|
{
|
||||||
if( config.isAssigned() )
|
if( config.isAssigned() )
|
||||||
{
|
{
|
||||||
mLog.debug( "Unassigning: " + config.getName() );
|
|
||||||
config.setAssigned( false );
|
config.setAssigned( false );
|
||||||
|
|
||||||
int index = mTunerConfigurations.indexOf( config );
|
int index = mTunerConfigurations.indexOf( config );
|
||||||
@@ -162,7 +161,6 @@ public class TunerConfigurationModel extends AbstractTableModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mLog.debug( "Assigning: " + configToAssign.getName() );
|
|
||||||
configToAssign.setAssigned( true );
|
configToAssign.setAssigned( true );
|
||||||
int index = mTunerConfigurations.indexOf( configToAssign );
|
int index = mTunerConfigurations.indexOf( configToAssign );
|
||||||
fireTableCellUpdated( index, ASSIGNED );
|
fireTableCellUpdated( index, ASSIGNED );
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ import source.tuner.rtl.e4k.E4KTunerController.E4KMixerGain;
|
|||||||
|
|
||||||
public class E4KTunerConfiguration extends TunerConfiguration
|
public class E4KTunerConfiguration extends TunerConfiguration
|
||||||
{
|
{
|
||||||
private E4KGain mMasterGain = E4KGain.AUTOMATIC;
|
private E4KGain mMasterGain = E4KGain.MANUAL;
|
||||||
private E4KMixerGain mMixerGain = E4KMixerGain.AUTOMATIC;
|
private E4KMixerGain mMixerGain = E4KMixerGain.GAIN_4;
|
||||||
private E4KLNAGain mLNAGain = E4KLNAGain.AUTOMATIC;
|
private E4KLNAGain mLNAGain = E4KLNAGain.GAIN_PLUS_200;
|
||||||
private E4KEnhanceGain mEnhanceGain = E4KEnhanceGain.AUTOMATIC;
|
private E4KEnhanceGain mEnhanceGain = E4KEnhanceGain.GAIN_3;
|
||||||
private double mFrequencyCorrection = 8.9d;
|
private double mFrequencyCorrection = 0.0d;
|
||||||
private SampleRate mSampleRate = SampleRate.RATE_1_920MHZ;
|
private SampleRate mSampleRate = SampleRate.RATE_2_400MHZ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for JAXB
|
* Default constructor for JAXB
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package source.tuner.rtl.e4k;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.usb.UsbException;
|
import javax.usb.UsbException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -30,7 +29,6 @@ import org.usb4java.DeviceHandle;
|
|||||||
import org.usb4java.LibUsb;
|
import org.usb4java.LibUsb;
|
||||||
import org.usb4java.LibUsbException;
|
import org.usb4java.LibUsbException;
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.TunerType;
|
import source.tuner.TunerType;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
@@ -110,8 +108,6 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
|
|
||||||
public static final byte CHFCALIB_CMD = (byte)0x01;
|
public static final byte CHFCALIB_CMD = (byte)0x01;
|
||||||
|
|
||||||
private E4KTunerEditorPanel mEditor;
|
|
||||||
|
|
||||||
public E4KTunerController( Device device,
|
public E4KTunerController( Device device,
|
||||||
DeviceDescriptor deviceDescriptor,
|
DeviceDescriptor deviceDescriptor,
|
||||||
ThreadPoolManager threadPoolManager )
|
ThreadPoolManager threadPoolManager )
|
||||||
@@ -252,16 +248,6 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getEditor( SettingsManager settingsManager )
|
|
||||||
{
|
|
||||||
if( mEditor == null )
|
|
||||||
{
|
|
||||||
mEditor = new E4KTunerEditorPanel( this, settingsManager );
|
|
||||||
}
|
|
||||||
|
|
||||||
return mEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the IF filters (mixer, channel and RC) to the correct filter setting
|
* Sets the IF filters (mixer, channel and RC) to the correct filter setting
|
||||||
* for the selected bandwidth/sample rate
|
* for the selected bandwidth/sample rate
|
||||||
@@ -1070,7 +1056,7 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
(byte)( ( temp & ~mask ) | ( value & mask ) ),
|
(byte)( ( temp & ~mask ) | ( value & mask ) ),
|
||||||
controlI2CRepeater );
|
controlI2CRepeater );
|
||||||
|
|
||||||
int temp2 = readE4KRegister( register, controlI2CRepeater );
|
readE4KRegister( register, controlI2CRepeater );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
494
src/source/tuner/rtl/e4k/E4KTunerEditor.java
Normal file
494
src/source/tuner/rtl/e4k/E4KTunerEditor.java
Normal file
@@ -0,0 +1,494 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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.rtl.e4k;
|
||||||
|
|
||||||
|
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.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 source.SourceException;
|
||||||
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEditor;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent;
|
||||||
|
import source.tuner.configuration.TunerConfigurationModel;
|
||||||
|
import source.tuner.rtl.RTL2832Tuner;
|
||||||
|
import source.tuner.rtl.RTL2832TunerController.Descriptor;
|
||||||
|
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 E4KTunerEditor extends TunerConfigurationEditor
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( E4KTunerEditor.class );
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private JTextField mConfigurationName;
|
||||||
|
private JButton mTunerInfo;
|
||||||
|
private JComboBox<SampleRate> mComboSampleRate;
|
||||||
|
private JSpinner mFrequencyCorrection;
|
||||||
|
private JComboBox<E4KGain> mComboMasterGain;
|
||||||
|
private JComboBox<E4KMixerGain> mComboMixerGain;
|
||||||
|
private JComboBox<E4KLNAGain> mComboLNAGain;
|
||||||
|
private JComboBox<E4KEnhanceGain> mComboEnhanceGain;
|
||||||
|
|
||||||
|
private E4KTunerController mController;
|
||||||
|
private boolean mLoading;
|
||||||
|
|
||||||
|
public E4KTunerEditor( TunerConfigurationModel tunerConfigurationModel, RTL2832Tuner tuner )
|
||||||
|
{
|
||||||
|
super( tunerConfigurationModel );
|
||||||
|
mController = (E4KTunerController)tuner.getController();
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private E4KTunerConfiguration getConfiguration()
|
||||||
|
{
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
return (E4KTunerConfiguration)getItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]",
|
||||||
|
"[][][][][][][][grow]" ) );
|
||||||
|
|
||||||
|
add( new JLabel( "E4000 Tuner Configuration" ), "span,align center" );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tuner Configuration Name
|
||||||
|
*/
|
||||||
|
add( new JLabel( "Name:" ) );
|
||||||
|
mConfigurationName = new JTextField();
|
||||||
|
mConfigurationName.setEnabled( false );
|
||||||
|
mConfigurationName.addFocusListener( new FocusListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void focusLost( FocusEvent e )
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void focusGained( FocusEvent e ) {}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( mConfigurationName, "span 2" );
|
||||||
|
|
||||||
|
mTunerInfo = new JButton( "Tuner Info" );
|
||||||
|
mTunerInfo.setEnabled( false );
|
||||||
|
mTunerInfo.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.this, getTunerInfo(),
|
||||||
|
"Tuner Info", JOptionPane.INFORMATION_MESSAGE );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mTunerInfo );
|
||||||
|
|
||||||
|
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
||||||
|
mComboSampleRate.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
SampleRate sampleRate = (SampleRate)mComboSampleRate.getSelectedItem();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mController.setSampleRate( sampleRate );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( SourceException | LibUsbException eSampleRate )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.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 );
|
||||||
|
|
||||||
|
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( E4KTunerEditor.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( "PPM:" ) );
|
||||||
|
add( mFrequencyCorrection );
|
||||||
|
|
||||||
|
mComboMasterGain = new JComboBox<E4KGain>( E4KGain.values() );
|
||||||
|
mComboMasterGain.setEnabled( false );
|
||||||
|
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.setSelectedItem( mController.getEnhanceGain( true ) );
|
||||||
|
mComboEnhanceGain.setEnabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mComboMixerGain.setEnabled( false );
|
||||||
|
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
|
||||||
|
|
||||||
|
mComboLNAGain.setEnabled( false );
|
||||||
|
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
|
||||||
|
|
||||||
|
mComboEnhanceGain.setEnabled( false );
|
||||||
|
mComboEnhanceGain.setSelectedItem( gain.getEnhanceGain() );
|
||||||
|
}
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.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>" );
|
||||||
|
add( new JLabel( "Master" ) );
|
||||||
|
add( mComboMasterGain );
|
||||||
|
|
||||||
|
mComboMixerGain = new JComboBox<E4KMixerGain>( E4KMixerGain.values() );
|
||||||
|
mComboMixerGain.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
E4KMixerGain mixerGain = (E4KMixerGain)mComboMixerGain.getSelectedItem();
|
||||||
|
mController.setMixerGain( mixerGain, true );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.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 );
|
||||||
|
add( new JLabel( "Mixer" ) );
|
||||||
|
add( mComboMixerGain );
|
||||||
|
|
||||||
|
mComboLNAGain = new JComboBox<E4KLNAGain>( E4KLNAGain.values() );
|
||||||
|
mComboLNAGain.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
E4KLNAGain lnaGain = (E4KLNAGain)mComboLNAGain.getSelectedItem();
|
||||||
|
mController.setLNAGain( lnaGain, true );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.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 );
|
||||||
|
add( new JLabel( "LNA:" ) );
|
||||||
|
add( mComboLNAGain );
|
||||||
|
|
||||||
|
mComboEnhanceGain = new JComboBox<E4KEnhanceGain>( E4KEnhanceGain.values() );
|
||||||
|
mComboEnhanceGain.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
E4KEnhanceGain enhance = (E4KEnhanceGain)mComboEnhanceGain.getSelectedItem();
|
||||||
|
mController.setEnhanceGain( enhance, true );
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch ( UsbException e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( E4KTunerEditor.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 );
|
||||||
|
add( new JLabel( "Enhance:" ) );
|
||||||
|
add( mComboEnhanceGain );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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( mComboMasterGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboMasterGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboMixerGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboMixerGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboLNAGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboLNAGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboEnhanceGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboEnhanceGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTunerInfo()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
Descriptor descriptor = mController.getDescriptor();
|
||||||
|
|
||||||
|
sb.append( "<html><h3>RTL-2832 with E4000 Tuner</h3>" );
|
||||||
|
|
||||||
|
if( descriptor == null )
|
||||||
|
{
|
||||||
|
sb.append( "No EEPROM Descriptor Available" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "<b>USB ID: </b>" );
|
||||||
|
sb.append( descriptor.getVendorID() );
|
||||||
|
sb.append( ":" );
|
||||||
|
sb.append( descriptor.getProductID() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Vendor: </b>" );
|
||||||
|
sb.append( descriptor.getVendorLabel() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Product: </b>" );
|
||||||
|
sb.append( descriptor.getProductLabel() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Serial: </b>" );
|
||||||
|
sb.append( descriptor.getSerial() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>IR Enabled: </b>" );
|
||||||
|
sb.append( descriptor.irEnabled() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
|
||||||
|
sb.append( "<b>Remote Wake: </b>" );
|
||||||
|
sb.append( descriptor.remoteWakeupEnabled() );
|
||||||
|
sb.append( "<br>" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && !mLoading )
|
||||||
|
{
|
||||||
|
E4KTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
|
config.setName( mConfigurationName.getText() );
|
||||||
|
|
||||||
|
config.setSampleRate( (SampleRate)mComboSampleRate.getSelectedItem() );
|
||||||
|
|
||||||
|
double value = ((SpinnerNumberModel)mFrequencyCorrection
|
||||||
|
.getModel()).getNumber().doubleValue();
|
||||||
|
config.setFrequencyCorrection( value );
|
||||||
|
|
||||||
|
config.setMasterGain( (E4KGain)mComboMasterGain.getSelectedItem() );
|
||||||
|
config.setMixerGain( (E4KMixerGain)mComboMixerGain.getSelectedItem() );
|
||||||
|
config.setLNAGain( (E4KLNAGain)mComboLNAGain.getSelectedItem() );
|
||||||
|
config.setEnhanceGain( (E4KEnhanceGain)mComboEnhanceGain.getSelectedItem() );
|
||||||
|
|
||||||
|
getTunerConfigurationModel().broadcast( new TunerConfigurationEvent(
|
||||||
|
getConfiguration(), TunerConfigurationEvent.Event.CHANGE ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( TunerConfiguration tunerConfiguration )
|
||||||
|
{
|
||||||
|
super.setItem( tunerConfiguration );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
E4KTunerConfiguration 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() );
|
||||||
|
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
||||||
|
mComboSampleRate.setSelectedItem( config.getSampleRate() );
|
||||||
|
mComboMasterGain.setSelectedItem( config.getMasterGain() );
|
||||||
|
mComboMixerGain.setSelectedItem( config.getMixerGain() );
|
||||||
|
mComboLNAGain.setSelectedItem( config.getLNAGain() );
|
||||||
|
mComboEnhanceGain.setSelectedItem( config.getEnhanceGain() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( config.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
mLoading = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,122 +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 gui.control.JFrequencyControl;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
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.rtl.RTL2832InfoPanel;
|
|
||||||
|
|
||||||
import com.jidesoft.swing.JideTabbedPane;
|
|
||||||
|
|
||||||
public class E4KTunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
|
|
||||||
{
|
|
||||||
private final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( E4KTunerEditorPanel.class );
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private E4KTunerController mController;
|
|
||||||
private SettingsManager mSettingsManager;
|
|
||||||
|
|
||||||
private JFrequencyControl mFrequencyControl;
|
|
||||||
|
|
||||||
public E4KTunerEditorPanel( E4KTunerController controller,
|
|
||||||
SettingsManager settingsManager )
|
|
||||||
{
|
|
||||||
mController = controller;
|
|
||||||
mSettingsManager = settingsManager;
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) );
|
|
||||||
|
|
||||||
add( new JLabel( "RTL2832 with E4000 Tuner" ), "span 2, align center, wrap" );
|
|
||||||
|
|
||||||
mFrequencyControl = new JFrequencyControl();
|
|
||||||
|
|
||||||
mFrequencyControl.addListener( this );
|
|
||||||
|
|
||||||
/* Add frequency control as listener on the controller, to maintain
|
|
||||||
* sync with the tuned frequency value */
|
|
||||||
mController.addListener( mFrequencyControl );
|
|
||||||
|
|
||||||
mFrequencyControl.setFrequency( mController.getFrequency(), false );
|
|
||||||
|
|
||||||
add( mFrequencyControl, "span 2, align center, wrap" );
|
|
||||||
|
|
||||||
JideTabbedPane tabs = new JideTabbedPane();
|
|
||||||
tabs.setFont( this.getFont() );
|
|
||||||
tabs.setForeground( Color.BLACK );
|
|
||||||
|
|
||||||
tabs.addTab( "Configuration",
|
|
||||||
new E4KTunerConfigurationPanel( mSettingsManager, mController ) );
|
|
||||||
|
|
||||||
tabs.addTab( "Info", new RTL2832InfoPanel( mController ) );
|
|
||||||
|
|
||||||
add( tabs, "grow,push,span" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frequency change listener for the frequency control gui component to
|
|
||||||
* apply end-user requested frequency changes against the tuner
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void frequencyChanged( FrequencyChangeEvent event )
|
|
||||||
{
|
|
||||||
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
|
|
||||||
{
|
|
||||||
final long frequency = event.getValue().longValue();
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mController.setFrequency( frequency );
|
|
||||||
}
|
|
||||||
catch ( SourceException e )
|
|
||||||
{
|
|
||||||
mLog.error( "E4KTunerController - error setting frequency [" +
|
|
||||||
frequency + "]", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -44,8 +44,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.usb4java.LibUsbException;
|
import org.usb4java.LibUsbException;
|
||||||
|
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.airspy.AirspyDeviceInformation;
|
|
||||||
import source.tuner.airspy.AirspyTunerEditor;
|
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
import source.tuner.configuration.TunerConfigurationEditor;
|
import source.tuner.configuration.TunerConfigurationEditor;
|
||||||
import source.tuner.configuration.TunerConfigurationEvent;
|
import source.tuner.configuration.TunerConfigurationEvent;
|
||||||
@@ -88,121 +86,6 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
if( hasItem() && !mLoading )
|
|
||||||
{
|
|
||||||
R820TTunerConfiguration config = getConfiguration();
|
|
||||||
|
|
||||||
config.setName( mConfigurationName.getText() );
|
|
||||||
|
|
||||||
double value = ((SpinnerNumberModel)mFrequencyCorrection
|
|
||||||
.getModel()).getNumber().doubleValue();
|
|
||||||
config.setFrequencyCorrection( value );
|
|
||||||
|
|
||||||
config.setSampleRate( (SampleRate)mComboSampleRate.getSelectedItem() );
|
|
||||||
|
|
||||||
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
|
|
||||||
config.setMasterGain( gain );
|
|
||||||
|
|
||||||
R820TMixerGain mixerGain = (R820TMixerGain)mComboMixerGain.getSelectedItem();
|
|
||||||
config.setMixerGain( mixerGain );
|
|
||||||
|
|
||||||
R820TLNAGain lnaGain = (R820TLNAGain)mComboLNAGain.getSelectedItem();
|
|
||||||
config.setLNAGain( lnaGain );
|
|
||||||
|
|
||||||
R820TVGAGain vgaGain = (R820TVGAGain)mComboVGAGain.getSelectedItem();
|
|
||||||
config.setVGAGain( vgaGain );
|
|
||||||
|
|
||||||
getTunerConfigurationModel().broadcast(
|
|
||||||
new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setItem( TunerConfiguration item )
|
|
||||||
{
|
|
||||||
super.setItem( item );
|
|
||||||
|
|
||||||
if( hasItem() )
|
|
||||||
{
|
|
||||||
R820TTunerConfiguration config = getConfiguration();
|
|
||||||
|
|
||||||
//Toggle loading so that we don't fire a change event and schedule a settings file save
|
|
||||||
mLoading = true;
|
|
||||||
|
|
||||||
if( item.isAssigned() )
|
|
||||||
{
|
|
||||||
setControlsEnabled( true );
|
|
||||||
mConfigurationName.setText( config.getName() );
|
|
||||||
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
|
||||||
mComboSampleRate.setSelectedItem( config.getSampleRate() );
|
|
||||||
mComboMasterGain.setSelectedItem( config.getMasterGain() );
|
|
||||||
mComboMixerGain.setSelectedItem( config.getMixerGain() );
|
|
||||||
mComboLNAGain.setSelectedItem( config.getLNAGain() );
|
|
||||||
mComboVGAGain.setSelectedItem( config.getVGAGain() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setControlsEnabled( false );
|
|
||||||
mConfigurationName.setText( config.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mLoading = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setControlsEnabled( false );
|
|
||||||
mConfigurationName.setText( "" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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( mComboMasterGain.isEnabled() != enabled )
|
|
||||||
{
|
|
||||||
mComboMasterGain.setEnabled( enabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboMixerGain.isEnabled() != enabled )
|
|
||||||
{
|
|
||||||
mComboMixerGain.setEnabled( enabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboLNAGain.isEnabled() != enabled )
|
|
||||||
{
|
|
||||||
mComboLNAGain.setEnabled( enabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mComboVGAGain.isEnabled() != enabled )
|
|
||||||
{
|
|
||||||
mComboVGAGain.setEnabled( enabled );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private R820TTunerConfiguration getConfiguration()
|
private R820TTunerConfiguration getConfiguration()
|
||||||
{
|
{
|
||||||
if( hasItem() )
|
if( hasItem() )
|
||||||
@@ -252,7 +135,6 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
} );
|
} );
|
||||||
add( mTunerInfo );
|
add( mTunerInfo );
|
||||||
|
|
||||||
|
|
||||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
||||||
mComboSampleRate.setEnabled( false );
|
mComboSampleRate.setEnabled( false );
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
mComboSampleRate.addActionListener( new ActionListener()
|
||||||
@@ -333,7 +215,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
/**
|
/**
|
||||||
* Gain Controls
|
* Gain Controls
|
||||||
*/
|
*/
|
||||||
add( new JLabel( "Gain" ), "span" );
|
add( new JLabel( "Gain" ), "span,align left" );
|
||||||
|
|
||||||
/* Master Gain Control */
|
/* Master Gain Control */
|
||||||
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
||||||
@@ -520,6 +402,52 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
add( mComboVGAGain );
|
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( mComboMasterGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboMasterGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboMixerGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboMixerGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboLNAGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboLNAGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mComboVGAGain.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mComboVGAGain.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
private String getTunerInfo()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -563,4 +491,74 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && !mLoading )
|
||||||
|
{
|
||||||
|
R820TTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
|
config.setName( mConfigurationName.getText() );
|
||||||
|
|
||||||
|
double value = ((SpinnerNumberModel)mFrequencyCorrection
|
||||||
|
.getModel()).getNumber().doubleValue();
|
||||||
|
config.setFrequencyCorrection( value );
|
||||||
|
|
||||||
|
config.setSampleRate( (SampleRate)mComboSampleRate.getSelectedItem() );
|
||||||
|
|
||||||
|
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
|
||||||
|
config.setMasterGain( gain );
|
||||||
|
|
||||||
|
R820TMixerGain mixerGain = (R820TMixerGain)mComboMixerGain.getSelectedItem();
|
||||||
|
config.setMixerGain( mixerGain );
|
||||||
|
|
||||||
|
R820TLNAGain lnaGain = (R820TLNAGain)mComboLNAGain.getSelectedItem();
|
||||||
|
config.setLNAGain( lnaGain );
|
||||||
|
|
||||||
|
R820TVGAGain vgaGain = (R820TVGAGain)mComboVGAGain.getSelectedItem();
|
||||||
|
config.setVGAGain( vgaGain );
|
||||||
|
|
||||||
|
getTunerConfigurationModel().broadcast(
|
||||||
|
new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( TunerConfiguration tunerConfiguration )
|
||||||
|
{
|
||||||
|
super.setItem( tunerConfiguration );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
R820TTunerConfiguration 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() );
|
||||||
|
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
||||||
|
mComboSampleRate.setSelectedItem( config.getSampleRate() );
|
||||||
|
mComboMasterGain.setSelectedItem( config.getMasterGain() );
|
||||||
|
mComboMixerGain.setSelectedItem( config.getMixerGain() );
|
||||||
|
mComboLNAGain.setSelectedItem( config.getLNAGain() );
|
||||||
|
mComboVGAGain.setSelectedItem( config.getVGAGain() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( config.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
mLoading = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
mConfigurationName.setText( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user