forked from M-Labs/artiq
moninj: decouple DAC logic and display
This commit is contained in:
parent
6408ae45e0
commit
585d8a4d5b
|
@ -345,11 +345,8 @@ class _DDSHandler:
|
||||||
|
|
||||||
|
|
||||||
class _DACWidget(QtWidgets.QFrame):
|
class _DACWidget(QtWidgets.QFrame):
|
||||||
def __init__(self, dm, spi_channel, channel, title):
|
def __init__(self, channel, title):
|
||||||
QtWidgets.QFrame.__init__(self)
|
QtWidgets.QFrame.__init__(self)
|
||||||
self.spi_channel = spi_channel
|
|
||||||
self.channel = channel
|
|
||||||
self.cur_value = 0
|
|
||||||
|
|
||||||
self.setFrameShape(QtWidgets.QFrame.Box)
|
self.setFrameShape(QtWidgets.QFrame.Box)
|
||||||
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
self.setFrameShadow(QtWidgets.QFrame.Raised)
|
||||||
|
@ -371,22 +368,24 @@ class _DACWidget(QtWidgets.QFrame):
|
||||||
grid.setRowStretch(2, 0)
|
grid.setRowStretch(2, 0)
|
||||||
grid.setRowStretch(3, 1)
|
grid.setRowStretch(3, 1)
|
||||||
|
|
||||||
self.refresh_display()
|
def set_value(self, value):
|
||||||
|
|
||||||
def refresh_display(self):
|
|
||||||
self.value.setText("<font size=\"4\">{:.3f}</font><font size=\"2\"> %</font>"
|
self.value.setText("<font size=\"4\">{:.3f}</font><font size=\"2\"> %</font>"
|
||||||
.format(self.cur_value * 100 / 2**16))
|
.format(value))
|
||||||
|
|
||||||
def sort_key(self):
|
|
||||||
return (self.spi_channel, self.channel)
|
|
||||||
|
|
||||||
|
|
||||||
class _DACHandler:
|
class _DACHandler:
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, dm, spi_channel, channel, title):
|
||||||
self.widget = _DACWidget(*args, **kw)
|
self.widget = _DACWidget(channel, title)
|
||||||
|
self.cur_value = 0
|
||||||
|
self.spi_channel = spi_channel
|
||||||
|
self.channel = channel
|
||||||
|
self.refresh_display()
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def refresh_display(self):
|
||||||
return getattr(self.widget, attr)
|
self.widget.set_value(self.cur_value * 100 / 2**16)
|
||||||
|
|
||||||
|
def sort_key(self):
|
||||||
|
return (self.spi_channel, self.channel)
|
||||||
|
|
||||||
|
|
||||||
_HandlerDesc = namedtuple("_HandlerDesc", "uid comment cls arguments")
|
_HandlerDesc = namedtuple("_HandlerDesc", "uid comment cls arguments")
|
||||||
|
|
Loading…
Reference in New Issue