Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit 84150f9

Browse files
committed
use the proper function for reading 16 bit values
some devices (such as the MPR121 touch sensor) will malfunction if you try to read the 2 bytes separately
1 parent 501c1ce commit 84150f9

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Adafruit_I2C/Adafruit_I2C.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def readS8(self, reg):
117117
def readU16(self, reg):
118118
"Reads an unsigned 16-bit value from the I2C device"
119119
try:
120-
hibyte = self.readU8(reg)
121-
lobyte = self.readU8(reg+1)
122-
result = (hibyte << 8) + lobyte
120+
result = self.bus.read_word_data(self.address,reg)
123121
if (self.debug):
124122
print "I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg)
125123
return result

0 commit comments

Comments
 (0)