wip #34 updates funcube dongle pro plus tuner editor

This commit is contained in:
denny
2016-03-20 07:22:18 -04:00
parent 4adffbdca7
commit 13617e8fe2
11 changed files with 450 additions and 211 deletions

View File

@@ -19,6 +19,7 @@ package source.mixer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@@ -168,7 +169,14 @@ public class MixerManager
public Collection<MixerTunerDataLine> getMixerTunerDataLines()
{
return mMixerTuners.values();
if( mMixerTuners.isEmpty() )
{
return Collections.emptyList();
}
else
{
return mMixerTuners.values();
}
}
private void loadMixers()

View File

@@ -1,3 +1,21 @@
/*******************************************************************************
* 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;
import gui.control.JFrequencyControl;

View File

@@ -54,6 +54,7 @@ public class TunerManager
TunerModel tunerModel,
ThreadPoolManager threadPoolManager )
{
mMixerManager = mixerManager;
mTunerModel = tunerModel;
mThreadPoolManager = threadPoolManager;

View File

@@ -1,3 +1,21 @@
/*******************************************************************************
* 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;
import java.awt.Color;

View File

@@ -1,3 +1,21 @@
/*******************************************************************************
* 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.configuration;
import gui.editor.Editor;
@@ -7,8 +25,10 @@ import source.tuner.TunerType;
import source.tuner.airspy.AirspyTuner;
import source.tuner.airspy.AirspyTunerConfiguration;
import source.tuner.airspy.AirspyTunerEditor;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerEditor;
import source.tuner.hackrf.HackRFTuner;
import source.tuner.hackrf.HackRFTunerConfiguration;
import source.tuner.hackrf.HackRFTunerEditor;
@@ -62,7 +82,7 @@ public class TunerConfigurationFactory
case FUNCUBE_DONGLE_PRO:
return new EmptyEditor<TunerConfiguration>( "a tuner" );
case FUNCUBE_DONGLE_PRO_PLUS:
return new EmptyEditor<TunerConfiguration>( "a tuner" );
return new FCD2TunerEditor( model, (FCDTuner)tuner );
case HACKRF:
return new HackRFTunerEditor( model, (HackRFTuner)tuner );
case RAFAELMICRO_R820T:

View File

@@ -1,3 +1,21 @@
/*******************************************************************************
* 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.configuration;
import java.util.ArrayList;

View File

@@ -147,23 +147,10 @@ public abstract class FCDTunerController extends TunerController
*/
public abstract TunerType getTunerType();
/**
* Editor panel (GUI) component.
*/
public abstract JPanel getEditor( FCDTuner tuner,
SettingsManager settingsManager );
/**
* Applies the settings in the tuner configuration
*/
public abstract void apply( TunerConfiguration config )
throws SourceException;
/**
* Returns the currently applied tuner configuration or null if one hasn't
* yet been applied
*/
public abstract TunerConfiguration getTunerConfiguration();
public abstract void apply( TunerConfiguration config ) throws SourceException;
/**
* USB address (bus/port)

View File

@@ -149,17 +149,6 @@ public class FCD1TunerController extends FCDTunerController
}
}
@Override
public JPanel getEditor( FCDTuner tuner, SettingsManager settingsManager )
{
if( mEditor == null )
{
mEditor = new FCD1TunerEditorPanel( tuner, settingsManager );
}
return mEditor;
}
/**
* Gets the current LNA Gain value from the controller and stores it
*/

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
* 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
@@ -20,49 +20,39 @@ package source.tuner.fcd.proplusV2;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.usb4java.Device;
import org.usb4java.DeviceDescriptor;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.MixerTunerType;
import source.tuner.TunerClass;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.FCDCommand;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerController;
public class FCD2TunerController extends FCDTunerController
{
private final static Logger mLog =
LoggerFactory.getLogger( FCD2TunerController.class );
private final static Logger mLog = LoggerFactory.getLogger( FCD2TunerController.class );
public static final int sMINIMUM_TUNABLE_FREQUENCY = 150000;
public static final int sMAXIMUM_TUNABLE_FREQUENCY = 2050000000;
public static final int sSAMPLE_RATE = 192000;
private FCD2TunerConfiguration mTunerConfiguration;
private FCD2TunerEditorPanel mEditor;
public static final int MINIMUM_TUNABLE_FREQUENCY = 150000;
public static final int MAXIMUM_TUNABLE_FREQUENCY = 2050000000;
public static final int SAMPLE_RATE = 192000;
public FCD2TunerController( Device device, DeviceDescriptor descriptor )
{
super( device,
descriptor,
super( device, descriptor,
(int)MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS.getAudioFormat().getSampleRate(),
sMINIMUM_TUNABLE_FREQUENCY,
sMAXIMUM_TUNABLE_FREQUENCY );
MINIMUM_TUNABLE_FREQUENCY, MAXIMUM_TUNABLE_FREQUENCY );
}
public void init() throws SourceException
{
super.init();
mFrequencyController.setSampleRate( sSAMPLE_RATE );
mFrequencyController.setSampleRate( SAMPLE_RATE );
try
{
@@ -76,7 +66,7 @@ public class FCD2TunerController extends FCDTunerController
public int getCurrentSampleRate()
{
return sSAMPLE_RATE;
return SAMPLE_RATE;
}
@Override
@@ -90,71 +80,44 @@ public class FCD2TunerController extends FCDTunerController
{
return TunerType.FUNCUBE_DONGLE_PRO_PLUS;
}
public JPanel getEditor( FCDTuner tuner, SettingsManager settingsManager )
{
if( mEditor == null )
{
mEditor = new FCD2TunerEditorPanel( tuner, settingsManager );
}
return mEditor;
}
public void setLNAGain( boolean enabled ) throws SourceException
{
try
{
send( FCDCommand.APP_SET_LNA_GAIN, enabled ? 1 : 0 );
}
catch ( Exception e )
{
throw new SourceException( "error while setting LNA Gain", e );
}
}
public void setMixerGain( boolean enabled ) throws SourceException
{
try
{
send( FCDCommand.APP_SET_MIXER_GAIN, enabled ? 1 : 0 );
}
catch ( Exception e )
{
throw new SourceException( "error while setting Mixer Gain", e );
}
}
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
if( config instanceof FCD2TunerConfiguration )
{
FCD2TunerConfiguration plusConfig =
(FCD2TunerConfiguration)config;
FCD2TunerConfiguration fcd2 = (FCD2TunerConfiguration)config;
setFrequencyCorrection( plusConfig.getFrequencyCorrection() );
try
{
if( plusConfig.getGainLNA() )
{
send( FCDCommand.APP_SET_LNA_GAIN, 1 );
}
else
{
send( FCDCommand.APP_SET_LNA_GAIN, 0 );
}
}
catch ( Exception e )
{
throw new SourceException( "error while setting LNA Gain", e );
}
try
{
if( plusConfig.getGainMixer() )
{
send( FCDCommand.APP_SET_MIXER_GAIN, 1 );
}
else
{
send( FCDCommand.APP_SET_MIXER_GAIN, 0 );
}
}
catch ( Exception e )
{
throw new SourceException( "error while setting Mixer Gain", e );
}
mTunerConfiguration = plusConfig;
setFrequencyCorrection( fcd2.getFrequencyCorrection() );
setLNAGain( fcd2.getGainLNA() );
setMixerGain( fcd2.getGainMixer() );
}
}
@Override
public TunerConfiguration getTunerConfiguration()
{
return mTunerConfiguration;
}
public int getDCCorrection()
{
int dcCorrection = -999;

View File

@@ -0,0 +1,327 @@
/*******************************************************************************
* 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.fcd.proplusV2;
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.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSeparator;
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 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.fcd.FCDTuner;
public class FCD2TunerEditor extends TunerConfigurationEditor
{
private final static Logger mLog = LoggerFactory.getLogger( FCD2TunerEditor.class );
private static final long serialVersionUID = 1L;
private JTextField mConfigurationName;
private JButton mTunerInfo;
private JSpinner mFrequencyCorrection;
private JCheckBox mLNAGain;
private JCheckBox mMixerGain;
private boolean mLoading;
private FCD2TunerController mController;
public FCD2TunerEditor( TunerConfigurationModel tunerConfigurationModel, FCDTuner tuner )
{
super( tunerConfigurationModel );
mController = (FCD2TunerController)tuner.getController();
init();
}
private FCD2TunerConfiguration getConfiguration()
{
if( hasItem() )
{
return (FCD2TunerConfiguration)getItem();
}
return null;
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]",
"[][][][][][grow]" ) );
add( new JLabel( "FCD Pro+ 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( FCD2TunerEditor.this, getTunerInfo(),
"Tuner Info", JOptionPane.INFORMATION_MESSAGE );
}
} );
add( mTunerInfo );
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 )
{
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
try
{
mController.setFrequencyCorrection( value );
save();
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog( FCD2TunerEditor.this, "FCD Pro Plus Tuner "
+ "Controller - couldn't apply frequency correction value: " + value +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDongleProPlus Controller - couldn't apply "
+ "frequency correction value: " + value, e1 );
}
}
} );
add( new JLabel( "PPM:" ) );
add( mFrequencyCorrection, "wrap" );
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
mLNAGain = new JCheckBox( "LNA Gain" );
mLNAGain.setEnabled( false );
mLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent event )
{
try
{
mController.setLNAGain( mLNAGain.isSelected() );
save();
}
catch( SourceException e )
{
mLog.error( "Couldn't set LNA gain for FCD2", e );
}
}
} );
add( new JLabel( "" ) );
add( mLNAGain );
/**
* Mixer Gain
*/
mMixerGain = new JCheckBox( "Mixer Gain" );
mMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent event )
{
try
{
mController.setMixerGain( mMixerGain.isSelected() );
save();
}
catch( SourceException e )
{
mLog.error( "Couldn't set mixer gain for FCD2", e );
}
}
} );
add( new JLabel( "" ) );
add( mMixerGain );
}
/**
* 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( mLNAGain.isEnabled() != enabled )
{
mLNAGain.setEnabled( enabled );
}
if( mMixerGain.isEnabled() != enabled )
{
mMixerGain.setEnabled( enabled );
}
}
private String getTunerInfo()
{
StringBuilder sb = new StringBuilder();
sb.append( "<html><h3>Funcube Dongle Pro Plus Tuner</h3>" );
sb.append( "<b>USB ID: </b>" );
sb.append( mController.getUSBID() );
sb.append( "<br>" );
sb.append( "<b>USB Address: </b>" );
sb.append( mController.getUSBAddress() );
sb.append( "<br>" );
sb.append( "<b>USB Speed: </b>" );
sb.append( mController.getUSBSpeed() );
sb.append( "<br>" );
sb.append( "<b>Cellular Band: </b>" );
sb.append( mController.getConfiguration().getBandBlocking() );
sb.append( "<br>" );
sb.append( "<b>Firmware: </b>" );
sb.append( mController.getConfiguration().getFirmware() );
sb.append( "<br>" );
return sb.toString();
}
@Override
public void save()
{
if( hasItem() && !mLoading )
{
FCD2TunerConfiguration config = getConfiguration();
config.setName( mConfigurationName.getText() );
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
config.setFrequencyCorrection( value );
config.setGainLNA( mLNAGain.isSelected() );
config.setGainMixer( mMixerGain.isSelected() );
getTunerConfigurationModel().broadcast(
new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
}
}
@Override
public void setItem( TunerConfiguration tunerConfiguration )
{
super.setItem( tunerConfiguration );
if( hasItem() )
{
FCD2TunerConfiguration 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() );
mLNAGain.setSelected( config.getGainLNA() );
mMixerGain.setSelected( config.getGainMixer() );
}
else
{
setControlsEnabled( false );
mConfigurationName.setText( config.getName() );
}
mLoading = false;
}
else
{
setControlsEnabled( false );
mConfigurationName.setText( "" );
}
}
}

View File

@@ -1,110 +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.fcd.proplusV2;
import gui.control.JFrequencyControl;
import java.awt.Color;
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.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerDetailsPanel;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
import com.jidesoft.swing.JideTabbedPane;
public class FCD2TunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
{
private final static Logger mLog =
LoggerFactory.getLogger( FCD2TunerEditorPanel.class );
private static final long serialVersionUID = 1L;
private FCDTuner mTuner;
private FCD2TunerController mController;
private SettingsManager mSettingsManager;
private JFrequencyControl mFrequencyControl;
public FCD2TunerEditorPanel( FCDTuner tuner, SettingsManager settingsManager )
{
mTuner = tuner;
mController = (FCD2TunerController)mTuner.getController();
mSettingsManager = settingsManager;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
add( new JLabel( "Funcube Dongle Pro Plus Tuner" ), "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 );
tabs.add( "Configuration", new FCD2TunerConfigurationPanel(
mSettingsManager, mController ) );
tabs.add( "Info", new FCDTunerDetailsPanel( mController ) );
add( tabs, "span,grow,push" );
}
@Override
public void frequencyChanged( FrequencyChangeEvent event )
{
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
{
//Disregard the bandwidth, which shouldn't be changing
try
{
mController.setFrequency( event.getValue().longValue() );
}
catch ( SourceException e )
{
mLog.error( "FCDProController - error setting frequency [" +
event.getValue().longValue() + "]", e );
}
}
}
}