From d708a268ae64a3bbbeeb85faabe4d32e4729deb9 Mon Sep 17 00:00:00 2001 From: blue-j Date: Thu, 14 Nov 2024 12:41:03 -0800 Subject: [PATCH] Update muse.py If control is not enabled, many arguments don't work, including setting the presets necessary to allow PPG signal transmission, for example. I see no problem with enabling control always. --- muselsl/muse.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/muselsl/muse.py b/muselsl/muse.py index 3eb47fc..71bd726 100644 --- a/muselsl/muse.py +++ b/muselsl/muse.py @@ -48,13 +48,13 @@ def __init__(self, self.name = name self.callback_eeg = callback_eeg self.callback_telemetry = callback_telemetry - self.callback_control = callback_control + self.callback_control = callback_control or self._default_control_callback self.callback_acc = callback_acc self.callback_gyro = callback_gyro self.callback_ppg = callback_ppg self.enable_eeg = not callback_eeg is None - self.enable_control = not callback_control is None + self.enable_control = True # Always enable control self.enable_telemetry = not callback_telemetry is None self.enable_acc = not callback_acc is None self.enable_gyro = not callback_gyro is None @@ -66,6 +66,11 @@ def __init__(self, self.preset = preset self.disable_light = disable_light + self._init_control() + + def _default_control_callback(self, message): + logger.info(f"Control message: {message}") + def connect(self, interface=None, retries=0): """Connect to the device""" try: @@ -113,7 +118,7 @@ def connect(self, interface=None, retries=0): if self.enable_ppg: self._subscribe_ppg() - + if self.disable_light: self._disable_light() @@ -146,7 +151,7 @@ def connect(self, interface=None, retries=0): if self.enable_ppg: self._subscribe_ppg() - + if self.disable_light: self._disable_light() @@ -608,6 +613,6 @@ def _unpack_ppg_channel(self, packet): data = res[1:] return packetIndex, data - + def _disable_light(self): self._write_cmd_str('L0')