Allow setting gain with more precision; tune default parameters of backends

This commit is contained in:
Michal Krenek (Mikos) 2017-03-24 16:51:32 +01:00
parent 87585c106b
commit 8109c537f6
11 changed files with 115 additions and 91 deletions

View File

@ -361,7 +361,7 @@ class QSpectrumAnalyzerMainWindow(QtWidgets.QMainWindow, Ui_QSpectrumAnalyzerMai
self.stopFreqSpinBox.setValue(settings.value("stop_freq", 108.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.gainSpinBox.setValue(settings.value("gain", 0, float))
self.ppmSpinBox.setValue(settings.value("ppm", 0, int))
self.cropSpinBox.setValue(settings.value("crop", 0, int))
self.mainCurveCheckBox.setChecked(settings.value("main_curve", 1, int))
@ -477,7 +477,7 @@ class QSpectrumAnalyzerMainWindow(QtWidgets.QMainWindow, Ui_QSpectrumAnalyzerMai
float(self.stopFreqSpinBox.value()),
float(self.binSizeSpinBox.value()),
interval=float(self.intervalSpinBox.value()),
gain=int(self.gainSpinBox.value()),
gain=float(self.gainSpinBox.value()),
ppm=int(self.ppmSpinBox.value()),
crop=int(self.cropSpinBox.value()) / 100.0,
single_shot=single_shot,

View File

@ -12,20 +12,20 @@ class BaseInfo:
bandwidth_max = 0
bandwidth = 0
gain_min = -1
gain_max = 49
gain_max = 49.6
gain = 37
start_freq_min = 24
start_freq_min = 0
start_freq_max = 2200
start_freq = 87
stop_freq_min = 24
stop_freq_min = 0
stop_freq_max = 2200
stop_freq = 108
bin_size_min = 0
bin_size_max = 2800
bin_size = 10
interval_min = 0
interval_max = 999
interval = 10
interval_max = 3600
interval = 1
ppm_min = -999
ppm_max = 999
ppm = 0

View File

@ -24,6 +24,7 @@ class PowerThread(BasePowerThread):
"bin_size": bin_size,
"interval": interval,
"device": device,
"sample_rate": sample_rate,
"hops": 0,
"gain": gain,
"ppm": ppm,
@ -53,6 +54,8 @@ class PowerThread(BasePowerThread):
"-c", "{}".format(self.params["crop"])
])
if self.params["sample_rate"] > 0:
cmdline.extend(["-r", "{}M".format(self.params["sample_rate"] / 1e6)])
if self.params["gain"] >= 0:
cmdline.extend(["-g", "{}".format(self.params["gain"])])
if self.params["single_shot"]:

View File

@ -37,7 +37,7 @@ class PowerThread(BasePowerThread):
"interval": interval,
"hops": hops,
"time": interval / hops,
"gain": gain * 10,
"gain": int(gain * 10),
"ppm": ppm,
"crop": crop,
"overlap": overlap,

View File

@ -9,11 +9,16 @@ from qspectrumanalyzer.backends import BaseInfo, BasePowerThread
class Info(BaseInfo):
"""rx_power device metadata"""
sample_rate_min = 0
sample_rate_max = 61440000
sample_rate_max = 0
sample_rate = 0
start_freq_min = 0
start_freq_max = 6000
start_freq_max = 7250
stop_freq_min = 0
stop_freq_max = 6000
stop_freq_max = 7250
gain_min = -1
gain_max = 999
bin_size_min = 0
bin_size_max = 2800
class PowerThread(BasePowerThread):

View File

@ -34,9 +34,13 @@ class Info(BaseInfo):
bandwidth_min = 0
bandwidth_max = 61440000
start_freq_min = 0
start_freq_max = 6000
start_freq_max = 7250
stop_freq_min = 0
stop_freq_max = 6000
stop_freq_max = 7250
gain_min = -1
gain_max = 999
bin_size_min = 0
bin_size_max = 10000
additional_params = '--even --fft-window boxcar --remove-dc'
@classmethod

View File

@ -41,22 +41,22 @@
<context>
<name>QSpectrumAnalyzerMainWindow</name>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="301"/>
<location filename="../ui_qspectrumanalyzer.py" line="304"/>
<source>QSpectrumAnalyzer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="312"/>
<location filename="../ui_qspectrumanalyzer.py" line="315"/>
<source> MHz</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="314"/>
<location filename="../ui_qspectrumanalyzer.py" line="317"/>
<source> kHz</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="318"/>
<location filename="../ui_qspectrumanalyzer.py" line="332"/>
<source>auto</source>
<translation type="unfinished"></translation>
</message>
@ -71,122 +71,122 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="302"/>
<location filename="../ui_qspectrumanalyzer.py" line="305"/>
<source>&amp;File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="303"/>
<location filename="../ui_qspectrumanalyzer.py" line="306"/>
<source>&amp;Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="305"/>
<location filename="../ui_qspectrumanalyzer.py" line="308"/>
<source>&amp;Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="306"/>
<location filename="../ui_qspectrumanalyzer.py" line="309"/>
<source>S&amp;top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="307"/>
<location filename="../ui_qspectrumanalyzer.py" line="310"/>
<source>Si&amp;ngle shot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="309"/>
<location filename="../ui_qspectrumanalyzer.py" line="312"/>
<source>Start:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="311"/>
<location filename="../ui_qspectrumanalyzer.py" line="314"/>
<source>Stop:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="319"/>
<location filename="../ui_qspectrumanalyzer.py" line="321"/>
<source>Corr. [ppm]:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="320"/>
<location filename="../ui_qspectrumanalyzer.py" line="322"/>
<source>Crop [%]:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="321"/>
<location filename="../ui_qspectrumanalyzer.py" line="323"/>
<source>Main curve</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="322"/>
<location filename="../ui_qspectrumanalyzer.py" line="324"/>
<source>Colors...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="323"/>
<location filename="../ui_qspectrumanalyzer.py" line="325"/>
<source>Max. hold</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="324"/>
<location filename="../ui_qspectrumanalyzer.py" line="326"/>
<source>Min. hold</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="325"/>
<location filename="../ui_qspectrumanalyzer.py" line="327"/>
<source>Average</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="326"/>
<location filename="../ui_qspectrumanalyzer.py" line="328"/>
<source>Smoothing</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="329"/>
<location filename="../ui_qspectrumanalyzer.py" line="331"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="328"/>
<location filename="../ui_qspectrumanalyzer.py" line="330"/>
<source>Persistence</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="331"/>
<location filename="../ui_qspectrumanalyzer.py" line="334"/>
<source>&amp;Settings...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="332"/>
<location filename="../ui_qspectrumanalyzer.py" line="335"/>
<source>&amp;Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="333"/>
<location filename="../ui_qspectrumanalyzer.py" line="336"/>
<source>Ctrl+Q</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="334"/>
<location filename="../ui_qspectrumanalyzer.py" line="337"/>
<source>&amp;About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="313"/>
<location filename="../ui_qspectrumanalyzer.py" line="316"/>
<source>&amp;Bin size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="316"/>
<location filename="../ui_qspectrumanalyzer.py" line="319"/>
<source>&amp;Interval [s]:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="317"/>
<location filename="../ui_qspectrumanalyzer.py" line="320"/>
<source>&amp;Gain [dB]:</source>
<translation type="unfinished"></translation>
</message>
@ -201,22 +201,22 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="304"/>
<location filename="../ui_qspectrumanalyzer.py" line="307"/>
<source>Controls</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="308"/>
<location filename="../ui_qspectrumanalyzer.py" line="311"/>
<source>Frequency</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="315"/>
<location filename="../ui_qspectrumanalyzer.py" line="318"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui_qspectrumanalyzer.py" line="330"/>
<location filename="../ui_qspectrumanalyzer.py" line="333"/>
<source>Levels</source>
<translation type="unfinished"></translation>
</message>

View File

@ -143,7 +143,7 @@
</property>
<property name="minimumSize">
<size>
<width>182</width>
<width>197</width>
<height>166</height>
</size>
</property>
@ -192,10 +192,10 @@
<number>3</number>
</property>
<property name="minimum">
<double>24.000000000000000</double>
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1766.000000000000000</double>
<double>2200.000000000000000</double>
</property>
<property name="value">
<double>87.000000000000000</double>
@ -233,10 +233,10 @@
<number>3</number>
</property>
<property name="minimum">
<double>24.000000000000000</double>
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1766.000000000000000</double>
<double>2200.000000000000000</double>
</property>
<property name="value">
<double>108.000000000000000</double>
@ -273,8 +273,11 @@
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>2800.000000000000000</double>
<double>10000.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
@ -348,25 +351,6 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QSpinBox" name="gainSpinBox">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>auto</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>49</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@ -492,6 +476,31 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="gainSpinBox">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>auto</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>999.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -573,8 +582,8 @@
<tabstop>persistenceCheckBox</tabstop>
<tabstop>persistenceButton</tabstop>
<tabstop>histogramPlotLayout</tabstop>
<tabstop>mainPlotLayout</tabstop>
<tabstop>waterfallPlotLayout</tabstop>
<tabstop>mainPlotLayout</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@ -220,7 +220,7 @@
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>61.439999999999998</double>
<double>999999.989999999990687</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
@ -245,7 +245,7 @@
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>61.439999999999998</double>
<double>999999.989999999990687</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>

View File

@ -84,7 +84,7 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frequencyDockWidget.sizePolicy().hasHeightForWidth())
self.frequencyDockWidget.setSizePolicy(sizePolicy)
self.frequencyDockWidget.setMinimumSize(QtCore.QSize(182, 166))
self.frequencyDockWidget.setMinimumSize(QtCore.QSize(197, 166))
self.frequencyDockWidget.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable|QtWidgets.QDockWidget.DockWidgetMovable)
self.frequencyDockWidget.setObjectName("frequencyDockWidget")
self.frequencyDockWidgetContents = QtWidgets.QWidget()
@ -105,8 +105,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.startFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.startFreqSpinBox.setProperty("showGroupSeparator", True)
self.startFreqSpinBox.setDecimals(3)
self.startFreqSpinBox.setMinimum(24.0)
self.startFreqSpinBox.setMaximum(1766.0)
self.startFreqSpinBox.setMinimum(0.0)
self.startFreqSpinBox.setMaximum(2200.0)
self.startFreqSpinBox.setProperty("value", 87.0)
self.startFreqSpinBox.setObjectName("startFreqSpinBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.startFreqSpinBox)
@ -122,8 +122,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.stopFreqSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.stopFreqSpinBox.setProperty("showGroupSeparator", True)
self.stopFreqSpinBox.setDecimals(3)
self.stopFreqSpinBox.setMinimum(24.0)
self.stopFreqSpinBox.setMaximum(1766.0)
self.stopFreqSpinBox.setMinimum(0.0)
self.stopFreqSpinBox.setMaximum(2200.0)
self.stopFreqSpinBox.setProperty("value", 108.0)
self.stopFreqSpinBox.setObjectName("stopFreqSpinBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.stopFreqSpinBox)
@ -139,7 +139,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.binSizeSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.binSizeSpinBox.setProperty("showGroupSeparator", True)
self.binSizeSpinBox.setDecimals(3)
self.binSizeSpinBox.setMaximum(2800.0)
self.binSizeSpinBox.setMinimum(0.0)
self.binSizeSpinBox.setMaximum(10000.0)
self.binSizeSpinBox.setProperty("value", 10.0)
self.binSizeSpinBox.setObjectName("binSizeSpinBox")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.binSizeSpinBox)
@ -172,13 +173,6 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.intervalSpinBox.setProperty("value", 1.0)
self.intervalSpinBox.setObjectName("intervalSpinBox")
self.gridLayout.addWidget(self.intervalSpinBox, 1, 0, 1, 1)
self.gainSpinBox = QtWidgets.QSpinBox(self.settingsDockWidgetContents)
self.gainSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.gainSpinBox.setMinimum(-1)
self.gainSpinBox.setMaximum(49)
self.gainSpinBox.setProperty("value", -1)
self.gainSpinBox.setObjectName("gainSpinBox")
self.gridLayout.addWidget(self.gainSpinBox, 1, 1, 1, 2)
self.label_5 = QtWidgets.QLabel(self.settingsDockWidgetContents)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 2, 0, 1, 1)
@ -227,6 +221,15 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.cropSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.cropSpinBox.setObjectName("cropSpinBox")
self.gridLayout.addWidget(self.cropSpinBox, 3, 1, 1, 2)
self.gainSpinBox = QtWidgets.QDoubleSpinBox(self.settingsDockWidgetContents)
self.gainSpinBox.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.gainSpinBox.setDecimals(1)
self.gainSpinBox.setMinimum(-1.0)
self.gainSpinBox.setMaximum(999.0)
self.gainSpinBox.setSingleStep(1.0)
self.gainSpinBox.setProperty("value", -1.0)
self.gainSpinBox.setObjectName("gainSpinBox")
self.gridLayout.addWidget(self.gainSpinBox, 1, 1, 1, 2)
self.settingsDockWidget.setWidget(self.settingsDockWidgetContents)
QSpectrumAnalyzerMainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.settingsDockWidget)
self.levelsDockWidget = QtWidgets.QDockWidget(QSpectrumAnalyzerMainWindow)
@ -293,8 +296,8 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
QSpectrumAnalyzerMainWindow.setTabOrder(self.smoothButton, self.persistenceCheckBox)
QSpectrumAnalyzerMainWindow.setTabOrder(self.persistenceCheckBox, self.persistenceButton)
QSpectrumAnalyzerMainWindow.setTabOrder(self.persistenceButton, self.histogramPlotLayout)
QSpectrumAnalyzerMainWindow.setTabOrder(self.histogramPlotLayout, self.mainPlotLayout)
QSpectrumAnalyzerMainWindow.setTabOrder(self.mainPlotLayout, self.waterfallPlotLayout)
QSpectrumAnalyzerMainWindow.setTabOrder(self.histogramPlotLayout, self.waterfallPlotLayout)
QSpectrumAnalyzerMainWindow.setTabOrder(self.waterfallPlotLayout, self.mainPlotLayout)
def retranslateUi(self, QSpectrumAnalyzerMainWindow):
_translate = QtCore.QCoreApplication.translate
@ -315,7 +318,6 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.settingsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Settings"))
self.label_4.setText(_translate("QSpectrumAnalyzerMainWindow", "&Interval [s]:"))
self.label_6.setText(_translate("QSpectrumAnalyzerMainWindow", "&Gain [dB]:"))
self.gainSpinBox.setSpecialValueText(_translate("QSpectrumAnalyzerMainWindow", "auto"))
self.label_5.setText(_translate("QSpectrumAnalyzerMainWindow", "Corr. [ppm]:"))
self.label_7.setText(_translate("QSpectrumAnalyzerMainWindow", "Crop [%]:"))
self.mainCurveCheckBox.setText(_translate("QSpectrumAnalyzerMainWindow", "Main curve"))
@ -327,6 +329,7 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.smoothButton.setText(_translate("QSpectrumAnalyzerMainWindow", "..."))
self.persistenceCheckBox.setText(_translate("QSpectrumAnalyzerMainWindow", "Persistence"))
self.persistenceButton.setText(_translate("QSpectrumAnalyzerMainWindow", "..."))
self.gainSpinBox.setSpecialValueText(_translate("QSpectrumAnalyzerMainWindow", "auto"))
self.levelsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Levels"))
self.action_Settings.setText(_translate("QSpectrumAnalyzerMainWindow", "&Settings..."))
self.action_Quit.setText(_translate("QSpectrumAnalyzerMainWindow", "&Quit"))

View File

@ -88,7 +88,7 @@ class Ui_QSpectrumAnalyzerSettings(object):
self.sampleRateSpinBox.setProperty("showGroupSeparator", True)
self.sampleRateSpinBox.setDecimals(3)
self.sampleRateSpinBox.setMinimum(0.0)
self.sampleRateSpinBox.setMaximum(61.44)
self.sampleRateSpinBox.setMaximum(999999.99)
self.sampleRateSpinBox.setSingleStep(0.01)
self.sampleRateSpinBox.setProperty("value", 61.44)
self.sampleRateSpinBox.setObjectName("sampleRateSpinBox")
@ -97,7 +97,7 @@ class Ui_QSpectrumAnalyzerSettings(object):
self.bandwidthSpinBox.setProperty("showGroupSeparator", True)
self.bandwidthSpinBox.setDecimals(3)
self.bandwidthSpinBox.setMinimum(0.0)
self.bandwidthSpinBox.setMaximum(61.44)
self.bandwidthSpinBox.setMaximum(999999.99)
self.bandwidthSpinBox.setSingleStep(0.01)
self.bandwidthSpinBox.setProperty("value", 0.0)
self.bandwidthSpinBox.setObjectName("bandwidthSpinBox")