mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 18:47:33 -05:00
Airspy controller - changes method for adjusting center tuned frequency
when tuner channels are allocated by the airspy. New method determines the min/max requested frequency range and sets tuner center to the center of that range, while limiting the total usable bandwidth to 90% of the bandwidth, to account for rolloff of 5% at the upper/lower edges. When a new channel is requested, if the channel fits within the current center frequency and usable bandwidth, the center tune frequency is not adjusted, to minimize the number of retunes on a busy system.
This commit is contained in:
@@ -714,7 +714,7 @@ public class Channel extends Configuration
|
|||||||
}
|
}
|
||||||
catch( SourceException se )
|
catch( SourceException se )
|
||||||
{
|
{
|
||||||
mLog.info( "Couldn't obtain source for channel [" + mName + "]" );
|
//Do nothing, we couldn't get a source for the channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public abstract class TunerController implements Tunable
|
|||||||
|
|
||||||
public long getMinTunedFrequency()
|
public long getMinTunedFrequency()
|
||||||
{
|
{
|
||||||
return mFrequencyController.getFrequency() -
|
return mFrequencyController.getFrequency() -
|
||||||
( mFrequencyController.getBandwidth() / 2 );
|
( mFrequencyController.getBandwidth() / 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ public class AirspyTunerController extends TunerController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the tuner can accomodate this new channel frequency and
|
* Indicates if the tuner can accommodate this new channel frequency and
|
||||||
* bandwidth, along with all of the existing tuned channels currently in
|
* bandwidth, along with all of the existing tuned channels currently in
|
||||||
* place.
|
* place.
|
||||||
*/
|
*/
|
||||||
@@ -857,20 +857,49 @@ public class AirspyTunerController extends TunerController
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usable = getUsableBandwidth();
|
||||||
|
|
||||||
if( channel.getMinFrequency() < minLockedFrequency )
|
if( channel.getMinFrequency() < minLockedFrequency )
|
||||||
{
|
{
|
||||||
return ( maxLockedFrequency - channel.getMinFrequency() ) < getBandwidth() - 1E5;
|
return ( maxLockedFrequency - channel.getMinFrequency() ) <= usable;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( channel.getMaxFrequency() > maxLockedFrequency )
|
if( channel.getMaxFrequency() > maxLockedFrequency )
|
||||||
{
|
{
|
||||||
return ( channel.getMaxFrequency() - minLockedFrequency ) <= getBandwidth() - 1E5;
|
return ( channel.getMaxFrequency() - minLockedFrequency ) <= usable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limits the usable bandwidth of the tuner to 90% of the bandwidth to
|
||||||
|
* account for roll-off at the band edges
|
||||||
|
*/
|
||||||
|
private int getUsableBandwidth()
|
||||||
|
{
|
||||||
|
return (int)( (double)getBandwidth() * 0.9d );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides the default tuner controller method to limit the total bandwidth
|
||||||
|
* of the tuner to 90% and adjust the min tuned frequency accordingly
|
||||||
|
*/
|
||||||
|
public long getMinTunedFrequency()
|
||||||
|
{
|
||||||
|
return mFrequencyController.getFrequency() - ( getUsableBandwidth() / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides the default tuner controller method to limit the total bandwidth
|
||||||
|
* of the tuner to 90% and adjust the max tuned frequency accordingly
|
||||||
|
*/
|
||||||
|
public long getMaxTunedFrequency()
|
||||||
|
{
|
||||||
|
return mFrequencyController.getFrequency() + ( getUsableBandwidth() / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
public TunerChannelSource getChannel( ThreadPoolManager threadPoolManager,
|
public TunerChannelSource getChannel( ThreadPoolManager threadPoolManager,
|
||||||
Tuner tuner, TunerChannel tunerChannel )
|
Tuner tuner, TunerChannel tunerChannel )
|
||||||
@@ -886,11 +915,12 @@ public class AirspyTunerController extends TunerController
|
|||||||
|
|
||||||
long min = mTunedChannels.get( 0 ).getMinFrequency();
|
long min = mTunedChannels.get( 0 ).getMinFrequency();
|
||||||
long max = mTunedChannels.get( mTunedChannels.size() - 1 ).getMaxFrequency();
|
long max = mTunedChannels.get( mTunedChannels.size() - 1 ).getMaxFrequency();
|
||||||
|
|
||||||
if( !( getMinTunedFrequency() <= min &&
|
/* Adjust the center frequency if the set of tuner channels don't
|
||||||
max <= getMaxTunedFrequency() ) )
|
* currently fit within the usable bandwidth and current center frequency */
|
||||||
|
if( !( getMinTunedFrequency() <= min && max <= getMaxTunedFrequency() ) )
|
||||||
{
|
{
|
||||||
long freq = min + ( mFrequencyController.getBandwidth() / 2 ) + 50000;
|
long freq = min + ( ( max - min ) / 2 );
|
||||||
|
|
||||||
mFrequencyController.setFrequency( freq );
|
mFrequencyController.setFrequency( freq );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user