Skip to content

Commit ea979e3

Browse files
committed
Adding bit resolution with lsl stream
1 parent 2b1049b commit ea979e3

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

chordspy/chords_serial.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ class Chords_USB:
4141

4242
# Supported boards with their sampling rate and Number of Channels
4343
supported_boards = {
44-
"UNO-R3": {"sampling_rate": 250, "Num_channels": 6},
45-
"UNO-CLONE": {"sampling_rate": 250, "Num_channels": 6},
46-
"GENUINO-UNO": {"sampling_rate": 250, "Num_channels": 6},
47-
"UNO-R4": {"sampling_rate": 500, "Num_channels": 6},
48-
"RPI-PICO-RP2040": {"sampling_rate": 500, "Num_channels": 3},
49-
"NANO-CLONE": {"sampling_rate": 250, "Num_channels": 8},
50-
"NANO-CLASSIC": {"sampling_rate": 250, "Num_channels": 8},
51-
"STM32F4-BLACK-PILL": {"sampling_rate": 500, "Num_channels": 8},
52-
"STM32G4-CORE-BOARD": {"sampling_rate": 500, "Num_channels": 16},
53-
"MEGA-2560-R3": {"sampling_rate": 250, "Num_channels": 16},
54-
"MEGA-2560-CLONE": {"sampling_rate": 250, "Num_channels": 16},
55-
"GIGA-R1": {"sampling_rate": 500, "Num_channels": 6},
56-
"NPG-LITE": {"sampling_rate": 500, "Num_channels": 3},
44+
"UNO-R3": {"sampling_rate": 250, "Num_channels": 6, "resolution": 10},
45+
"UNO-CLONE": {"sampling_rate": 250, "Num_channels": 6, "resolution": 10},
46+
"GENUINO-UNO": {"sampling_rate": 250, "Num_channels": 6, "resolution": 10},
47+
"UNO-R4": {"sampling_rate": 500, "Num_channels": 6, "resolution": 14},
48+
"RPI-PICO-RP2040": {"sampling_rate": 500, "Num_channels": 3, "resolution": 12},
49+
"NANO-CLONE": {"sampling_rate": 250, "Num_channels": 8, "resolution": 10},
50+
"NANO-CLASSIC": {"sampling_rate": 250, "Num_channels": 8, "resolution": 10},
51+
"STM32F4-BLACK-PILL": {"sampling_rate": 500, "Num_channels": 8, "resolution": 12},
52+
"STM32G4-CORE-BOARD": {"sampling_rate": 500, "Num_channels": 16, "resolution": 12},
53+
"MEGA-2560-R3": {"sampling_rate": 250, "Num_channels": 16, "resolution": 10},
54+
"MEGA-2560-CLONE": {"sampling_rate": 250, "Num_channels": 16, "resolution": 10},
55+
"GIGA-R1": {"sampling_rate": 500, "Num_channels": 6, "resolution": 16},
56+
"NPG-LITE": {"sampling_rate": 500, "Num_channels": 3, "resolution": 12},
5757
}
5858

5959
def __init__(self):

chordspy/connection.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(self):
6161
self.stream_type = "EXG" # LSL stream type
6262
self.stream_format = "float32" # Data format for LSL samples
6363
self.stream_id = "UDL" # Unique stream identifier
64+
self.resolution = 12 # Resolution bit for stream
6465

6566
# Data Tracking Systems
6667
self.last_sample = None # Stores the most recent sample received
@@ -131,8 +132,15 @@ def setup_lsl(self, num_channels, sampling_rate):
131132
"""
132133
# Create LSL stream info with configured parameters
133134
info = StreamInfo(self.stream_name, self.stream_type, num_channels, sampling_rate, self.stream_format, self.stream_id)
134-
self.lsl_connection = StreamOutlet(info) # Initialize LSL outlet
135-
print(f"LSL stream started: {num_channels} channels at {sampling_rate}Hz")
135+
136+
# Add resolution information to the stream description
137+
desc = info.desc()
138+
resinfo = desc.append_child("resinfo")
139+
resolution = getattr(self, 'resolution', 12)
140+
resinfo.append_child_value("resolution", str(resolution))
141+
142+
self.lsl_connection = StreamOutlet(info)
143+
print(f"LSL stream started: {num_channels} channels at {sampling_rate}Hz with {resolution}-bit resolution")
136144
self.stream_active = True
137145
self.num_channels = num_channels
138146
self.sampling_rate = sampling_rate
@@ -539,6 +547,9 @@ def connect_usb(self):
539547
board_config = self.usb_connection.supported_boards[self.usb_connection.board]
540548
self.sampling_rate = board_config["sampling_rate"]
541549

550+
# Get resolution from board config (with fallback to 12)
551+
self.resolution = board_config.get("resolution", 12)
552+
542553
# Initialize LSL stream
543554
self.setup_lsl(self.num_channels, self.sampling_rate)
544555

0 commit comments

Comments
 (0)