Skip to content

Commit c16703f

Browse files
authored
Merge pull request #5 from NanoExplorer/struct_features
switch from custom short int parser to builtin
2 parents 06ef440 + 7b40296 commit c16703f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

adafruit_ble_lywsd03mmc.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ def temperature_humidity(self) -> Optional[Tuple[float, int]]:
7575
data = self._readings_buf
7676
length = self.readings.readinto(data)
7777
if length > 0:
78-
low_temp, high_temp, hum = struct.unpack_from("<BBB", data)
79-
sign = high_temp & 0x80
80-
temp = ((high_temp & 0x7F) << 8) | low_temp
81-
if sign:
82-
temp = temp - 32767
78+
temp, hum = struct.unpack_from("<hB", data)
8379
temp = temp / 100
8480
return (temp, hum)
8581
# No data.

0 commit comments

Comments
 (0)