@@ -590,7 +590,6 @@ def _read_register(self, register):
590
590
raise ValueError ("Register value must be in the range of 0x00 to 0x08" )
591
591
592
592
with self ._i2c as i2c :
593
- i2c .write (bytes ([0x00 ]))
594
593
# Write to the base address, then read all data registers in a
595
594
# single block read. Then return the desired value from the list.
596
595
# Successive individual byte reads, tend to fail. This trick
@@ -600,7 +599,7 @@ def _read_register(self, register):
600
599
# trick is required because smbus doesn't support repeated I2C
601
600
# starts to read the registers directly (singularly) on the sensor.
602
601
result = bytearray (9 )
603
- i2c .readinto ( result )
602
+ i2c .write_then_readinto ( bytes ([ 0x00 ]), result )
604
603
if self ._debug :
605
604
print ([hex (i ) for i in result ])
606
605
print ("$%02X => %s" % (register , hex (result [register ])))
@@ -612,7 +611,6 @@ def _read_byte(self, register):
612
611
# contains the lightning look-up tables and calibration registers.
613
612
# The read_register is more efficent for more frequent data registers.
614
613
with self ._i2c as i2c :
615
- i2c .write (bytes ([0x00 ]))
616
614
# Write to the base address, then read all data registers in a
617
615
# single block read. Then return the desired value from the list.
618
616
# Successive individual byte reads, tend to fail. This trick
@@ -624,7 +622,7 @@ def _read_byte(self, register):
624
622
# trick is required because smbus doesn't support repeated I2C
625
623
# starts to read the registers directly (singularly) on the sensor.
626
624
result = bytearray (0x3E )
627
- i2c .readinto ( result )
625
+ i2c .write_then_readinto ( bytes ([ 0x00 ]), result )
628
626
if self ._debug :
629
627
print ([hex (i ) for i in result ])
630
628
print ("$%02X => %s" % (register , hex (result [register ])))
0 commit comments