-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Currently it seems that the ESP32 wire library doesn support the 5 params requestFrom() command. So as it is now, your library isn't compatible with ESP32. I have modified your read() function to be compatible on the ESP32, i am unshure it is the best way to do it, but it is working on my setup.!
`void LIDARLite_v3HP::read(uint8_t regAddr, uint8_t * dataBytes,
uint8_t numBytes, uint8_t lidarliteAddress)
{
// This single function performs the following actions -
// 1) I2C START
// 2) I2C write to set the address
// 3) I2C REPEATED START
// 4) I2C read to fetch the required data
// 5) I2C STOP
Wire.beginTransmission(lidarliteAddress);
Wire.write(regAddr);
if(!Wire.endTransmission()){
Wire.requestFrom
(
lidarliteAddress, // Slave address
numBytes, // number of consecutive bytes to read
//regAddr, // address of first register to read
//1, // number of bytes in regAddr
true // true = set STOP condition following I2C read
);
uint8_t numHere = Wire.available();
uint8_t i = 0;
while (i < numHere)
{
dataBytes[i] = Wire.read();
i++;
}
delayMicroseconds(100); // 100 us delay for robustness with successive reads and writes
}else{
Serial.println("> nack");
}
} /* LIDARLite_v3HP::read */`