Skip to content

Commit

Permalink
limit LSL triggers to [1, 127]
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheltienne committed Aug 30, 2023
1 parent 7ff0c31 commit 743f0df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bsl/triggers/lsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ def __init__(self, name: str):
stype="Markers",
n_channels=1,
sfreq=0.0,
dtype="uint8",
dtype="int8",
source_id=f"BSL-{name}",
)
self._outlet = StreamOutlet(self._sinfo, max_buffered=1)

@copy_doc(BaseTrigger.signal)
def signal(self, value: int) -> None:
super().signal(value)
self._outlet.push_sample(np.array([value], dtype=np.uint8))
if not (1 <= value <= 127):
raise ValueError(
"The argument 'value' of an LSL trigger must be an integer "
"between 1 and 127 included."
)
self._outlet.push_sample(np.array([value], dtype=np.int8))

def close(self) -> None:
"""Close the LSL outlet."""
Expand Down

0 comments on commit 743f0df

Please sign in to comment.