@@ -150,10 +150,10 @@ def _conversion_value(self, raw_adc):
150150
151151 def _read (self , pin ):
152152 """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 :
155156 self ._last_pin_read = pin
156- fast = False
157157 config = _ADS1X15_CONFIG_OS_SINGLE
158158 config |= (pin & 0x07 ) << _ADS1X15_CONFIG_MUX_OFFSET
159159 config |= _ADS1X15_CONFIG_GAIN [self .gain ]
@@ -162,11 +162,11 @@ def _read(self, pin):
162162 config |= _ADS1X15_CONFIG_COMP_QUE_DISABLE
163163 self ._write_register (_ADS1X15_POINTER_CONFIG , config )
164164
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
168168
169- return self ._conversion_value (self .get_last_result (fast ))
169+ return self ._conversion_value (self .get_last_result (False ))
170170
171171 def _conversion_complete (self ):
172172 """Return status of ADC conversion."""
@@ -195,7 +195,6 @@ def _read_register(self, reg, fast=False):
195195 """Read 16 bit register value. If fast is True, the pointer register
196196 is not updated.
197197 """
198- self .buf [0 ] = reg
199198 with self .i2c_device as i2c :
200199 if fast :
201200 i2c .readinto (self .buf , end = 2 )
0 commit comments