switch back to averaging multiple ADC readings. More reliable.
This commit is contained in:
parent
f632aaddc3
commit
003bb7d96a
@ -28,11 +28,11 @@ class BasePotentiometer:
|
|||||||
# AnalogRead always reports 16 bit values - truncate to 6 to de-noise
|
# AnalogRead always reports 16 bit values - truncate to 6 to de-noise
|
||||||
# convert to percentage and round to quarter of a percent
|
# convert to percentage and round to quarter of a percent
|
||||||
|
|
||||||
# readings = [(self.read_pin.value >> (16 - self._truncate_bits)) for i in range(3)]
|
readings = [(self.read_pin.value >> (16 - self._truncate_bits)) for i in range(3)]
|
||||||
# reading = sum(readings) / len(readings)
|
reading = sum(readings) / len(readings)
|
||||||
|
|
||||||
|
|
||||||
reading = self.read_pin.value >> 10
|
# reading = self.read_pin.value >> 10
|
||||||
dec_val = reading / (pow(2, self._truncate_bits) - 1)
|
dec_val = reading / (pow(2, self._truncate_bits) - 1)
|
||||||
|
|
||||||
# new_pos = round(dec_val * 4, 1) / 4
|
# new_pos = round(dec_val * 4, 1) / 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user