src/vl53l1x.cpp
uint8_t Vl53l1x::readReg(uint16_t reg)
{
  uint8_t  writeBuffer[2];

  writeBuffer[0] = ((reg >> 8) & 0xFF);  // reg high byte
  writeBuffer[1] = (reg        & 0xFF);  // reg low byte


  if( write(fd, writeBuffer, sizeof(writeBuffer)) < sizeof(writeBuffer)) {
    //something went wrong
    std::cout << "DEBUG: ERROR on write to i2c" << std::endl;
    return 0x00;
  }

  uint8_t readBuffer[1];
  read(fd, readBuffer, sizeof(readBuffer));

  return readBuffer[0];
}
// Read an 8-bit register
Read an 8-bit register
Read an 8 - bit register
uint8_t Vl53l1x::readReg(uint16_t reg)
{
  uint8_t  writeBuffer[2];
  writeBuffer[0] = ((reg >> 8) & 0xFF);  
  writeBuffer[1] = (reg        & 0xFF);  
  if( write(fd, writeBuffer, sizeof(writeBuffer)) < sizeof(writeBuffer)) {
    std::cout << "DEBUG: ERROR on write to i2c" << std::endl;
    return 0x00;
  }
  uint8_t readBuffer[1];
  read(fd, readBuffer, sizeof(readBuffer));
  return readBuffer[0];
}
uint8_t Vl53l1x :: readReg ( uint16_t reg ) { uint8_t writeBuffer [ 2 ] ; writeBuffer [ 0 ] = ( ( reg >> 8 ) & 0xFF ) ; writeBuffer [ 1 ] = ( reg & 0xFF ) ; if ( write ( fd , writeBuffer , sizeof ( writeBuffer ) ) < sizeof ( writeBuffer ) ) { std :: cout << " " << std :: endl ; return 0x00 ; } uint8_t readBuffer [ 1 ] ; read ( fd , readBuffer , sizeof ( readBuffer ) ) ; return readBuffer [ 0 ] ; }
Read an 8-bit register
Read an 8 - bit register
// reg high byte // reg low byte //something went wrong