Skip to content

Commit 720c5e1

Browse files
committed
Update chords_ble in standard form
1 parent e0604b5 commit 720c5e1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

chords_ble.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class Chords_BLE:
1313
CONTROL_CHAR_UUID = "0000ff01-0000-1000-8000-00805f9b34fb"
1414

1515
# Packet parameters
16-
SINGLE_SAMPLE_LEN = 7 # (1 Counter + 3 Channels * 2 bytes)
16+
NUM_CHANNELS = 3
17+
SINGLE_SAMPLE_LEN = (NUM_CHANNELS * 2) + 1 # (1 Counter + Num_Channels * 2 bytes)
1718
BLOCK_COUNT = 10
1819
NEW_PACKET_LEN = SINGLE_SAMPLE_LEN * BLOCK_COUNT
1920

@@ -72,10 +73,8 @@ def process_sample(self, sample_data: bytearray):
7273
if self.start_time is None:
7374
self.start_time = time.time()
7475

75-
channels = [
76-
int.from_bytes(sample_data[1:3], byteorder='big', signed=True),
77-
int.from_bytes(sample_data[3:5], byteorder='big', signed=True),
78-
int.from_bytes(sample_data[5:7], byteorder='big', signed=True)]
76+
channels = [int.from_bytes(sample_data[i:i+2], byteorder='big', signed=True)
77+
for i in range(1, len(sample_data), 2)]
7978

8079
self.samples_received += 1
8180

0 commit comments

Comments
 (0)