From 55443b42f3423a0afdca688b4ca6649e9a67ecaf Mon Sep 17 00:00:00 2001 From: denny Date: Sun, 27 Mar 2016 07:25:17 -0400 Subject: [PATCH] wip #34 - resolved issue with airspy correctly loading stored tuner configuration values. Updated remaining tuner editors to set loading flag when loading tuner configuration and turn off after loading is complete. --- .../tuner/airspy/AirspyTunerEditor.java | 53 +++++++++++++++++-- .../tuner/fcd/proV1/FCD1TunerEditor.java | 10 ++-- .../tuner/fcd/proplusV2/FCD2TunerEditor.java | 9 ++-- .../tuner/hackrf/HackRFTunerEditor.java | 10 ++-- src/source/tuner/rtl/e4k/E4KTunerEditor.java | 10 ++-- .../tuner/rtl/r820t/R820TTunerEditor.java | 10 ++-- 6 files changed, 75 insertions(+), 27 deletions(-) diff --git a/src/source/tuner/airspy/AirspyTunerEditor.java b/src/source/tuner/airspy/AirspyTunerEditor.java index ee034ca3..10e1e567 100644 --- a/src/source/tuner/airspy/AirspyTunerEditor.java +++ b/src/source/tuner/airspy/AirspyTunerEditor.java @@ -432,6 +432,8 @@ public class AirspyTunerEditor extends TunerConfigurationEditor try { mController.setMixerAGC( mMixerAGC.isSelected() ); + mMixerGain.setEnabled( !mMixerAGC.isSelected() ); + save(); } catch ( Exception e1 ) @@ -452,6 +454,8 @@ public class AirspyTunerEditor extends TunerConfigurationEditor try { mController.setLNAAGC( mLNAAGC.isSelected() ); + mLNAGain.setEnabled( !mLNAAGC.isSelected() ); + save(); } catch ( Exception e1 ) @@ -563,15 +567,16 @@ public class AirspyTunerEditor extends TunerConfigurationEditor double value = ((SpinnerNumberModel)mFrequencyCorrection.getModel()).getNumber().doubleValue(); config.setFrequencyCorrection( value ); - config.setGain( Gain.getGain( (GainMode)mGainModeCombo.getSelectedItem(), mMasterGain.getValue() ) ); + Gain gain = Gain.getGain( (GainMode)mGainModeCombo.getSelectedItem(), mMasterGain.getValue() ); + + config.setGain( gain ); config.setIFGain( mIFGain.getValue() ); config.setMixerGain( mMixerGain.getValue() ); config.setLNAGain( mLNAGain.getValue() ); config.setMixerAGC( mMixerAGC.isSelected() ); config.setLNAAGC( mLNAAGC.isSelected() ); - getTunerConfigurationModel().broadcast( - new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) ); + getTunerConfigurationModel().broadcast( new TunerConfigurationEvent( config, Event.CHANGE ) ); } } @@ -665,6 +670,8 @@ public class AirspyTunerEditor extends TunerConfigurationEditor { super.setItem( config ); + mLoading = true; + if( hasItem() && getItem().isAssigned() ) { AirspyTunerConfiguration airspy = getConfiguration(); @@ -686,12 +693,52 @@ public class AirspyTunerEditor extends TunerConfigurationEditor //This will set the master, IF, Mixer, LNA and AGC controls mGainModeCombo.setSelectedItem( mode ); + + if( mode == GainMode.CUSTOM ) + { + mMasterGain.setValue( airspy.getGain().getValue() ); + mIFGain.setValue( airspy.getIFGain() ); + + if( airspy.isMixerAGC() ) + { + mMixerAGC.setSelected( airspy.isMixerAGC() ); + mMixerGain.setEnabled( false ); + } + else + { + mMixerGain.setValue( airspy.getMixerGain() ); + } + + if( airspy.isLNAAGC() ) + { + mLNAAGC.setSelected( airspy.isLNAAGC() ); + mLNAGain.setEnabled( false ); + } + else + { + mLNAGain.setValue( airspy.getLNAGain() ); + } + } + else + { + mMixerAGC.setSelected( false ); + mLNAAGC.setSelected( false ); + + Gain gain = airspy.getGain(); + + mMasterGain.setValue( gain.getValue() ); + mIFGain.setValue( gain.getIF() ); + mMixerGain.setValue( gain.getMixer() ); + mLNAGain.setValue( gain.getLNA() ); + } } else { setControlsEnabled( false ); mConfigurationName.setText( hasItem() ? getItem().getName() : "" ); } + + mLoading = false; } private String getTunerInfo() diff --git a/src/source/tuner/fcd/proV1/FCD1TunerEditor.java b/src/source/tuner/fcd/proV1/FCD1TunerEditor.java index bd8ef493..5c8f834b 100644 --- a/src/source/tuner/fcd/proV1/FCD1TunerEditor.java +++ b/src/source/tuner/fcd/proV1/FCD1TunerEditor.java @@ -425,13 +425,13 @@ public class FCD1TunerEditor extends TunerConfigurationEditor { super.setItem( tunerConfiguration ); + //Toggle loading so that we don't fire a change event and schedule a settings file save + mLoading = true; + if( hasItem() ) { FCD1TunerConfiguration 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 ); @@ -450,14 +450,14 @@ public class FCD1TunerEditor extends TunerConfigurationEditor setControlsEnabled( false ); mConfigurationName.setText( config.getName() ); } - - mLoading = false; } else { setControlsEnabled( false ); mConfigurationName.setText( "" ); } + + mLoading = false; } public enum Correction { GAIN, PHASE, DC_INPHASE, DC_QUADRATURE }; diff --git a/src/source/tuner/fcd/proplusV2/FCD2TunerEditor.java b/src/source/tuner/fcd/proplusV2/FCD2TunerEditor.java index d358c46f..1e0ab570 100644 --- a/src/source/tuner/fcd/proplusV2/FCD2TunerEditor.java +++ b/src/source/tuner/fcd/proplusV2/FCD2TunerEditor.java @@ -295,12 +295,13 @@ public class FCD2TunerEditor extends TunerConfigurationEditor { super.setItem( tunerConfiguration ); + //Toggle loading so that we don't fire a change event and schedule a settings file save + mLoading = true; + 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() ) { @@ -315,13 +316,13 @@ public class FCD2TunerEditor extends TunerConfigurationEditor setControlsEnabled( false ); mConfigurationName.setText( config.getName() ); } - - mLoading = false; } else { setControlsEnabled( false ); mConfigurationName.setText( "" ); } + + mLoading = false; } } diff --git a/src/source/tuner/hackrf/HackRFTunerEditor.java b/src/source/tuner/hackrf/HackRFTunerEditor.java index 81542ef5..1b0095d1 100644 --- a/src/source/tuner/hackrf/HackRFTunerEditor.java +++ b/src/source/tuner/hackrf/HackRFTunerEditor.java @@ -407,13 +407,13 @@ public class HackRFTunerEditor extends TunerConfigurationEditor { super.setItem( tunerConfiguration ); + //Toggle loading so that we don't fire a change event and schedule a settings file save + mLoading = true; + 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 ); @@ -430,14 +430,14 @@ public class HackRFTunerEditor extends TunerConfigurationEditor setControlsEnabled( false ); mConfigurationName.setText( config.getName() ); } - - mLoading = false; } else { setControlsEnabled( false ); mConfigurationName.setText( "" ); } + + mLoading = false; } @Override diff --git a/src/source/tuner/rtl/e4k/E4KTunerEditor.java b/src/source/tuner/rtl/e4k/E4KTunerEditor.java index 1ea51265..5989fdf2 100644 --- a/src/source/tuner/rtl/e4k/E4KTunerEditor.java +++ b/src/source/tuner/rtl/e4k/E4KTunerEditor.java @@ -463,13 +463,13 @@ public class E4KTunerEditor extends TunerConfigurationEditor { super.setItem( tunerConfiguration ); + //Toggle loading so that we don't fire a change event and schedule a settings file save + mLoading = true; + 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 ); @@ -487,13 +487,13 @@ public class E4KTunerEditor extends TunerConfigurationEditor setControlsEnabled( false ); mConfigurationName.setText( config.getName() ); } - - mLoading = false; } else { setControlsEnabled( false ); mConfigurationName.setText( "" ); } + + mLoading = false; } } diff --git a/src/source/tuner/rtl/r820t/R820TTunerEditor.java b/src/source/tuner/rtl/r820t/R820TTunerEditor.java index 7c325eb0..0d55490c 100644 --- a/src/source/tuner/rtl/r820t/R820TTunerEditor.java +++ b/src/source/tuner/rtl/r820t/R820TTunerEditor.java @@ -524,13 +524,13 @@ public class R820TTunerEditor extends TunerConfigurationEditor { super.setItem( tunerConfiguration ); + //Toggle loading so that we don't fire a change event and schedule a settings file save + mLoading = true; + 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 ); @@ -547,13 +547,13 @@ public class R820TTunerEditor extends TunerConfigurationEditor setControlsEnabled( false ); mConfigurationName.setText( config.getName() ); } - - mLoading = false; } else { setControlsEnabled( false ); mConfigurationName.setText( "" ); } + + mLoading = false; } }