@@ -145,7 +145,8 @@ def _read_register(self, reg):
145
145
i2c .write (self .buf , end = 1 , stop = False )
146
146
i2c .readinto (self .buf , start = 1 )
147
147
# LSB MSB
148
- return self .buf [2 ], self .buf [1 ]
148
+ #return self.buf[2], self.buf[1]
149
+ return self .buf [1 ] << 8 | self .buf [2 ]
149
150
150
151
def _data_rate_default (self ):
151
152
"""Retrieve the default data rate for this ADC (in samples per second).
@@ -185,7 +186,8 @@ def _conversion_complete(self):
185
186
# OS is bit 15
186
187
# OS = 0: Device is currently performing a conversion
187
188
# OS = 1: Device is not currently performing a conversion
188
- return self ._read_register (ADS1X15_POINTER_CONFIG )[1 ] & 0x80
189
+ #return self._read_register(ADS1X15_POINTER_CONFIG)[1] & 0x80
190
+ return self ._read_register (ADS1X15_POINTER_CONFIG ) & 0x8000
189
191
190
192
def _read (self , mux , gain , data_rate , mode ):
191
193
"""Perform an ADC read with the provided mux, gain, data_rate, and mode
@@ -229,4 +231,6 @@ def get_last_result(self):
229
231
"""
230
232
# Retrieve the conversion register value, convert to a signed int, and
231
233
# return it.
232
- return self ._conversion_value (* self ._read_register (ADS1X15_POINTER_CONVERSION ))
234
+ #return self._conversion_value(*self._read_register(ADS1X15_POINTER_CONVERSION))
235
+ result = self ._read_register (ADS1X15_POINTER_CONVERSION )
236
+ return self ._conversion_value (result & 0xff , result >> 8 )
0 commit comments