Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.10.0 #36

Merged
merged 14 commits into from
Feb 27, 2024
Prev Previous commit
Next Next commit
new fixed frequency marker feature
code and database updates to add preset frequency markers with user-defined colours
g4ixt committed Feb 17, 2024
commit 1008332cdd120e44110c488f9c6c73d849eb374e
278 changes: 173 additions & 105 deletions QtTSApreferences.py
Original file line number Diff line number Diff line change
@@ -14,70 +14,35 @@
class Ui_Preferences(object):
def setupUi(self, Preferences):
Preferences.setObjectName("Preferences")
Preferences.resize(600, 350)
Preferences.resize(423, 736)
self.gridLayout_2 = QtWidgets.QGridLayout(Preferences)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.autoPoints = QtWidgets.QGroupBox(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.autoPoints.sizePolicy().hasHeightForWidth())
self.autoPoints.setSizePolicy(sizePolicy)
self.autoPoints.setObjectName("autoPoints")
self.minPoints = QtWidgets.QSpinBox(self.autoPoints)
self.minPoints.setGeometry(QtCore.QRect(200, 70, 80, 27))
self.minPoints.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.minPoints.setMinimum(25)
self.minPoints.setMaximum(450)
self.minPoints.setProperty("value", 450)
self.minPoints.setObjectName("minPoints")
self.maxPoints = QtWidgets.QSpinBox(self.autoPoints)
self.maxPoints.setGeometry(QtCore.QRect(200, 110, 80, 27))
self.maxPoints.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.maxPoints.setMinimum(25)
self.maxPoints.setMaximum(100000)
self.maxPoints.setProperty("value", 30000)
self.maxPoints.setObjectName("maxPoints")
self.label_3 = QtWidgets.QLabel(self.autoPoints)
self.label_3.setGeometry(QtCore.QRect(10, 70, 111, 24))
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.autoPoints)
self.label_4.setGeometry(QtCore.QRect(10, 110, 111, 24))
self.label_4.setObjectName("label_4")
self.rbw_x = QtWidgets.QSpinBox(self.autoPoints)
self.rbw_x.setGeometry(QtCore.QRect(200, 30, 80, 27))
self.label = QtWidgets.QLabel(Preferences)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 16, 0, 1, 2)
self.label_11 = QtWidgets.QLabel(Preferences)
self.label_11.setObjectName("label_11")
self.gridLayout.addWidget(self.label_11, 8, 0, 1, 2)
self.neg25Line = QtWidgets.QCheckBox(Preferences)
self.neg25Line.setChecked(False)
self.neg25Line.setObjectName("neg25Line")
self.gridLayout.addWidget(self.neg25Line, 10, 3, 1, 1)
self.rbw_x = QtWidgets.QSpinBox(Preferences)
self.rbw_x.setMinimum(2)
self.rbw_x.setMaximum(10)
self.rbw_x.setProperty("value", 3)
self.rbw_x.setObjectName("rbw_x")
self.label = QtWidgets.QLabel(self.autoPoints)
self.label.setGeometry(QtCore.QRect(10, 35, 111, 18))
self.label.setObjectName("label")
self.gridLayout.addWidget(self.autoPoints, 1, 1, 1, 1)
self.signalLines = QtWidgets.QGroupBox(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.signalLines.sizePolicy().hasHeightForWidth())
self.signalLines.setSizePolicy(sizePolicy)
self.signalLines.setObjectName("signalLines")
self.neg25Line = QtWidgets.QCheckBox(self.signalLines)
self.neg25Line.setGeometry(QtCore.QRect(10, 30, 221, 24))
self.neg25Line.setChecked(False)
self.neg25Line.setObjectName("neg25Line")
self.zeroLine = QtWidgets.QCheckBox(self.signalLines)
self.zeroLine.setGeometry(QtCore.QRect(10, 60, 221, 24))
self.zeroLine.setChecked(False)
self.zeroLine.setObjectName("zeroLine")
self.plus6Line = QtWidgets.QCheckBox(self.signalLines)
self.plus6Line.setGeometry(QtCore.QRect(10, 90, 221, 24))
self.plus6Line.setChecked(False)
self.plus6Line.setObjectName("plus6Line")
self.peakThreshold = QtWidgets.QSpinBox(self.signalLines)
self.peakThreshold.setGeometry(QtCore.QRect(200, 120, 80, 23))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
self.gridLayout.addWidget(self.rbw_x, 16, 3, 1, 1)
self.label_10 = QtWidgets.QLabel(Preferences)
self.label_10.setObjectName("label_10")
self.gridLayout.addWidget(self.label_10, 9, 0, 1, 2)
self.label_9 = QtWidgets.QLabel(Preferences)
self.label_9.setObjectName("label_9")
self.gridLayout.addWidget(self.label_9, 10, 0, 1, 2)
self.peakThreshold = QtWidgets.QSpinBox(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.peakThreshold.sizePolicy().hasHeightForWidth())
@@ -91,54 +56,150 @@ def setupUi(self, Preferences):
self.peakThreshold.setMaximum(-20)
self.peakThreshold.setProperty("value", -90)
self.peakThreshold.setObjectName("peakThreshold")
self.label_9 = QtWidgets.QLabel(self.signalLines)
self.label_9.setGeometry(QtCore.QRect(10, 120, 171, 27))
self.gridLayout.addWidget(self.peakThreshold, 13, 3, 1, 1)
self.minPoints = QtWidgets.QSpinBox(Preferences)
self.minPoints.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.minPoints.setMinimum(25)
self.minPoints.setMaximum(450)
self.minPoints.setProperty("value", 450)
self.minPoints.setObjectName("minPoints")
self.gridLayout.addWidget(self.minPoints, 17, 3, 1, 1)
self.interest = QtWidgets.QRadioButton(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.interest.sizePolicy().hasHeightForWidth())
self.interest.setSizePolicy(sizePolicy)
self.interest.setObjectName("interest")
self.listSelect = QtWidgets.QButtonGroup(Preferences)
self.listSelect.setObjectName("listSelect")
self.listSelect.addButton(self.interest)
self.gridLayout.addWidget(self.interest, 1, 2, 1, 1)
self.label_6 = QtWidgets.QLabel(Preferences)
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(False)
font.setWeight(50)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.gridLayout.addWidget(self.signalLines, 2, 1, 1, 1)
self.FreqBands = QtWidgets.QGroupBox(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
font.setBold(True)
font.setWeight(75)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 7, 0, 1, 3)
self.deleteRow = QtWidgets.QPushButton(Preferences)
self.deleteRow.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.FreqBands.sizePolicy().hasHeightForWidth())
self.FreqBands.setSizePolicy(sizePolicy)
self.FreqBands.setObjectName("FreqBands")
self.freqBands = QtWidgets.QTableView(self.FreqBands)
self.freqBands.setGeometry(QtCore.QRect(10, 30, 271, 211))
sizePolicy.setHeightForWidth(self.deleteRow.sizePolicy().hasHeightForWidth())
self.deleteRow.setSizePolicy(sizePolicy)
self.deleteRow.setObjectName("deleteRow")
self.gridLayout.addWidget(self.deleteRow, 5, 3, 1, 1)
self.label_7 = QtWidgets.QLabel(Preferences)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.gridLayout.addWidget(self.label_7, 12, 0, 1, 2)
self.plus6Line = QtWidgets.QCheckBox(Preferences)
self.plus6Line.setChecked(False)
self.plus6Line.setObjectName("plus6Line")
self.gridLayout.addWidget(self.plus6Line, 8, 3, 1, 1)
self.all = QtWidgets.QRadioButton(Preferences)
self.all.setObjectName("all")
self.listSelect.addButton(self.all)
self.gridLayout.addWidget(self.all, 1, 3, 1, 1)
self.maxPoints = QtWidgets.QSpinBox(Preferences)
self.maxPoints.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.maxPoints.setMinimum(25)
self.maxPoints.setMaximum(100000)
self.maxPoints.setProperty("value", 30000)
self.maxPoints.setObjectName("maxPoints")
self.gridLayout.addWidget(self.maxPoints, 18, 3, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 14, 0, 1, 1)
self.label_2 = QtWidgets.QLabel(Preferences)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 13, 0, 1, 2)
self.label_3 = QtWidgets.QLabel(Preferences)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 17, 0, 1, 2)
self.zeroLine = QtWidgets.QCheckBox(Preferences)
self.zeroLine.setChecked(False)
self.zeroLine.setObjectName("zeroLine")
self.gridLayout.addWidget(self.zeroLine, 9, 3, 1, 1)
self.freqBands = QtWidgets.QTableView(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.freqBands.sizePolicy().hasHeightForWidth())
self.freqBands.setSizePolicy(sizePolicy)
self.freqBands.setObjectName("freqBands")
self.addRow = QtWidgets.QPushButton(self.FreqBands)
self.gridLayout.addWidget(self.freqBands, 2, 0, 2, 4)
self.beacon = QtWidgets.QRadioButton(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.beacon.sizePolicy().hasHeightForWidth())
self.beacon.setSizePolicy(sizePolicy)
self.beacon.setObjectName("beacon")
self.listSelect.addButton(self.beacon)
self.gridLayout.addWidget(self.beacon, 1, 1, 1, 1)
self.addRow = QtWidgets.QPushButton(Preferences)
self.addRow.setEnabled(True)
self.addRow.setGeometry(QtCore.QRect(190, 250, 90, 26))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.addRow.sizePolicy().hasHeightForWidth())
self.addRow.setSizePolicy(sizePolicy)
self.addRow.setObjectName("addRow")
self.deleteRow = QtWidgets.QPushButton(self.FreqBands)
self.deleteRow.setEnabled(True)
self.deleteRow.setGeometry(QtCore.QRect(190, 290, 90, 26))
self.deleteRow.setObjectName("deleteRow")
self.rowUp = QtWidgets.QToolButton(self.FreqBands)
self.rowUp.setGeometry(QtCore.QRect(10, 250, 25, 25))
self.rowUp.setArrowType(QtCore.Qt.UpArrow)
self.rowUp.setObjectName("rowUp")
self.rowDown = QtWidgets.QToolButton(self.FreqBands)
self.rowDown.setGeometry(QtCore.QRect(10, 290, 25, 25))
self.rowDown.setArrowType(QtCore.Qt.DownArrow)
self.rowDown.setObjectName("rowDown")
self.label_5 = QtWidgets.QLabel(self.FreqBands)
self.label_5.setGeometry(QtCore.QRect(50, 250, 131, 61))
self.gridLayout.addWidget(self.addRow, 5, 2, 1, 1)
self.importButton = QtWidgets.QPushButton(Preferences)
self.importButton.setEnabled(False)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.importButton.sizePolicy().hasHeightForWidth())
self.importButton.setSizePolicy(sizePolicy)
self.importButton.setObjectName("importButton")
self.gridLayout.addWidget(self.importButton, 5, 0, 1, 1)
self.band = QtWidgets.QRadioButton(Preferences)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.band.sizePolicy().hasHeightForWidth())
self.band.setSizePolicy(sizePolicy)
self.band.setChecked(True)
self.band.setObjectName("band")
self.listSelect.addButton(self.band)
self.gridLayout.addWidget(self.band, 1, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem1, 11, 0, 1, 1)
self.exportButton = QtWidgets.QPushButton(Preferences)
self.exportButton.setEnabled(False)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.exportButton.sizePolicy().hasHeightForWidth())
self.exportButton.setSizePolicy(sizePolicy)
self.exportButton.setObjectName("exportButton")
self.gridLayout.addWidget(self.exportButton, 5, 1, 1, 1)
self.label_8 = QtWidgets.QLabel(Preferences)
font = QtGui.QFont()
font.setItalic(True)
font.setBold(True)
font.setWeight(75)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.gridLayout.addWidget(self.label_8, 15, 0, 1, 2)
self.label_5 = QtWidgets.QLabel(Preferences)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_5.setFont(font)
self.label_5.setWordWrap(True)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.FreqBands, 0, 0, 4, 1)
self.gridLayout.addWidget(self.label_5, 0, 0, 1, 2)
self.label_4 = QtWidgets.QLabel(Preferences)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 18, 0, 1, 2)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem2, 6, 0, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)

self.retranslateUi(Preferences)
@@ -147,19 +208,26 @@ def setupUi(self, Preferences):
def retranslateUi(self, Preferences):
_translate = QtCore.QCoreApplication.translate
Preferences.setWindowTitle(_translate("Preferences", "Preferences"))
self.autoPoints.setTitle(_translate("Preferences", "Auto Points"))
self.label_3.setText(_translate("Preferences", "Auto min points"))
self.label_4.setText(_translate("Preferences", "Auto max points"))
self.label.setText(_translate("Preferences", "Points per RBW"))
self.signalLines.setTitle(_translate("Preferences", "Horizontal lines "))
self.neg25Line.setText(_translate("Preferences", "-25dBm (best accuracy)"))
self.zeroLine.setText(_translate("Preferences", " 0dBm (attenuator on Auto)"))
self.plus6Line.setText(_translate("Preferences", "Absolute maximum of +6dBm"))
self.label.setText(_translate("Preferences", "Points / Resolution Bandwidth"))
self.label_11.setText(_translate("Preferences", "Absolute maximum"))
self.neg25Line.setText(_translate("Preferences", "-25dBm"))
self.label_10.setText(_translate("Preferences", "Max with auto attenuator"))
self.label_9.setText(_translate("Preferences", "Max for best accuracy"))
self.peakThreshold.setSuffix(_translate("Preferences", "dBm"))
self.label_9.setText(_translate("Preferences", "Peak detection threshold"))
self.FreqBands.setTitle(_translate("Preferences", "Frequency Bands "))
self.addRow.setText(_translate("Preferences", "Add"))
self.deleteRow.setText(_translate("Preferences", "Delete"))
self.rowUp.setText(_translate("Preferences", "..."))
self.rowDown.setText(_translate("Preferences", "..."))
self.label_5.setText(_translate("Preferences", "use arrows to select row for add/delete"))
self.interest.setText(_translate("Preferences", "Interest"))
self.label_6.setText(_translate("Preferences", "Signal Level Reminder lines"))
self.deleteRow.setText(_translate("Preferences", "Delete Row"))
self.label_7.setText(_translate("Preferences", "Peak Marker Settings"))
self.plus6Line.setText(_translate("Preferences", "+6dBm"))
self.all.setText(_translate("Preferences", "All"))
self.label_2.setText(_translate("Preferences", "Detection Threshold"))
self.label_3.setText(_translate("Preferences", "Auto minimum points"))
self.zeroLine.setText(_translate("Preferences", " 0dBm"))
self.beacon.setText(_translate("Preferences", "Beacon"))
self.addRow.setText(_translate("Preferences", "Add Row"))
self.importButton.setText(_translate("Preferences", "Import"))
self.band.setText(_translate("Preferences", "Band"))
self.exportButton.setText(_translate("Preferences", "Export"))
self.label_8.setText(_translate("Preferences", "Scan Points Settings"))
self.label_5.setText(_translate("Preferences", "Preset Bands and Markers"))
self.label_4.setText(_translate("Preferences", "Auto maximum points"))
Binary file modified QtTSAprefs.db
Binary file not shown.
155 changes: 107 additions & 48 deletions QtTinySA.py
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ def initialise(self):
logging.info(f'{hardware[:16]}')
i += 1
time.sleep(0.5)
# hardware = 'basic' # used for testing
# hardware = 'tinySA' # used for testing
if hardware[:7] == 'tinySA4': # It's an Ultra
self.tinySA4 = True
ui.spur_box.setTristate(True) # TinySA Ultra has 'auto', 'on' and 'off' setting for Spur
@@ -163,6 +163,7 @@ def initialise(self):
# set each marker to a different colour
S1.vline.label.setColor('y')
S2.vline.setPen(color='m', width=0.75, style=QtCore.Qt.DashLine)
# S2.vline.setPen(color=QtGui.QColor('darkgreen'), width=0.75, style=QtCore.Qt.DashLine)
S2.vline.label.setColor('m')
S3.vline.setPen(color='c', width=0.75, style=QtCore.Qt.DashLine)
S3.vline.label.setColor('c')
@@ -665,16 +666,18 @@ def updateMarker(self, frequencies, readings, fPeaks): # called by updateGUI()
else:
self.vline.label.setText(f'M{self.vline.name()} {self.vline.value():.3f}MHz {dBm:.1f}dBm')

def addFreqMarker(self, freq):
# adds a simple frequency marker line without the functionality of the other markers
marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen('g', width=0.5, style=QtCore.Qt.DashLine))
# store the marker object in a queue
self.fifo.put(marker)
def addFreqMarker(self, freq, colour, name): # adds simple frequency marker without full marker capability
if ui.presetLabel.isChecked():
marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine),
label=name, labelOpts={'position': 0.05, 'color': (colour)})
else:
marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine))

self.fifo.put(marker) # store the marker object in a queue

def delFreqMarkers(self):
for i in range(0, self.fifo.qsize()):
# remove the marker and its corresponding object in the queue
ui.graphWidget.removeItem(self.fifo.get())
ui.graphWidget.removeItem(self.fifo.get()) # remove the marker and its corresponding object in the queue


class WorkerSignals(QObject):
@@ -749,34 +752,73 @@ def saveChanges(self):

def deleteRow(self): # deletes row selected by the up/down arrows on the frequency bands table widget
self.tm.removeRow(self.currentRow)
self.tm.select()
self.tm.layoutChanged.emit()
self.dwm.submit()

def upRow(self):
if self.currentRow > 0:
self.currentRow -= 1
preferences.freqBands.selectRow(self.currentRow)
else:
return
def tableClicked(self):
self.currentRow = preferences.freqBands.currentIndex().row() # the row index from the QModelIndexObject
logging.debug(f'row {self.currentRow} clicked')

def insertData(self, name, startF, stopF):
record = self.tm.record()
record.setValue('name', name)
record.setValue('startF', f'{startF:.6f}')
record.setValue('stopF', f'{stopF:.6f}')
self.tm.insertRecord(-1, record)
self.tm.select()
self.tm.layoutChanged.emit()
self.dwm.submit()

def downRow(self):
if self.currentRow < self.tm.rowCount():
self.currentRow += 1
preferences.freqBands.selectRow(self.currentRow)
def buttonFilter(self, tF):
pressed = preferences.listSelect.checkedButton().objectName()
if tF:
options = {'band': 'preset = "band"',
'beacon': 'preset = "beacon"',
'interest': 'preset = "interest"',
'all': ''}
else:
return
options = {'band': 'visible = "1" AND preset = "band"',
'beacon': 'visible = "1" AND preset = "beacon"',
'interest': 'visible = "1" AND preset = "interest"',
'all': 'visible = "1"'}
if tinySA.usb and tinySA.dev:
if tinySA.tinySA4: # It's a tinySA Ultra
bands.tm.setFilter(options.get(pressed))
else:
f = options.get(pressed) + ' AND (startF <= "960" AND stopF <= "960")'
bands.tm.setFilter(f)


###############################################################################
# respond to GUI signals

def band_changed():
index = ui.band_box.currentIndex()
if index == 0:
return
startF = bands.tm.record(index).value('StartF')
stopF = bands.tm.record(index).value('StopF')
ui.start_freq.setValue(startF)
ui.stop_freq.setValue(stopF)
tinySA.freq_changed(False) # start/stop mode
if bands.tm.record(index).value('preset') == 'band':
startF = bands.tm.record(index).value('StartF')
stopF = bands.tm.record(index).value('StopF')
ui.start_freq.setValue(startF)
ui.stop_freq.setValue(stopF)
tinySA.freq_changed(False) # start/stop mode
else:
centreF = bands.tm.record(index).value('StartF')
ui.centre_freq.setValue(centreF)
ui.span_freq.setValue(1)
tinySA.freq_changed(True) # centre mode


def addBandPressed():
if ui.marker1.isChecked() and ui.marker2.isChecked():
if S1.vline.value() >= S2.vline.value():
message = 'M1 frequency >= M2 frequency'
popUp(message, 'Ok', QMessageBox.Information)
return
name = 'M' + str(round(S1.vline.value(), 6))
bands.insertData(name, S1.vline.value(), S2.vline.value())
else:
message = 'M1 and M2 must both be enabled to add a new Band'
popUp(message, 'Ok', QMessageBox.Information)


def attenuate_changed():
@@ -843,19 +885,16 @@ def setPreferences():
numbers.dwm.submit()
bands.tm.submitAll()
S4.hline.setValue(preferences.peakThreshold.value())
if tinySA.usb and tinySA.dev:
if tinySA.tinySA4: # It's a tinySA Ultra
bands.tm.setFilter('visible = "1"')
else:
bands.tm.setFilter('visible = "1" AND (startF <= 960 AND stopF <= 960)')
if ui.markBands.isChecked():
bands.buttonFilter(False)
if ui.presetMarker.isChecked():
S1.delFreqMarkers()
S2.delFreqMarkers()
freqMarkers()


def dialogPrefs():
bands.tm.setFilter('name != "Band"') # remove filters
# bands.tm.setFilter('name != "Band"') # remove filters
bands.buttonFilter(True)
bands.tm.select()
bands.currentRow = 0
preferences.freqBands.selectRow(bands.currentRow)
@@ -901,24 +940,34 @@ def popUp(message, button, icon):


def freqMarkers():
if ui.markBands.isChecked():
if ui.presetMarker.isChecked():
for i in range(0, bands.tm.rowCount()):
startF = bands.tm.record(i).value('StartF')
S1.addFreqMarker(startF)
colour = bands.tm.record(i).value('colour')
name = bands.tm.record(i).value('name')
S1.addFreqMarker(startF, colour, name)
stopF = bands.tm.record(i).value('StopF')
S2.addFreqMarker(stopF)
if bands.tm.record(i).value('preset') == 'band':
S2.addFreqMarker(stopF, colour, '')
else:
S1.delFreqMarkers()
S2.delFreqMarkers()


def freqMarkerLabel():
S1.delFreqMarkers()
S2.delFreqMarkers()
freqMarkers()


###############################################################################
# Instantiate classes

tinySA = analyser()

app = QtWidgets.QApplication([]) # create QApplication for the GUI
app.setApplicationName('QtTinySA')
app.setApplicationVersion(' v0.9.x')
app.setApplicationVersion(' v0.9.2.beta')
window = QtWidgets.QMainWindow()
ui = QtTinySpectrum.Ui_MainWindow()
ui.setupUi(window)
@@ -1011,7 +1060,9 @@ def freqMarkers():
ui.m4_type.activated.connect(S4.mType)

# frequency band markers
ui.markBands.stateChanged.connect(freqMarkers)
ui.presetMarker.stateChanged.connect(freqMarkers)
ui.presetLabel.stateChanged.connect(freqMarkerLabel)
ui.mToBand.clicked.connect(addBandPressed)

# trace checkboxes
ui.trace1.stateChanged.connect(S1.tEnable)
@@ -1047,8 +1098,8 @@ def freqMarkers():
preferences.plus6Line.stateChanged.connect(lambda: S3.hEnable(preferences.plus6Line))
preferences.addRow.clicked.connect(bands.addRow)
preferences.deleteRow.clicked.connect(bands.deleteRow)
preferences.rowUp.clicked.connect(bands.upRow)
preferences.rowDown.clicked.connect(bands.downRow)
preferences.freqBands.clicked.connect(bands.tableClicked)
preferences.listSelect.buttonClicked.connect(lambda: bands.buttonFilter(True))
ui.actionPreferences.triggered.connect(dialogPrefs) # open preferences dialogue when its menu is clicked
ui.actionAbout_QtTinySA.triggered.connect(about)
pwindow.finished.connect(setPreferences) # update database checkboxes table on dialogue window close
@@ -1059,26 +1110,30 @@ def freqMarkers():
logging.info(f'{app.applicationName()}{app.applicationVersion()}')

# table models - read/write views of the configuration data
bands.createTableModel()
bands.tm.setSort(2, Qt.AscendingOrder)
bands.tm.setRelation(4, QSqlRelation('boolean', 'ID', 'value'))
bands.tm.setHeaderData(4, Qt.Horizontal, 'Visible')
boolean = QSqlRelationalDelegate(preferences.freqBands) # set 'view' column true/false to be combo box
bands.createTableModel() # relational
bands.tm.setSort(3, Qt.AscendingOrder)
bands.tm.setRelation(5, QSqlRelation('boolean', 'ID', 'value')) # set 'view' column to a True/False choice combo box
bands.tm.setHeaderData(5, Qt.Horizontal, 'visible')
boolean = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(boolean)
bands.tm.setRelation(6, QSqlRelation('SVGColour', 'ID', 'colour')) # set 'marker' column to a colours choice combo box
colour = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(colour)
bands.tm.setRelation(2, QSqlRelation('freqtype', 'ID', 'preset')) # set 'type' column to a freq type choice combo box
fType = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(fType)
colHeader = preferences.freqBands.horizontalHeader()
colHeader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

# populate the bands combobox
# populate the presets combobox
ui.band_box.setModel(bands.tm)
ui.band_box.setModelColumn(1)
bands.tm.setFilter('visible = "1"')
bands.tm.select() # initially select the data in the model

# connect the preferences dialogue box freq band widget to the data model
preferences.freqBands.setModel(bands.tm)
preferences.freqBands.hideColumn(0) # ID
rowHeader = preferences.freqBands.verticalHeader()
rowHeader.hide()

# Map database tables to preferences dialogue box fields and to main GUI
# ** lines need to be in this order and here or the mapping doesn't work **
@@ -1097,6 +1152,10 @@ def freqMarkers():
checkboxes.dwm.addMapping(ui.marker4, 14)
checkboxes.dwm.addMapping(ui.lna_box, 15)
checkboxes.dwm.addMapping(ui.points_auto, 16)
checkboxes.dwm.addMapping(preferences.band, 17)
checkboxes.dwm.addMapping(preferences.beacon, 18)
checkboxes.dwm.addMapping(preferences.interest, 19)
checkboxes.dwm.addMapping(preferences.all, 20)
checkboxes.tm.select()
checkboxes.dwm.setCurrentIndex(0) # 0 = (last used) default settings

674 changes: 366 additions & 308 deletions QtTinySpectrum.py

Large diffs are not rendered by default.

964 changes: 536 additions & 428 deletions QtTinySpectrum.ui

Large diffs are not rendered by default.

704 changes: 372 additions & 332 deletions preferences.ui

Large diffs are not rendered by default.