Compare commits
1 commit
master
...
remove-bad
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ec60b6188 |
2 changed files with 1 additions and 13 deletions
|
|
@ -31,11 +31,9 @@ CircuitPython base class driver for ADS1015/1115 ADCs.
|
||||||
__version__ = "0.0.0-auto.0"
|
__version__ = "0.0.0-auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
||||||
|
|
||||||
import time
|
|
||||||
from micropython import const
|
from micropython import const
|
||||||
from adafruit_bus_device.i2c_device import I2CDevice
|
from adafruit_bus_device.i2c_device import I2CDevice
|
||||||
|
|
||||||
# pylint: disable=bad-whitespace
|
|
||||||
_ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
_ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
||||||
_ADS1X15_POINTER_CONVERSION = const(0x00)
|
_ADS1X15_POINTER_CONVERSION = const(0x00)
|
||||||
_ADS1X15_POINTER_CONFIG = const(0x01)
|
_ADS1X15_POINTER_CONFIG = const(0x01)
|
||||||
|
|
@ -50,7 +48,6 @@ _ADS1X15_CONFIG_GAIN = {
|
||||||
8: 0x0800,
|
8: 0x0800,
|
||||||
16: 0x0A00,
|
16: 0x0A00,
|
||||||
}
|
}
|
||||||
# pylint: enable=bad-whitespace
|
|
||||||
|
|
||||||
|
|
||||||
class Mode:
|
class Mode:
|
||||||
|
|
@ -162,10 +159,7 @@ class ADS1x15:
|
||||||
if self.mode == Mode.CONTINUOUS and self._last_pin_read == pin:
|
if self.mode == Mode.CONTINUOUS and self._last_pin_read == pin:
|
||||||
return self._conversion_value(self.get_last_result(True))
|
return self._conversion_value(self.get_last_result(True))
|
||||||
self._last_pin_read = pin
|
self._last_pin_read = pin
|
||||||
if self.mode == Mode.SINGLE:
|
config = _ADS1X15_CONFIG_OS_SINGLE
|
||||||
config = _ADS1X15_CONFIG_OS_SINGLE
|
|
||||||
else:
|
|
||||||
config = 0
|
|
||||||
config |= (pin & 0x07) << _ADS1X15_CONFIG_MUX_OFFSET
|
config |= (pin & 0x07) << _ADS1X15_CONFIG_MUX_OFFSET
|
||||||
config |= _ADS1X15_CONFIG_GAIN[self.gain]
|
config |= _ADS1X15_CONFIG_GAIN[self.gain]
|
||||||
config |= self.mode
|
config |= self.mode
|
||||||
|
|
@ -174,12 +168,8 @@ class ADS1x15:
|
||||||
self._write_register(_ADS1X15_POINTER_CONFIG, config)
|
self._write_register(_ADS1X15_POINTER_CONFIG, config)
|
||||||
|
|
||||||
if self.mode == Mode.SINGLE:
|
if self.mode == Mode.SINGLE:
|
||||||
# poll conversion complete status bit
|
|
||||||
while not self._conversion_complete():
|
while not self._conversion_complete():
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
# just sleep (can't poll in continuous)
|
|
||||||
time.sleep(2 / self.data_rate)
|
|
||||||
|
|
||||||
return self._conversion_value(self.get_last_result(False))
|
return self._conversion_value(self.get_last_result(False))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,8 @@ differential ADC readings.
|
||||||
* Author(s): Carter Nelson, adapted from MCP3xxx original by Brent Rubell
|
* Author(s): Carter Nelson, adapted from MCP3xxx original by Brent Rubell
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=bad-whitespace
|
|
||||||
_ADS1X15_DIFF_CHANNELS = {(0, 1): 0, (0, 3): 1, (1, 3): 2, (2, 3): 3}
|
_ADS1X15_DIFF_CHANNELS = {(0, 1): 0, (0, 3): 1, (1, 3): 2, (2, 3): 3}
|
||||||
_ADS1X15_PGA_RANGE = {2 / 3: 6.144, 1: 4.096, 2: 2.048, 4: 1.024, 8: 0.512, 16: 0.256}
|
_ADS1X15_PGA_RANGE = {2 / 3: 6.144, 1: 4.096, 2: 2.048, 4: 1.024, 8: 0.512, 16: 0.256}
|
||||||
# pylint: enable=bad-whitespace
|
|
||||||
|
|
||||||
|
|
||||||
class AnalogIn:
|
class AnalogIn:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue