File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 3131__version__ = "0.0.0-auto.0"
3232__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
3333
34+ import time
3435from micropython import const
3536from adafruit_bus_device .i2c_device import I2CDevice
3637
@@ -161,7 +162,10 @@ def _read(self, pin):
161162 if self .mode == Mode .CONTINUOUS and self ._last_pin_read == pin :
162163 return self ._conversion_value (self .get_last_result (True ))
163164 self ._last_pin_read = pin
164- config = _ADS1X15_CONFIG_OS_SINGLE
165+ if self .mode == Mode .SINGLE :
166+ config = _ADS1X15_CONFIG_OS_SINGLE
167+ else :
168+ config = 0
165169 config |= (pin & 0x07 ) << _ADS1X15_CONFIG_MUX_OFFSET
166170 config |= _ADS1X15_CONFIG_GAIN [self .gain ]
167171 config |= self .mode
@@ -170,8 +174,12 @@ def _read(self, pin):
170174 self ._write_register (_ADS1X15_POINTER_CONFIG , config )
171175
172176 if self .mode == Mode .SINGLE :
177+ # poll conversion complete status bit
173178 while not self ._conversion_complete ():
174179 pass
180+ else :
181+ # just sleep (can't poll in continuous)
182+ time .sleep (2 / self .data_rate )
175183
176184 return self ._conversion_value (self .get_last_result (False ))
177185
You can’t perform that action at this time.
0 commit comments