@@ -150,10 +150,10 @@ def _conversion_value(self, raw_adc):
150
150
151
151
def _read (self , pin ):
152
152
"""Perform an ADC read. Returns the signed integer result of the read."""
153
- fast = True
154
- if self ._last_pin_read != pin :
153
+ if self .mode == Mode .CONTINUOUS and self ._last_pin_read == pin :
154
+ return self ._conversion_value (self .get_last_result (True ))
155
+ else :
155
156
self ._last_pin_read = pin
156
- fast = False
157
157
config = _ADS1X15_CONFIG_OS_SINGLE
158
158
config |= (pin & 0x07 ) << _ADS1X15_CONFIG_MUX_OFFSET
159
159
config |= _ADS1X15_CONFIG_GAIN [self .gain ]
@@ -162,11 +162,11 @@ def _read(self, pin):
162
162
config |= _ADS1X15_CONFIG_COMP_QUE_DISABLE
163
163
self ._write_register (_ADS1X15_POINTER_CONFIG , config )
164
164
165
- if self .mode == Mode .SINGLE :
166
- while not self ._conversion_complete ():
167
- pass
165
+ if self .mode == Mode .SINGLE :
166
+ while not self ._conversion_complete ():
167
+ pass
168
168
169
- return self ._conversion_value (self .get_last_result (fast ))
169
+ return self ._conversion_value (self .get_last_result (False ))
170
170
171
171
def _conversion_complete (self ):
172
172
"""Return status of ADC conversion."""
@@ -195,7 +195,6 @@ def _read_register(self, reg, fast=False):
195
195
"""Read 16 bit register value. If fast is True, the pointer register
196
196
is not updated.
197
197
"""
198
- self .buf [0 ] = reg
199
198
with self .i2c_device as i2c :
200
199
if fast :
201
200
i2c .readinto (self .buf , end = 2 )
0 commit comments