Add basic switch control for white-wired pluto io shield
This commit is contained in:
@ -56,6 +56,9 @@ class MainWindow(QMainWindow):
|
||||
vna_kwargs["ip"] = ip
|
||||
self.vna = Charon(**vna_kwargs)
|
||||
|
||||
self.active_port = 0
|
||||
self.vna.set_switches(a=self.active_port, b=self.active_port)
|
||||
|
||||
mpl.use("QtAgg")
|
||||
|
||||
self.setWindowTitle("Charon VNA")
|
||||
@ -90,6 +93,9 @@ class MainWindow(QMainWindow):
|
||||
action_trigger.triggered.connect(self.capture)
|
||||
action_trigger.setShortcut("Ctrl+T")
|
||||
menu_stimulus.addAction(action_trigger)
|
||||
action_p0 = QAction("Switch &Port", self)
|
||||
action_p0.triggered.connect(self.toggle_port)
|
||||
menu_stimulus.addAction(action_p0)
|
||||
|
||||
menu_calibration = QMenu("&Calibration")
|
||||
menubar.addMenu(menu_calibration)
|
||||
@ -139,6 +145,11 @@ class MainWindow(QMainWindow):
|
||||
widget.setLayout(window_layout)
|
||||
self.setCentralWidget(widget)
|
||||
|
||||
def toggle_port(self):
|
||||
self.active_port = int(not self.active_port)
|
||||
print(f"Activating port {self.active_port}")
|
||||
self.vna.set_switches(a=self.active_port, b=self.active_port)
|
||||
|
||||
def saveas_config(self) -> None:
|
||||
print("Prompting for save path...")
|
||||
dialog = QFileDialog(self)
|
||||
|
@ -140,6 +140,8 @@ class Charon:
|
||||
self._set_dac_code(value=0, channel=1)
|
||||
self._set_dac_code(value=0, channel=2)
|
||||
|
||||
self.set_switches(a=0, b=0)
|
||||
|
||||
def get_config(self) -> Dict[str, Any]:
|
||||
config = dict()
|
||||
config["rx_lo"] = self.sdr.rx_lo
|
||||
@ -171,6 +173,18 @@ class Charon:
|
||||
def _set_dac_voltage(self, voltage: float, channel: Literal[1, 2]):
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_switches(self, a: int, b: int, excitation: int | None = None):
|
||||
if excitation is None:
|
||||
excitation = a
|
||||
|
||||
val = 0
|
||||
|
||||
val |= int(bool(excitation)) << 0 # exc = GPO0
|
||||
val |= int(bool(a)) << 2 # a = GPO2
|
||||
val |= int(bool(b)) << 1 # b = GPO1
|
||||
|
||||
self._set_gpo(val)
|
||||
|
||||
def _set_dac_code(
|
||||
self,
|
||||
value: int,
|
||||
|
Reference in New Issue
Block a user