mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-19 20:17:25 -05:00
Frequency limit for Automatic Frequency Control to prevent the controller from walking too far.
Defaults to a maximum of 3kHz, but can be set to as high as 15 kHz.
This commit is contained in:
@@ -376,7 +376,11 @@ public class ProcessingChain implements Listener<Message>
|
|||||||
{
|
{
|
||||||
TunerChannelSource tcs = (TunerChannelSource)mSource;
|
TunerChannelSource tcs = (TunerChannelSource)mSource;
|
||||||
|
|
||||||
mAFC = new AutomaticFrequencyControl( tcs );
|
int maximumCorrection = mChannel
|
||||||
|
.getDecodeConfiguration().getAFCMaximumCorrection();
|
||||||
|
|
||||||
|
mAFC = new AutomaticFrequencyControl( tcs,
|
||||||
|
maximumCorrection );
|
||||||
|
|
||||||
/* Register AFC to receive frequency change events */
|
/* Register AFC to receive frequency change events */
|
||||||
tcs.addListener( mAFC );
|
tcs.addListener( mAFC );
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SpinnerModel;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
import controller.Editor;
|
import controller.Editor;
|
||||||
import decode.config.DecodeConfiguration;
|
import decode.config.DecodeConfiguration;
|
||||||
@@ -32,6 +39,7 @@ public class DecodeEditor extends Editor
|
|||||||
protected DecodeConfiguration mConfig;
|
protected DecodeConfiguration mConfig;
|
||||||
|
|
||||||
protected JCheckBox mAFC;
|
protected JCheckBox mAFC;
|
||||||
|
protected JSpinner mAFCMaximumCorrection;
|
||||||
|
|
||||||
public DecodeEditor( DecodeConfiguration config )
|
public DecodeEditor( DecodeConfiguration config )
|
||||||
{
|
{
|
||||||
@@ -50,7 +58,41 @@ public class DecodeEditor extends Editor
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
add( mAFC, "wrap" );
|
mAFC.setToolTipText( "AFC automatically adjusts the center "
|
||||||
|
+ "frequency of the channel to correct/compensate for "
|
||||||
|
+ "inaccuracies and frequency drift in the tuner" );
|
||||||
|
|
||||||
|
add( mAFC, "span" );
|
||||||
|
|
||||||
|
int initial = mConfig.getAFCMaximumCorrection();
|
||||||
|
|
||||||
|
SpinnerModel model = new SpinnerNumberModel( initial, 0, 15000, 1 );
|
||||||
|
|
||||||
|
mAFCMaximumCorrection = new JSpinner( model );
|
||||||
|
|
||||||
|
JSpinner.NumberEditor editor =
|
||||||
|
(JSpinner.NumberEditor)mAFCMaximumCorrection.getEditor();
|
||||||
|
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
||||||
|
|
||||||
|
mAFCMaximumCorrection.setToolTipText( "Sets the maximum frequency "
|
||||||
|
+ "correction value in hertz, 0 - 15kHz" );
|
||||||
|
|
||||||
|
mAFCMaximumCorrection.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
int value = ((SpinnerNumberModel)mAFCMaximumCorrection
|
||||||
|
.getModel()).getNumber().intValue();
|
||||||
|
|
||||||
|
mConfig.setAFCMaximumCorrection( value );
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( mAFCMaximumCorrection );
|
||||||
|
add( new JLabel( "Correction Limit Hz" ), "growx, push" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,14 +104,12 @@ public class DecodeEditor extends Editor
|
|||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public abstract class DecodeConfiguration extends Configuration
|
|||||||
{
|
{
|
||||||
private DecoderType mDecoderType = DecoderType.NBFM;
|
private DecoderType mDecoderType = DecoderType.NBFM;
|
||||||
private boolean mAFCEnabled = true;
|
private boolean mAFCEnabled = true;
|
||||||
|
private int mAFCMaxCorrection = 3000;
|
||||||
|
|
||||||
public DecodeConfiguration()
|
public DecodeConfiguration()
|
||||||
{
|
{
|
||||||
@@ -67,6 +68,16 @@ public abstract class DecodeConfiguration extends Configuration
|
|||||||
mAFCEnabled = enabled;
|
mAFCEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAFCMaximumCorrection()
|
||||||
|
{
|
||||||
|
return mAFCMaxCorrection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAFCMaximumCorrection( int max )
|
||||||
|
{
|
||||||
|
mAFCMaxCorrection = max;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean supportsAFC()
|
public boolean supportsAFC()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
|
|||||||
private int mSkipThreshold = 4;
|
private int mSkipThreshold = 4;
|
||||||
private int mErrorCorrection = 0;
|
private int mErrorCorrection = 0;
|
||||||
private long mCurrentFrequency;
|
private long mCurrentFrequency;
|
||||||
|
private int mMaximumCorrection;
|
||||||
private FrequencyChangeListener mListener;
|
private FrequencyChangeListener mListener;
|
||||||
|
|
||||||
public enum Mode
|
public enum Mode
|
||||||
@@ -31,9 +32,11 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
|
|||||||
NORMAL,FAST;
|
NORMAL,FAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutomaticFrequencyControl( FrequencyChangeListener listener )
|
public AutomaticFrequencyControl( FrequencyChangeListener listener,
|
||||||
|
int maximumCorrection )
|
||||||
{
|
{
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
mMaximumCorrection = maximumCorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
@@ -150,6 +153,14 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
|
|||||||
if( correction != 0 )
|
if( correction != 0 )
|
||||||
{
|
{
|
||||||
mErrorCorrection -= correction;
|
mErrorCorrection -= correction;
|
||||||
|
|
||||||
|
if( Math.abs( mErrorCorrection ) > mMaximumCorrection )
|
||||||
|
{
|
||||||
|
mErrorCorrection = ( mErrorCorrection < 0 ) ?
|
||||||
|
-mMaximumCorrection :
|
||||||
|
mMaximumCorrection;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch();
|
dispatch();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -135,10 +135,6 @@ public abstract class TunerController implements Tunable
|
|||||||
long maxLockedFrequency = mTunedChannels
|
long maxLockedFrequency = mTunedChannels
|
||||||
.get( mTunedChannels.size() - 1 ).getMaxFrequency();
|
.get( mTunedChannels.size() - 1 ).getMaxFrequency();
|
||||||
|
|
||||||
mLog.debug( "Tuner Controller min [" + minLockedFrequency +
|
|
||||||
"] max [" + maxLockedFrequency +
|
|
||||||
"] bw [" + getBandwidth() + "]" );
|
|
||||||
|
|
||||||
//Requested channel is higher than min locked frequency
|
//Requested channel is higher than min locked frequency
|
||||||
if( minLockedFrequency <= channel.getMinFrequency() &&
|
if( minLockedFrequency <= channel.getMinFrequency() &&
|
||||||
( channel.getMaxFrequency() - minLockedFrequency ) <= getBandwidth() )
|
( channel.getMaxFrequency() - minLockedFrequency ) <= getBandwidth() )
|
||||||
|
|||||||
Reference in New Issue
Block a user