src/vl53l1x.cpp
uint16_t Vl53l1x::encodeTimeout(uint32_t timeout_mclks)
{
  // encoded format: "(LSByte * 2^MSByte) + 1"

  uint32_t ls_byte = 0;
  uint16_t ms_byte = 0;

  if (timeout_mclks > 0)
  {
    ls_byte = timeout_mclks - 1;

    while ((ls_byte & 0xFFFFFF00) > 0)
    {
      ls_byte >>= 1;
      ms_byte++;
    }

    return (ms_byte << 8) | (ls_byte & 0xFF);
  }
  else { return 0; }
}
// Encode sequence step timeout register value from timeout in MCLKs
// based on VL53L1_encode_timeout()
Encode sequence step timeout register value from timeout in MCLKs
based on VL53L1_encode_timeout()
Encode sequence step timeout register value from timeout in MCLKs based on VL53L1_encode_timeout ()
uint16_t Vl53l1x::encodeTimeout(uint32_t timeout_mclks)
{
  uint32_t ls_byte = 0;
  uint16_t ms_byte = 0;
  if (timeout_mclks > 0)
  {
    ls_byte = timeout_mclks - 1;
    while ((ls_byte & 0xFFFFFF00) > 0)
    {
      ls_byte >>= 1;
      ms_byte++;
    }
    return (ms_byte << 8) | (ls_byte & 0xFF);
  }
  else { return 0; }
}
uint16_t Vl53l1x :: encodeTimeout ( uint32_t timeout_mclks ) { uint32_t ls_byte = 0 ; uint16_t ms_byte = 0 ; if ( timeout_mclks > 0 ) { ls_byte = timeout_mclks - 1 ; while ( ( ls_byte & 0xFFFFFF00 ) > 0 ) { ls_byte >>= 1 ; ms_byte ++ ; } return ( ms_byte << 8 ) | ( ls_byte & 0xFF ) ; } else { return 0 ; } }
Encode sequence step timeout register value from timeout in MCLKs
based on VL53L1_encode_timeout()
Encode sequence step timeout register value from timeout in MCLKs based on VL53L1_encode_timeout ()
// encoded format: "(LSByte * 2^MSByte) + 1"