kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
rodzic
36c919829e
commit
e0ee24b103
|
@ -41,31 +41,66 @@ class Marker(QtCore.QObject):
|
||||||
self.frequencyInput.setAlignment(QtCore.Qt.AlignRight)
|
self.frequencyInput.setAlignment(QtCore.Qt.AlignRight)
|
||||||
self.frequencyInput.returnPressed.connect(lambda: self.setFrequency(self.frequencyInput.text()))
|
self.frequencyInput.returnPressed.connect(lambda: self.setFrequency(self.frequencyInput.text()))
|
||||||
|
|
||||||
|
################################################################################################################
|
||||||
|
# Data display label
|
||||||
|
################################################################################################################
|
||||||
|
|
||||||
|
self.frequency_label = QtWidgets.QLabel("")
|
||||||
|
self.frequency_label.setMinimumWidth(100)
|
||||||
|
self.impedance_label = QtWidgets.QLabel("")
|
||||||
|
self.returnloss_label = QtWidgets.QLabel("")
|
||||||
|
self.returnloss_label.setMinimumWidth(80)
|
||||||
|
self.vswr_label = QtWidgets.QLabel("")
|
||||||
|
self.inductance_label = QtWidgets.QLabel("")
|
||||||
|
self.capacitance_label = QtWidgets.QLabel("")
|
||||||
|
self.gain_label = QtWidgets.QLabel("")
|
||||||
|
self.phase_label = QtWidgets.QLabel("")
|
||||||
|
self.quality_factor_label = QtWidgets.QLabel("")
|
||||||
|
|
||||||
|
################################################################################################################
|
||||||
|
# Marker control layout
|
||||||
|
################################################################################################################
|
||||||
|
|
||||||
self.btnColorPicker = QtWidgets.QPushButton("█")
|
self.btnColorPicker = QtWidgets.QPushButton("█")
|
||||||
self.btnColorPicker.setFixedWidth(20)
|
self.btnColorPicker.setFixedWidth(20)
|
||||||
self.setColor(initialColor)
|
self.setColor(initialColor)
|
||||||
self.btnColorPicker.clicked.connect(lambda: self.setColor(QtWidgets.QColorDialog.getColor(self.color, options=QtWidgets.QColorDialog.ShowAlphaChannel)))
|
self.btnColorPicker.clicked.connect(lambda: self.setColor(QtWidgets.QColorDialog.getColor(self.color, options=QtWidgets.QColorDialog.ShowAlphaChannel)))
|
||||||
|
self.radioButton = QtWidgets.QRadioButton()
|
||||||
|
|
||||||
self.layout = QtWidgets.QHBoxLayout()
|
self.layout = QtWidgets.QHBoxLayout()
|
||||||
self.layout.addWidget(self.frequencyInput)
|
self.layout.addWidget(self.frequencyInput)
|
||||||
self.layout.addWidget(self.btnColorPicker)
|
self.layout.addWidget(self.btnColorPicker)
|
||||||
|
self.layout.addWidget(self.radioButton)
|
||||||
|
|
||||||
|
################################################################################################################
|
||||||
|
# Data display layout
|
||||||
|
################################################################################################################
|
||||||
|
|
||||||
self.group_box = QtWidgets.QGroupBox(self.name)
|
self.group_box = QtWidgets.QGroupBox(self.name)
|
||||||
box_layout = QtWidgets.QFormLayout(self.group_box)
|
box_layout = QtWidgets.QHBoxLayout(self.group_box)
|
||||||
self.frequency_label = QtWidgets.QLabel("")
|
|
||||||
box_layout.addRow(QtWidgets.QLabel("Actual frequency:"), self.frequency_label)
|
line = QtWidgets.QFrame()
|
||||||
self.impedance_label = QtWidgets.QLabel("")
|
line.setFrameShape(QtWidgets.QFrame.VLine)
|
||||||
box_layout.addRow(QtWidgets.QLabel("Impedance:"), self.impedance_label)
|
#line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||||
self.returnloss_label = QtWidgets.QLabel("")
|
|
||||||
box_layout.addRow(QtWidgets.QLabel("Return loss:"), self.returnloss_label)
|
left_form = QtWidgets.QFormLayout()
|
||||||
self.vswr_label = QtWidgets.QLabel("")
|
right_form = QtWidgets.QFormLayout()
|
||||||
box_layout.addRow(QtWidgets.QLabel("VSWR:"), self.vswr_label)
|
box_layout.addLayout(left_form)
|
||||||
self.reactance_label = QtWidgets.QLabel("")
|
box_layout.addWidget(line)
|
||||||
box_layout.addRow(QtWidgets.QLabel("C/L equivalent:"), self.reactance_label)
|
box_layout.addLayout(right_form)
|
||||||
self.gain_label = QtWidgets.QLabel("")
|
|
||||||
box_layout.addRow(QtWidgets.QLabel("S21 Gain:"), self.gain_label)
|
# Left side
|
||||||
self.phase_label = QtWidgets.QLabel("")
|
left_form.addRow(QtWidgets.QLabel("Frequency:"), self.frequency_label)
|
||||||
box_layout.addRow(QtWidgets.QLabel("S21 Phase:"), self.phase_label)
|
left_form.addRow(QtWidgets.QLabel("Impedance:"), self.impedance_label)
|
||||||
|
left_form.addRow(QtWidgets.QLabel("L equiv.:"), self.inductance_label)
|
||||||
|
left_form.addRow(QtWidgets.QLabel("C equiv.:"), self.capacitance_label)
|
||||||
|
left_form.addRow(QtWidgets.QLabel("Q:"), self.quality_factor_label)
|
||||||
|
|
||||||
|
# Right side
|
||||||
|
right_form.addRow(QtWidgets.QLabel("Return loss:"), self.returnloss_label)
|
||||||
|
right_form.addRow(QtWidgets.QLabel("VSWR:"), self.vswr_label)
|
||||||
|
right_form.addRow(QtWidgets.QLabel("S21 Gain:"), self.gain_label)
|
||||||
|
right_form.addRow(QtWidgets.QLabel("S21 Phase:"), self.phase_label)
|
||||||
|
|
||||||
def setFrequency(self, frequency):
|
def setFrequency(self, frequency):
|
||||||
from .NanoVNASaver import NanoVNASaver
|
from .NanoVNASaver import NanoVNASaver
|
||||||
|
@ -111,9 +146,11 @@ class Marker(QtCore.QObject):
|
||||||
self.impedance_label.setText("")
|
self.impedance_label.setText("")
|
||||||
self.vswr_label.setText("")
|
self.vswr_label.setText("")
|
||||||
self.returnloss_label.setText("")
|
self.returnloss_label.setText("")
|
||||||
self.reactance_label.setText("")
|
self.inductance_label.setText("")
|
||||||
|
self.capacitance_label.setText("")
|
||||||
self.gain_label.setText("")
|
self.gain_label.setText("")
|
||||||
self.phase_label.setText("")
|
self.phase_label.setText("")
|
||||||
|
self.quality_factor_label.setText("")
|
||||||
|
|
||||||
def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
|
def updateLabels(self, s11data: List[Datapoint], s21data: List[Datapoint]):
|
||||||
from NanoVNASaver.Chart import PhaseChart
|
from NanoVNASaver.Chart import PhaseChart
|
||||||
|
@ -127,9 +164,15 @@ class Marker(QtCore.QObject):
|
||||||
self.frequency_label.setText(NanoVNASaver.formatFrequency(s11data[self.location].freq))
|
self.frequency_label.setText(NanoVNASaver.formatFrequency(s11data[self.location].freq))
|
||||||
self.impedance_label.setText(str(round(re50, 3)) + im50str)
|
self.impedance_label.setText(str(round(re50, 3)) + im50str)
|
||||||
self.returnloss_label.setText(str(round(20 * math.log10((vswr - 1) / (vswr + 1)), 3)) + " dB")
|
self.returnloss_label.setText(str(round(20 * math.log10((vswr - 1) / (vswr + 1)), 3)) + " dB")
|
||||||
reactance = NanoVNASaver.reactanceEquivalent(im50, s11data[self.location].freq)
|
capacitance = NanoVNASaver.capacitanceEquivalent(im50, s11data[self.location].freq)
|
||||||
self.reactance_label.setText(reactance)
|
inductance = NanoVNASaver.inductanceEquivalent(im50, s11data[self.location].freq)
|
||||||
self.vswr_label.setText(str(round(vswr, 3)))
|
self.inductance_label.setText(inductance)
|
||||||
|
self.capacitance_label.setText(capacitance)
|
||||||
|
vswr = round(vswr, 3)
|
||||||
|
if vswr < 0:
|
||||||
|
vswr = "-"
|
||||||
|
self.vswr_label.setText(str(vswr))
|
||||||
|
self.quality_factor_label.setText(str(round(NanoVNASaver.qualifyFactor(s11data[self.location]), 1)))
|
||||||
if len(s21data) == len(s11data):
|
if len(s21data) == len(s11data):
|
||||||
_, _, vswr = NanoVNASaver.vswr(s21data[self.location])
|
_, _, vswr = NanoVNASaver.vswr(s21data[self.location])
|
||||||
self.gain_label.setText(str(round(20 * math.log10((vswr - 1) / (vswr + 1)), 3)) + " dB")
|
self.gain_label.setText(str(round(20 * math.log10((vswr - 1) / (vswr + 1)), 3)) + " dB")
|
||||||
|
|
|
@ -41,6 +41,8 @@ class NanoVNASaver(QtWidgets.QWidget):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.setWindowIcon(QtGui.QIcon("icon_48x48.png"))
|
||||||
|
|
||||||
self.settings = QtCore.QSettings(QtCore.QSettings.IniFormat,
|
self.settings = QtCore.QSettings(QtCore.QSettings.IniFormat,
|
||||||
QtCore.QSettings.UserScope,
|
QtCore.QSettings.UserScope,
|
||||||
"NanoVNASaver", "NanoVNASaver")
|
"NanoVNASaver", "NanoVNASaver")
|
||||||
|
@ -187,7 +189,7 @@ class NanoVNASaver(QtWidgets.QWidget):
|
||||||
|
|
||||||
marker_control_box = QtWidgets.QGroupBox()
|
marker_control_box = QtWidgets.QGroupBox()
|
||||||
marker_control_box.setTitle("Markers")
|
marker_control_box.setTitle("Markers")
|
||||||
marker_control_box.setMaximumWidth(300)
|
marker_control_box.setMaximumWidth(350)
|
||||||
marker_control_layout = QtWidgets.QFormLayout(marker_control_box)
|
marker_control_layout = QtWidgets.QFormLayout(marker_control_box)
|
||||||
|
|
||||||
mouse_marker_color = self.settings.value("MouseMarkerColor", QtGui.QColor(20, 255, 20), QtGui.QColor)
|
mouse_marker_color = self.settings.value("MouseMarkerColor", QtGui.QColor(20, 255, 20), QtGui.QColor)
|
||||||
|
@ -466,7 +468,7 @@ class NanoVNASaver(QtWidgets.QWidget):
|
||||||
|
|
||||||
self.lister = QtWidgets.QPlainTextEdit()
|
self.lister = QtWidgets.QPlainTextEdit()
|
||||||
self.lister.setFixedHeight(200)
|
self.lister.setFixedHeight(200)
|
||||||
self.lister.setMaximumWidth(300)
|
self.lister.setMaximumWidth(350)
|
||||||
marker_column.addWidget(self.lister)
|
marker_column.addWidget(self.lister)
|
||||||
|
|
||||||
self.worker.signals.updated.connect(self.dataUpdated)
|
self.worker.signals.updated.connect(self.dataUpdated)
|
||||||
|
@ -768,10 +770,14 @@ class NanoVNASaver(QtWidgets.QWidget):
|
||||||
return Q
|
return Q
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reactanceEquivalent(im50, freq) -> str:
|
def capacitanceEquivalent(im50, freq) -> str:
|
||||||
capacitance = 10**12/(freq * 2 * math.pi * im50)
|
capacitance = 10**12/(freq * 2 * math.pi * im50)
|
||||||
|
return str(round(-capacitance, 3)) + " pF"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def inductanceEquivalent(im50, freq) -> str:
|
||||||
inductance = im50 / (freq * 2 * math.pi)
|
inductance = im50 / (freq * 2 * math.pi)
|
||||||
return str(round(-capacitance, 3)) + " pF / " + str(round(inductance * 1000000000, 3)) + " nH"
|
return str(round(inductance * 1000000000, 3)) + " nH"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def gain(data: Datapoint):
|
def gain(data: Datapoint):
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 17 KiB |
Ładowanie…
Reference in New Issue