Skip to content

Commit 24c10da

Browse files
committed
ganglion: fix decompress of negative numbers
1 parent 8339f2c commit 24c10da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

open_bci_ganglion.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,12 @@ def conv19bitToInt32 (threeByteBuffer):
453453

454454
prefix = 0;
455455

456+
# if LSB is 1, negative number, some hasty unsigned to signed conversion to do
456457
if threeByteBuffer[2] & 0x01 > 0:
457458
prefix = 0b1111111111111;
458-
459-
return (prefix << 19) | (threeByteBuffer[0] << 16) | (threeByteBuffer[1] << 8) | threeByteBuffer[2]
459+
return ((prefix << 19) | (threeByteBuffer[0] << 16) | (threeByteBuffer[1] << 8) | threeByteBuffer[2]) | ~0xFFFFFFFF
460+
else:
461+
return (prefix << 19) | (threeByteBuffer[0] << 16) | (threeByteBuffer[1] << 8) | threeByteBuffer[2]
460462

461463
def decompressDeltas19Bit(buffer):
462464
"""

0 commit comments

Comments
 (0)