Skip to content

Commit

Permalink
disable button for toggling LED if hardware does not support it
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Nov 1, 2023
1 parent c301402 commit 0df53d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions iblrig/gui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions iblrig/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0df53d0

Please sign in to comment.