set backend-specific min/max/default values when backend is selected

This commit is contained in:
Michael Ossmann 2017-02-11 22:24:44 -07:00
parent dc39b44c67
commit 3cc202de89
3 changed files with 77 additions and 16 deletions

View File

@ -185,13 +185,74 @@ class QSpectrumAnalyzerMainWindow(QtGui.QMainWindow, Ui_QSpectrumAnalyzerMainWin
backend = settings.value("backend", "rtl_power")
if backend == "rtl_power_fftw":
self.gainSpinBox.setMinimum(-1)
self.gainSpinBox.setMaximum(49)
self.gainSpinBox.setValue(-1)
self.startFreqSpinBox.setMinimum(24)
self.startFreqSpinBox.setMaximum(1766)
self.startFreqSpinBox.setValue(87)
self.stopFreqSpinBox.setMinimum(24)
self.stopFreqSpinBox.setMaximum(1766)
self.stopFreqSpinBox.setValue(108)
self.binSizeSpinBox.setMinimum(0)
self.binSizeSpinBox.setMaximum(2800)
self.binSizeSpinBox.setValue(10)
self.intervalSpinBox.setMinimum(0)
self.intervalSpinBox.setMaximum(999)
self.intervalSpinBox.setValue(10)
self.ppmSpinBox.setMinimum(-999)
self.ppmSpinBox.setMaximum(999)
self.ppmSpinBox.setValue(0)
self.cropSpinBox.setMinimum(0)
self.cropSpinBox.setMaximum(99)
self.cropSpinBox.setValue(0)
self.rtl_power_thread = RtlPowerFftwThread(self.data_storage)
elif backend == "hackrf_sweep":
self.gainSpinBox.setMinimum(0)
self.gainSpinBox.setMaximum(102)
self.gainSpinBox.setValue(40)
self.startFreqSpinBox.setMinimum(0)
self.startFreqSpinBox.setMaximum(7230)
self.startFreqSpinBox.setValue(0)
self.stopFreqSpinBox.setMinimum(0)
self.stopFreqSpinBox.setMaximum(7250)
self.stopFreqSpinBox.setValue(6000)
self.binSizeSpinBox.setMinimum(40)
self.binSizeSpinBox.setMaximum(5000)
self.binSizeSpinBox.setValue(1000)
self.intervalSpinBox.setMinimum(0)
self.intervalSpinBox.setMaximum(0)
self.intervalSpinBox.setValue(0)
self.ppmSpinBox.setMinimum(0)
self.ppmSpinBox.setMaximum(0)
self.ppmSpinBox.setValue(0)
self.cropSpinBox.setMinimum(0)
self.cropSpinBox.setMaximum(0)
self.cropSpinBox.setValue(0)
self.rtl_power_thread = HackRFSweepThread(self.data_storage)
print(self.rtl_power_thread)
else:
self.gainSpinBox.setMinimum(-1)
self.gainSpinBox.setMaximum(49)
self.gainSpinBox.setValue(-1)
self.startFreqSpinBox.setMinimum(24)
self.startFreqSpinBox.setMaximum(1766)
self.startFreqSpinBox.setValue(87)
self.stopFreqSpinBox.setMinimum(24)
self.stopFreqSpinBox.setMaximum(1766)
self.stopFreqSpinBox.setValue(108)
self.binSizeSpinBox.setMinimum(0)
self.binSizeSpinBox.setMaximum(2800)
self.binSizeSpinBox.setValue(10)
self.intervalSpinBox.setMinimum(0)
self.intervalSpinBox.setMaximum(999)
self.intervalSpinBox.setValue(10)
self.ppmSpinBox.setMinimum(-999)
self.ppmSpinBox.setMaximum(999)
self.ppmSpinBox.setValue(0)
self.cropSpinBox.setMinimum(0)
self.cropSpinBox.setMaximum(99)
self.cropSpinBox.setValue(0)
self.rtl_power_thread = RtlPowerThread(self.data_storage)
self.rtl_power_thread.rtlPowerStarted.connect(self.update_buttons)
@ -225,9 +286,9 @@ class QSpectrumAnalyzerMainWindow(QtGui.QMainWindow, Ui_QSpectrumAnalyzerMainWin
def load_settings(self):
"""Restore spectrum analyzer settings and window geometry"""
settings = QtCore.QSettings()
self.startFreqSpinBox.setValue(settings.value("start_freq", 88.0, float))
self.startFreqSpinBox.setValue(settings.value("start_freq", 87.0, float))
self.stopFreqSpinBox.setValue(settings.value("stop_freq", 108.0, float))
self.binSizeSpinBox.setValue(settings.value("bin_size", 100.0, float))
self.binSizeSpinBox.setValue(settings.value("bin_size", 10.0, float))
self.intervalSpinBox.setValue(settings.value("interval", 10.0, float))
self.gainSpinBox.setValue(settings.value("gain", 0, int))
self.ppmSpinBox.setValue(settings.value("ppm", 0, int))

View File

@ -189,13 +189,13 @@
<number>3</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
<double>24.000000000000000</double>
</property>
<property name="maximum">
<double>6000.000000000000000</double>
<double>1766.000000000000000</double>
</property>
<property name="value">
<double>88.000000000000000</double>
<double>87.000000000000000</double>
</property>
</widget>
</item>
@ -227,10 +227,10 @@
<number>3</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
<double>24.000000000000000</double>
</property>
<property name="maximum">
<double>6000.000000000000000</double>
<double>1766.000000000000000</double>
</property>
<property name="value">
<double>108.000000000000000</double>
@ -265,10 +265,10 @@
<number>3</number>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
<double>2800.000000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
<double>10.000000000000000</double>
</property>
</widget>
</item>

View File

@ -116,9 +116,9 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.startFreqSpinBox.setSizePolicy(sizePolicy)
self.startFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.startFreqSpinBox.setDecimals(3)
self.startFreqSpinBox.setMinimum(0.0)
self.startFreqSpinBox.setMaximum(6000.0)
self.startFreqSpinBox.setProperty("value", 88.0)
self.startFreqSpinBox.setMinimum(24.0)
self.startFreqSpinBox.setMaximum(1766.0)
self.startFreqSpinBox.setProperty("value", 87.0)
self.startFreqSpinBox.setObjectName(_fromUtf8("startFreqSpinBox"))
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.startFreqSpinBox)
self.label_3 = QtGui.QLabel(self.frequencyDockWidgetContents)
@ -132,8 +132,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.stopFreqSpinBox.setSizePolicy(sizePolicy)
self.stopFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.stopFreqSpinBox.setDecimals(3)
self.stopFreqSpinBox.setMinimum(0.0)
self.stopFreqSpinBox.setMaximum(6000.0)
self.stopFreqSpinBox.setMinimum(24.0)
self.stopFreqSpinBox.setMaximum(1766.0)
self.stopFreqSpinBox.setProperty("value", 108.0)
self.stopFreqSpinBox.setObjectName(_fromUtf8("stopFreqSpinBox"))
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.stopFreqSpinBox)
@ -148,8 +148,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.binSizeSpinBox.setSizePolicy(sizePolicy)
self.binSizeSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.binSizeSpinBox.setDecimals(3)
self.binSizeSpinBox.setMaximum(5000.0)
self.binSizeSpinBox.setProperty("value", 100.0)
self.binSizeSpinBox.setMaximum(2800.0)
self.binSizeSpinBox.setProperty("value", 10.0)
self.binSizeSpinBox.setObjectName(_fromUtf8("binSizeSpinBox"))
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.binSizeSpinBox)
spacerItem1 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)