We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a44e06 commit 14964a8Copy full SHA for 14964a8
adafruit_mcp3xxx/analog_in.py
@@ -55,9 +55,10 @@ def __init__(
55
@property
56
def value(self) -> int:
57
"""Returns the value of an ADC pin as an integer in the range [0, 65535]."""
58
- return int(
59
- self._mcp.read(self._pin_setting, is_differential=self.is_differential)
60
- * (65535 / 1023)
+ # Initial result is only 10 bits.
+ result = int(self._mcp.read(self._pin_setting, is_differential=self.is_differential))
+ # Stretch to 16 bits and cover full range.
61
+ return (result << 6) | (result >> 4)
62
)
63
64
0 commit comments