From 0df53d0485da02971a84e0898f370750b5e6b72f Mon Sep 17 00:00:00 2001 From: Florian Rau Date: Wed, 1 Nov 2023 13:28:58 +0000 Subject: [PATCH] disable button for toggling LED if hardware does not support it --- iblrig/gui/wizard.py | 4 ++++ iblrig/hardware.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/iblrig/gui/wizard.py b/iblrig/gui/wizard.py index bffcbd700..d982a91a1 100644 --- a/iblrig/gui/wizard.py +++ b/iblrig/gui/wizard.py @@ -232,6 +232,10 @@ def __init__(self, *args, **kwargs): # anydesk_worker.signals.result.connect(lambda var: print(f'Your AnyDesk ID: {var:s}')) # QThreadPool.globalInstance().tryStart(anydesk_worker) + # disable control of LED if Bpod does not have the respective capability + bpod = Bpod(self.model.hardware_settings['device_bpod']['COM_BPOD'], skip_initialization=True) + self.uiPushStatusLED.setEnabled(bpod.can_control_led) + # check for update update_worker = Worker(check_for_updates) update_worker.signals.result.connect(self._on_check_update_result) diff --git a/iblrig/hardware.py b/iblrig/hardware.py index 68f340027..05ee6b5c3 100644 --- a/iblrig/hardware.py +++ b/iblrig/hardware.py @@ -28,10 +28,10 @@ class Bpod(BpodIO): + can_control_led = True _instances = {} _lock = threading.Lock() _is_initialized = False - _can_control_led = True def __new__(cls, *args, **kwargs): serial_port = args[0] if len(args) > 0 else '' @@ -66,7 +66,7 @@ def __init__(self, *args, skip_initialization: bool = False, **kwargs): "Please unplug the Bpod USB cable from the computer and plug it back in to start the task. ") from e self.default_message_idx = 0 self.actions = Bunch({}) - self._can_control_led = self.set_status_led(True) + self.can_control_led = self.set_status_led(True) self._is_initialized = True def close(self) -> None: @@ -183,7 +183,7 @@ def toggle_valve(self, duration=None): @static_vars(supported=True) def set_status_led(self, state: bool) -> bool: - if self._can_control_led and self._arcom is not None: + if self.can_control_led and self._arcom is not None: try: log.info(f'{"en" if state else "dis"}abling Bpod Status LED') command = struct.pack("cB", b":", state)