From b3b85d33e556f06c88eca9ee8e385a31106a18f1 Mon Sep 17 00:00:00 2001 From: Jan Vrany Date: Wed, 8 Jan 2020 10:16:07 +0000 Subject: [PATCH] Treat all sensor values and signed integers Based on @dlech's suggestion that in LEGO BT protocol all sensor values are signed, this commit changes `Peripheral._convert_bytes()` to treat values as signed (as opposed to unsigned). This commit fixes issue #7. --- bricknil/sensor/peripheral.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bricknil/sensor/peripheral.py b/bricknil/sensor/peripheral.py index 9ba0dc5..a767956 100644 --- a/bricknil/sensor/peripheral.py +++ b/bricknil/sensor/peripheral.py @@ -130,12 +130,12 @@ def _convert_bytes(self, msg_bytes:bytearray, byte_count): If multiple values, then a list of those values Value can be either uint8, uint16, or uint32 depending on value of `byte_count` """ - if byte_count == 1: # just a uint8 - val = msg_bytes[0] - elif byte_count == 2: # uint16 little-endian - val = struct.unpack('