mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -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:
@@ -114,7 +114,7 @@ public abstract class TunerController implements Tunable
|
||||
|
||||
public long getMinTunedFrequency()
|
||||
{
|
||||
return mFrequencyController.getFrequency() -
|
||||
return mFrequencyController.getFrequency() -
|
||||
( 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
|
||||
* place.
|
||||
*/
|
||||
@@ -857,20 +857,49 @@ public class AirspyTunerController extends TunerController
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int usable = getUsableBandwidth();
|
||||
|
||||
if( channel.getMinFrequency() < minLockedFrequency )
|
||||
{
|
||||
return ( maxLockedFrequency - channel.getMinFrequency() ) < getBandwidth() - 1E5;
|
||||
return ( maxLockedFrequency - channel.getMinFrequency() ) <= usable;
|
||||
}
|
||||
|
||||
if( channel.getMaxFrequency() > maxLockedFrequency )
|
||||
{
|
||||
return ( channel.getMaxFrequency() - minLockedFrequency ) <= getBandwidth() - 1E5;
|
||||
return ( channel.getMaxFrequency() - minLockedFrequency ) <= usable;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
Tuner tuner, TunerChannel tunerChannel )
|
||||
@@ -886,11 +915,12 @@ public class AirspyTunerController extends TunerController
|
||||
|
||||
long min = mTunedChannels.get( 0 ).getMinFrequency();
|
||||
long max = mTunedChannels.get( mTunedChannels.size() - 1 ).getMaxFrequency();
|
||||
|
||||
if( !( getMinTunedFrequency() <= min &&
|
||||
max <= getMaxTunedFrequency() ) )
|
||||
|
||||
/* Adjust the center frequency if the set of tuner channels don't
|
||||
* 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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user