forked from M-Labs/artiq
1
0
Fork 0

moninj: separate DDS further

This commit is contained in:
Simon Renblad 2024-04-26 14:49:52 +08:00
parent 3b8f6edd52
commit 5fd42dc0e2
1 changed files with 14 additions and 9 deletions

View File

@ -155,11 +155,12 @@ class _TTLHandler:
class _DDSWidget(QtWidgets.QFrame):
apply_changes = QtCore.pyqtSignal()
off_clicked = QtCore.pyqtSignal()
set_clicked = QtCore.pyqtSignal()
def __init__(self, title, is_urukul):
QtWidgets.QFrame.__init__(self)
self._value = 0
self.setFrameShape(QtWidgets.QFrame.Box)
self.setFrameShadow(QtWidgets.QFrame.Raised)
@ -245,20 +246,29 @@ class _DDSWidget(QtWidgets.QFrame):
grid.setRowStretch(3, 1)
set_btn.clicked.connect(self.set_clicked)
apply.clicked.connect(self.apply_changes)
apply.clicked.connect(self._apply_changes)
if is_urukul:
off_btn.clicked.connect(self.off_clicked)
off_btn.setToolTip(textwrap.dedent(
"""Note: If TTL RTIO sw for the channel is switched high,
this button will not disable the channel.
Use the TTL override instead."""))
self.value_edit.returnPressed.connect(self.apply_changes)
self.value_edit.returnPressed.connect(self._apply_changes)
def cancel_changes(cancel):
self.set_page(0)
self.value_edit.escapePressedConnect(cancel_changes)
cancel.clicked.connect(cancel_changes)
def _apply_changes(self):
self.widget.set_page(0)
self.apply_changes.emit()
def set_clicked(self):
self.set_page(1)
self.set_edit_value(self._value)
self.start_edit()
def set_page(self, page):
self.data_stack.setCurrentIndex(page)
self.button_stack.setCurrentIndex(page)
@ -271,6 +281,7 @@ class _DDSWidget(QtWidgets.QFrame):
def set_value(self, value):
self.value_label.setText("<font size=\"4\">{:.7f}</font>".format(value))
self._value = value
self.set_edit_value(value)
def start_edit(self):
@ -308,7 +319,6 @@ class _DDSHandler:
self.widget = _DDSWidget(title, self.is_urukul)
self.widget.apply_changes.connect(self.apply_changes)
self.widget.off_clicked.connect(self.off_clicked)
self.widget.set_clicked.connect(self.set_clicked)
self.refresh_display()
def monitor_update(self, probe, value):
@ -323,14 +333,9 @@ class _DDSHandler:
self.widget.set_value(self.cur_frequency / 1e6)
def apply_changes(self):
self.widget.set_page(0)
frequency = self.widget.get_value() * 1e6
self.dm.dds_set_frequency(self.dds_name, frequency)
def set_clicked(self):
self.widget.set_page(1)
self.widget.set_edit_value(self.cur_frequency / 1e6)
self.widget.start_edit()
def off_clicked(self):
self.dm.dds_channel_toggle(self.dds_name, sw=False)