mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 11:07:35 -05:00
Adds capability to persist spectral display fft size and frame rate
between sessions.
This commit is contained in:
@@ -82,12 +82,9 @@ public class SystemProperties
|
|||||||
{
|
{
|
||||||
out = new FileOutputStream( propsPath.toString() );
|
out = new FileOutputStream( propsPath.toString() );
|
||||||
|
|
||||||
String comments =
|
String comments = "SDRTrunk - SDR Trunking Decoder Application Settings";
|
||||||
"SDRTrunk - SDR Trunking Decoder Application Settings";
|
|
||||||
|
|
||||||
mProperties.store( out, comments );
|
mProperties.store( out, comments );
|
||||||
|
|
||||||
mLog.info( "saved current properties [" + propsPath.toString() + "]" );
|
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jtransforms.fft.FloatFFT_1D;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import properties.SystemProperties;
|
||||||
import sample.Buffer;
|
import sample.Buffer;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
@@ -61,6 +62,8 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
private ScheduledExecutorService mScheduler = Executors
|
private ScheduledExecutorService mScheduler = Executors
|
||||||
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
|
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
|
||||||
|
|
||||||
|
public static final String FRAME_RATE_PROPERTY = "spectral.display.frame.rate";
|
||||||
|
|
||||||
private DFTSize mDFTSize = DFTSize.FFT04096;
|
private DFTSize mDFTSize = DFTSize.FFT04096;
|
||||||
private DFTSize mNewDFTSize = DFTSize.FFT04096;
|
private DFTSize mNewDFTSize = DFTSize.FFT04096;
|
||||||
|
|
||||||
@@ -89,7 +92,16 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
public DFTProcessor( SampleType sampleType )
|
public DFTProcessor( SampleType sampleType )
|
||||||
{
|
{
|
||||||
setSampleType( sampleType );
|
setSampleType( sampleType );
|
||||||
setFrameRate( 20 );
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSettings()
|
||||||
|
{
|
||||||
|
int frameRate = SystemProperties.getInstance()
|
||||||
|
.get( DFTProcessor.FRAME_RATE_PROPERTY, 20 );
|
||||||
|
|
||||||
|
setFrameRate( frameRate );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
@@ -171,6 +183,10 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
|
|
||||||
mFrameRate = framesPerSecond;
|
mFrameRate = framesPerSecond;
|
||||||
|
|
||||||
|
SystemProperties properties = SystemProperties.getInstance();
|
||||||
|
properties.set( FRAME_RATE_PROPERTY, String.valueOf( mFrameRate ) );
|
||||||
|
properties.save();
|
||||||
|
|
||||||
calculateConsumptionRate();
|
calculateConsumptionRate();
|
||||||
|
|
||||||
restart();
|
restart();
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
|
import properties.SystemProperties;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
@@ -99,9 +100,11 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
|
|
||||||
private static DecimalFormat sCURSOR_FORMAT = new DecimalFormat( "000.00000" );
|
private static DecimalFormat sCURSOR_FORMAT = new DecimalFormat( "000.00000" );
|
||||||
|
|
||||||
|
public static final String FFT_SIZE_PROPERTY = "spectral.display.dft.size";
|
||||||
public static final int NO_ZOOM = 0;
|
public static final int NO_ZOOM = 0;
|
||||||
public static final int MAX_ZOOM = 6;
|
public static final int MAX_ZOOM = 6;
|
||||||
|
|
||||||
|
|
||||||
private DFTSize mDFTSize = DFTSize.FFT04096;
|
private DFTSize mDFTSize = DFTSize.FFT04096;
|
||||||
private int mZoom = 0;
|
private int mZoom = 0;
|
||||||
private int mDFTZoomWindowOffset = 0;
|
private int mDFTZoomWindowOffset = 0;
|
||||||
@@ -150,6 +153,36 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSettings()
|
||||||
|
{
|
||||||
|
SystemProperties properties = SystemProperties.getInstance();
|
||||||
|
|
||||||
|
String rawSize = properties.get( FFT_SIZE_PROPERTY, DFTSize.FFT04096.name() );
|
||||||
|
|
||||||
|
DFTSize size = null;
|
||||||
|
|
||||||
|
if( rawSize != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
size = DFTSize.valueOf( rawSize );
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
//Do nothing, we couldn't parse the stored value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( size == null )
|
||||||
|
{
|
||||||
|
size = DFTSize.FFT04096;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDFTSize( size );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
@@ -195,6 +228,10 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
mOverlayPanel.setDFTSize( size );
|
mOverlayPanel.setDFTSize( size );
|
||||||
mDFTSize = size;
|
mDFTSize = size;
|
||||||
|
|
||||||
|
SystemProperties properties = SystemProperties.getInstance();
|
||||||
|
properties.set( FFT_SIZE_PROPERTY, size.name() );
|
||||||
|
properties.save();
|
||||||
|
|
||||||
setZoom( 0, 0, 0 );
|
setZoom( 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
|
|||||||
mMemoryImageSource.setAnimated( true );
|
mMemoryImageSource.setAnimated( true );
|
||||||
|
|
||||||
mWaterfallImage = createImage( mMemoryImageSource );
|
mWaterfallImage = createImage( mMemoryImageSource );
|
||||||
|
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user