Skip to content

Commit

Permalink
Merge pull request #4 from BlitzCityDIY/main
Browse files Browse the repository at this point in the history
18-bit fix
  • Loading branch information
BlitzCityDIY authored Jan 11, 2024
2 parents ebdc0da + 45636e2 commit 975d1af
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions adafruit_mcp3421/mcp3421.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def read(self) -> int:
adc_value = (
(self.adc_data[0] << 16) | (self.adc_data[1] << 8) | self.adc_data[2]
)
if self.adc_data[0] & 0x02: # Extend the sign if the top bit is set
adc_value |= 0xFF000000

if self.adc_data[0] & 0x80: # Extend the sign if the top bit is set
adc_value = adc_value - 0x1000000 # Sign-extend to 32 bits
return adc_value

0 comments on commit 975d1af

Please sign in to comment.