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 31
31
__version__ = "0.0.0-auto.0"
32
32
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
33
33
34
+ import time
34
35
from micropython import const
35
36
from adafruit_bus_device .i2c_device import I2CDevice
36
37
@@ -161,7 +162,10 @@ def _read(self, pin):
161
162
if self .mode == Mode .CONTINUOUS and self ._last_pin_read == pin :
162
163
return self ._conversion_value (self .get_last_result (True ))
163
164
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
165
169
config |= (pin & 0x07 ) << _ADS1X15_CONFIG_MUX_OFFSET
166
170
config |= _ADS1X15_CONFIG_GAIN [self .gain ]
167
171
config |= self .mode
@@ -170,8 +174,12 @@ def _read(self, pin):
170
174
self ._write_register (_ADS1X15_POINTER_CONFIG , config )
171
175
172
176
if self .mode == Mode .SINGLE :
177
+ # poll conversion complete status bit
173
178
while not self ._conversion_complete ():
174
179
pass
180
+ else :
181
+ # just sleep (can't poll in continuous)
182
+ time .sleep (2 / self .data_rate )
175
183
176
184
return self ._conversion_value (self .get_last_result (False ))
177
185
You can’t perform that action at this time.
0 commit comments