kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
rodzic
b4800102d8
commit
21e85bdb49
|
@ -48,6 +48,7 @@ docs/_build/*
|
||||||
cover/*
|
cover/*
|
||||||
MANIFEST
|
MANIFEST
|
||||||
**/_version.py
|
**/_version.py
|
||||||
|
.flatpak-builder/*
|
||||||
|
|
||||||
# Per-project virtualenvs
|
# Per-project virtualenvs
|
||||||
.venv*/
|
.venv*/
|
||||||
|
|
|
@ -26,12 +26,12 @@ import sys
|
||||||
src = os.path.join(os.path.dirname(__file__), "src")
|
src = os.path.join(os.path.dirname(__file__), "src")
|
||||||
|
|
||||||
if os.path.exists(src):
|
if os.path.exists(src):
|
||||||
sys.path.insert(0, src)
|
sys.path.insert(0, src)
|
||||||
|
|
||||||
# pylint: disable-next=wrong-import-position
|
# pylint: disable-next=wrong-import-position
|
||||||
import NanoVNASaver.__main__
|
import NanoVNASaver.__main__
|
||||||
|
|
||||||
# The traditional test does not make sense here.
|
# The traditional test does not make sense here.
|
||||||
assert __name__ == '__main__'
|
assert __name__ == "__main__"
|
||||||
|
|
||||||
NanoVNASaver.__main__.main()
|
NanoVNASaver.__main__.main()
|
||||||
|
|
|
@ -217,8 +217,8 @@ class SweepControl(Control):
|
||||||
|
|
||||||
def update_sweep(self):
|
def update_sweep(self):
|
||||||
self.app.sweep.update(
|
self.app.sweep.update(
|
||||||
start = self.get_start(),
|
start=self.get_start(),
|
||||||
end = self.get_end(),
|
end=self.get_end(),
|
||||||
segments = self.get_segments(),
|
segments=self.get_segments(),
|
||||||
points = self.app.vna.datapoints,
|
points=self.app.vna.datapoints,
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,7 +41,7 @@ class JNCRadio_VNA_3G(NanoVNA):
|
||||||
|
|
||||||
def getScreenshot(self) -> QPixmap:
|
def getScreenshot(self) -> QPixmap:
|
||||||
logger.debug("Capturing screenshot...")
|
logger.debug("Capturing screenshot...")
|
||||||
self.serial.timeout=8
|
self.serial.timeout = 8
|
||||||
if not self.connected():
|
if not self.connected():
|
||||||
return QPixmap()
|
return QPixmap()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -41,7 +41,7 @@ class SV4401A(NanoVNA):
|
||||||
|
|
||||||
def getScreenshot(self) -> QPixmap:
|
def getScreenshot(self) -> QPixmap:
|
||||||
logger.debug("Capturing screenshot...")
|
logger.debug("Capturing screenshot...")
|
||||||
self.serial.timeout=8
|
self.serial.timeout = 8
|
||||||
if not self.connected():
|
if not self.connected():
|
||||||
return QPixmap()
|
return QPixmap()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -41,7 +41,7 @@ class SV6301A(NanoVNA):
|
||||||
|
|
||||||
def getScreenshot(self) -> QPixmap:
|
def getScreenshot(self) -> QPixmap:
|
||||||
logger.debug("Capturing screenshot...")
|
logger.debug("Capturing screenshot...")
|
||||||
self.serial.timeout=8
|
self.serial.timeout = 8
|
||||||
if not self.connected():
|
if not self.connected():
|
||||||
return QPixmap()
|
return QPixmap()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -98,6 +98,6 @@ class Value:
|
||||||
]
|
]
|
||||||
|
|
||||||
self.freq = s11[1].freq
|
self.freq = s11[1].freq
|
||||||
self.s11 = s11[index - 1 : index + 2]
|
self.s11 = s11[index - 1: index + 2]
|
||||||
if s21:
|
if s21:
|
||||||
self.s21 = s21[index - 1 : index + 2]
|
self.s21 = s21[index - 1: index + 2]
|
||||||
|
|
|
@ -304,7 +304,6 @@ class NanoVNASaver(QWidget):
|
||||||
self.marker_data_layout.addWidget(m.get_data_layout())
|
self.marker_data_layout.addWidget(m.get_data_layout())
|
||||||
|
|
||||||
scroll2 = QtWidgets.QScrollArea()
|
scroll2 = QtWidgets.QScrollArea()
|
||||||
# scroll2.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
|
|
||||||
scroll2.setWidgetResizable(True)
|
scroll2.setWidgetResizable(True)
|
||||||
scroll2.setVisible(True)
|
scroll2.setVisible(True)
|
||||||
|
|
||||||
|
@ -468,7 +467,7 @@ class NanoVNASaver(QWidget):
|
||||||
|
|
||||||
logger.debug("Finished building interface")
|
logger.debug("Finished building interface")
|
||||||
|
|
||||||
def auto_connect( self ): # connect if there is exactly one detected serial device
|
def auto_connect(self): # connect if there is exactly one detected serial device
|
||||||
if self.serial_control.inp_port.count() == 1:
|
if self.serial_control.inp_port.count() == 1:
|
||||||
self.serial_control.connect_device()
|
self.serial_control.connect_device()
|
||||||
|
|
||||||
|
@ -512,11 +511,8 @@ class NanoVNASaver(QWidget):
|
||||||
self.sweepSource = source
|
self.sweepSource = source
|
||||||
else:
|
else:
|
||||||
time = strftime('%Y-%m-%d %H:%M:%S', localtime())
|
time = strftime('%Y-%m-%d %H:%M:%S', localtime())
|
||||||
name = self.sweep.properties.name
|
name = self.sweep.properties.name or 'nanovna'
|
||||||
if name:
|
self.sweepSource = f'{name}_{time}'
|
||||||
self.sweepSource = name + ' ' + time
|
|
||||||
else:
|
|
||||||
self.sweepSource = time
|
|
||||||
|
|
||||||
def markerUpdated(self, marker: Marker):
|
def markerUpdated(self, marker: Marker):
|
||||||
with self.dataLock:
|
with self.dataLock:
|
||||||
|
|
|
@ -40,12 +40,12 @@ class Properties(NamedTuple):
|
||||||
|
|
||||||
class Sweep:
|
class Sweep:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
start: int = 3600000,
|
start: int = 3600000,
|
||||||
end: int = 30000000,
|
end: int = 30000000,
|
||||||
points: int = 101,
|
points: int = 101,
|
||||||
segments: int = 1,
|
segments: int = 1,
|
||||||
properties: "Properties" = Properties(),
|
properties: "Properties" = Properties(),
|
||||||
):
|
):
|
||||||
self._start = start
|
self._start = start
|
||||||
self._end = end
|
self._end = end
|
||||||
self._points = points
|
self._points = points
|
||||||
|
@ -112,10 +112,10 @@ class Sweep:
|
||||||
|
|
||||||
def update(self, start: int, end: int, segments: int, points: int) -> None:
|
def update(self, start: int, end: int, segments: int, points: int) -> None:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._start = start
|
self._start = max(start, 1)
|
||||||
self._end = end
|
self._end = max(end, start)
|
||||||
self._segments = segments
|
self._segments = max(segments, 1)
|
||||||
self._points = points
|
self._points = max(points, 1)
|
||||||
self.check()
|
self.check()
|
||||||
|
|
||||||
def set_name(self, name: str) -> None:
|
def set_name(self, name: str) -> None:
|
||||||
|
@ -136,11 +136,11 @@ class Sweep:
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
if (
|
if (
|
||||||
self.segments <= 0
|
self.segments < 1
|
||||||
or self.points <= 0
|
or self.points < 1
|
||||||
or self.start < 0
|
or self.start < 1
|
||||||
or self.end <= 0
|
or self.end < self.start
|
||||||
or self.stepsize < 1
|
or self.stepsize < 0
|
||||||
):
|
):
|
||||||
raise ValueError(f"Illegal sweep settings: {self}")
|
raise ValueError(f"Illegal sweep settings: {self}")
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,13 @@ import typing
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
_RXP = re.compile(
|
_RXP = re.compile(r"""^
|
||||||
r"""^
|
\D*
|
||||||
\D*
|
(?P<major>\d+)\.
|
||||||
(?P<major>\d+)\.
|
(?P<minor>\d+)\.?
|
||||||
(?P<minor>\d+)\.?
|
(?P<revision>\d+)?
|
||||||
(?P<revision>\d+)?
|
(?P<note>.*)
|
||||||
(?P<note>.*)
|
$""", re.VERBOSE)
|
||||||
$""",
|
|
||||||
re.VERBOSE,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class _Version(typing.NamedTuple):
|
class _Version(typing.NamedTuple):
|
||||||
|
|
|
@ -42,7 +42,7 @@ class AboutWindow(QtWidgets.QWidget):
|
||||||
make_scrollable(self, top_layout)
|
make_scrollable(self, top_layout)
|
||||||
|
|
||||||
upper_layout = QtWidgets.QHBoxLayout()
|
upper_layout = QtWidgets.QHBoxLayout()
|
||||||
top_layout.addLayout( upper_layout )
|
top_layout.addLayout(upper_layout)
|
||||||
QtGui.QShortcut(QtCore.Qt.Key.Key_Escape, self, self.hide)
|
QtGui.QShortcut(QtCore.Qt.Key.Key_Escape, self, self.hide)
|
||||||
|
|
||||||
icon_layout = QtWidgets.QVBoxLayout()
|
icon_layout = QtWidgets.QVBoxLayout()
|
||||||
|
@ -84,7 +84,7 @@ class AboutWindow(QtWidgets.QWidget):
|
||||||
info_layout.addWidget(QtWidgets.QLabel(""))
|
info_layout.addWidget(QtWidgets.QLabel(""))
|
||||||
|
|
||||||
lower_layout = QtWidgets.QVBoxLayout()
|
lower_layout = QtWidgets.QVBoxLayout()
|
||||||
top_layout.addLayout( lower_layout )
|
top_layout.addLayout(lower_layout)
|
||||||
|
|
||||||
btn_check_version = QtWidgets.QPushButton("Check for NanoVNASaver updates")
|
btn_check_version = QtWidgets.QPushButton("Check for NanoVNASaver updates")
|
||||||
btn_check_version.clicked.connect(self.findUpdates)
|
btn_check_version.clicked.connect(self.findUpdates)
|
||||||
|
@ -95,7 +95,7 @@ class AboutWindow(QtWidgets.QWidget):
|
||||||
update_hbox.addWidget(btn_check_version)
|
update_hbox.addWidget(btn_check_version)
|
||||||
update_hbox.addStretch()
|
update_hbox.addStretch()
|
||||||
lower_layout.addLayout(update_hbox)
|
lower_layout.addLayout(update_hbox)
|
||||||
lower_layout.addWidget( self.updateLabel )
|
lower_layout.addWidget(self.updateLabel)
|
||||||
|
|
||||||
lower_layout.addStretch()
|
lower_layout.addStretch()
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
"If you are certain you know what you are doing, click"
|
"If you are certain you know what you are doing, click"
|
||||||
" Yes."
|
" Yes."
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Yes |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -798,7 +799,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
" cable unconnected if desired.\n\n"
|
" cable unconnected if desired.\n\n"
|
||||||
"Press Ok when you are ready to continue."
|
"Press Ok when you are ready to continue."
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Ok |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = open_step.exec()
|
response = open_step.exec()
|
||||||
|
@ -824,7 +826,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
" NanoVNA.\n\n"
|
" NanoVNA.\n\n"
|
||||||
"Press Ok when you are ready to continue."
|
"Press Ok when you are ready to continue."
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Ok |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = load_step.exec()
|
response = load_step.exec()
|
||||||
|
@ -884,7 +887,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
" port 0.\n\n"
|
" port 0.\n\n"
|
||||||
"Press Ok when you are ready to continue."
|
"Press Ok when you are ready to continue."
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Ok |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = isolation_step.exec()
|
response = isolation_step.exec()
|
||||||
|
@ -910,7 +914,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
" port 0 and port 1 of the NanoVNA.\n\n"
|
" port 0 and port 1 of the NanoVNA.\n\n"
|
||||||
"Press Ok when you are ready to continue."
|
"Press Ok when you are ready to continue."
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Ok |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = through_step.exec()
|
response = through_step.exec()
|
||||||
|
@ -935,7 +940,8 @@ class CalibrationWindow(QtWidgets.QWidget):
|
||||||
"The calibration process is now complete. Press"
|
"The calibration process is now complete. Press"
|
||||||
' "Apply" to apply the calibration parameters.'
|
' "Apply" to apply the calibration parameters.'
|
||||||
),
|
),
|
||||||
QtWidgets.QMessageBox.StandardButton.Apply | QtWidgets.QMessageBox.StandardButton.Cancel,
|
QtWidgets.QMessageBox.StandardButton.Apply |
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = apply_step.exec()
|
response = apply_step.exec()
|
||||||
|
|
|
@ -30,6 +30,7 @@ logger = logging.getLogger(__name__)
|
||||||
class DeviceSettingsWindow(QtWidgets.QWidget):
|
class DeviceSettingsWindow(QtWidgets.QWidget):
|
||||||
custom_points_checkBox = QtWidgets.QCheckBox
|
custom_points_checkBox = QtWidgets.QCheckBox
|
||||||
custom_points_Eidt = QtWidgets.QLineEdit
|
custom_points_Eidt = QtWidgets.QLineEdit
|
||||||
|
|
||||||
def __init__(self, app: QtWidgets.QWidget):
|
def __init__(self, app: QtWidgets.QWidget):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
@ -99,7 +100,9 @@ class DeviceSettingsWindow(QtWidgets.QWidget):
|
||||||
self.custom_points_checkBox = QtWidgets.QCheckBox("Custom points")
|
self.custom_points_checkBox = QtWidgets.QCheckBox("Custom points")
|
||||||
self.custom_points_checkBox.stateChanged.connect(self.customPoint_check)
|
self.custom_points_checkBox.stateChanged.connect(self.customPoint_check)
|
||||||
self.custom_points_Eidt = QtWidgets.QLineEdit("101")
|
self.custom_points_Eidt = QtWidgets.QLineEdit("101")
|
||||||
self.custom_points_Eidt.setValidator(QIntValidator(self.app.vna.sweep_points_min,self.app.vna.sweep_points_max))
|
self.custom_points_Eidt.setValidator(
|
||||||
|
QIntValidator(self.app.vna.sweep_points_min,
|
||||||
|
self.app.vna.sweep_points_max))
|
||||||
self.custom_points_Eidt.textEdited.connect(self.updatecustomPoint)
|
self.custom_points_Eidt.textEdited.connect(self.updatecustomPoint)
|
||||||
self.custom_points_Eidt.setDisabled(True)
|
self.custom_points_Eidt.setDisabled(True)
|
||||||
|
|
||||||
|
@ -152,7 +155,9 @@ class DeviceSettingsWindow(QtWidgets.QWidget):
|
||||||
|
|
||||||
if "Customizable data points" in features:
|
if "Customizable data points" in features:
|
||||||
self.datapoints.clear()
|
self.datapoints.clear()
|
||||||
self.custom_points_Eidt.setValidator(QIntValidator(self.app.vna.sweep_points_min,self.app.vna.sweep_points_max))
|
self.custom_points_Eidt.setValidator(
|
||||||
|
QIntValidator(self.app.vna.sweep_points_min,
|
||||||
|
self.app.vna.sweep_points_max))
|
||||||
cur_dps = self.app.vna.datapoints
|
cur_dps = self.app.vna.datapoints
|
||||||
for d in sorted(self.app.vna.valid_datapoints):
|
for d in sorted(self.app.vna.valid_datapoints):
|
||||||
self.datapoints.addItem(str(d))
|
self.datapoints.addItem(str(d))
|
||||||
|
@ -200,16 +205,16 @@ class DeviceSettingsWindow(QtWidgets.QWidget):
|
||||||
|
|
||||||
def customPoint_check(self, validate_data: bool):
|
def customPoint_check(self, validate_data: bool):
|
||||||
self.datapoints.setDisabled(validate_data)
|
self.datapoints.setDisabled(validate_data)
|
||||||
self.custom_points_Eidt.setDisabled(not(validate_data))
|
self.custom_points_Eidt.setDisabled(not validate_data)
|
||||||
|
|
||||||
def updatecustomPoint(self,points_str: str):
|
def updatecustomPoint(self, points_str: str):
|
||||||
if self.custom_points_checkBox.isChecked():
|
if self.custom_points_checkBox.isChecked():
|
||||||
#points_str = self.custom_points_Eidt.text()
|
# points_str = self.custom_points_Eidt.text()
|
||||||
if len(points_str) == 0:
|
if len(points_str) == 0:
|
||||||
return
|
return
|
||||||
points = int(points_str)
|
points = int(points_str)
|
||||||
if points < self.app.vna.sweep_points_min:
|
if points < self.app.vna.sweep_points_min:
|
||||||
return
|
return
|
||||||
if points > self.app.vna.sweep_points_max:
|
if points > self.app.vna.sweep_points_max:
|
||||||
points = int(self.app.vna.sweep_points_max)
|
points = int(self.app.vna.sweep_points_max)
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
||||||
logger.info("Invalid color")
|
logger.info("Invalid color")
|
||||||
return
|
return
|
||||||
|
|
||||||
setattr( Chart.color, attr, color ) # update trace color immediately
|
setattr(Chart.color, attr, color) # update trace color immediately
|
||||||
palette = sender.palette()
|
palette = sender.palette()
|
||||||
palette.setColor(QPalette.ColorRole.ButtonText, color)
|
palette.setColor(QPalette.ColorRole.ButtonText, color)
|
||||||
sender.setPalette(palette)
|
sender.setPalette(palette)
|
||||||
|
|
Ładowanie…
Reference in New Issue