Informatic0re
04/03/2024, 1:09 PM0x010F but if I try to read it with toit I get the following error
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.143>
******************************************************************************
EXCEPTION error.
INVALID_ARGUMENT
0: i2c-read-reg_ <sdk>\i2c.toit:314:3
1: Bus.read-reg_ <sdk>\i2c.toit:115:10
2: Device.read-reg <sdk>\i2c.toit:242:17
3: Device.read-reg <sdk>\i2c.toit:235:12
4: Registers.read-bytes <sdk>\i2c.toit:291:20
5: Registers.read-u16-be <sdk>\serial\registers.toit:83:14
6: VL53L4CD-DRIVER.get-identification-model-id toit\vl53l4cd-driver.toit:25:22
7: VL53L4CD.get-id toit\vl53l4cd.toit:26:20
8: main toit\examples\05-vl534cd.toit:23:29
******************************************************************************
Is there a way of setting this address or still get to read this vlaue somehow using whats implemented in toit already?floitsch
04/03/2024, 1:22 PMread-reg, though. Let me check.floitsch
04/03/2024, 1:24 PMdevice.read-address #[0x01, 0x0F] <length>Informatic0re
04/03/2024, 1:25 PMInformatic0re
04/03/2024, 1:28 PMIDENTIFICATION_MODEL_ID ::= 0x010F into an ByteArray or do I have to change this constants into ByteArrays? Whats better?erikcorry
04/03/2024, 1:43 PMcast value/int -> ByteArray
return #[value >> 8, value]RaspPi Parts
04/04/2024, 8:15 AMfloitsch
04/04/2024, 8:18 AMread-reg function only takes 8-bit addresses. For accessing registers with 16 (or more) bits one needs to use read-address.Informatic0re
04/04/2024, 8:37 AMInformatic0re
04/04/2024, 8:38 AMInformatic0re
04/04/2024, 8:39 AMimport binary show LITTLE-ENDIAN BIG-ENDIAN
pack-16 value -> ByteArray:
buffer := ByteArray 2
BIG-ENDIAN.put-uint16 buffer 0 value
return buffer
unpack-16 buffer/ByteArray:
return BIG-ENDIAN.uint16 buffer 0
pack-32 value -> ByteArray:
buffer := ByteArray 4
BIG-ENDIAN.put-uint32 buffer 0 value
return buffer
unpack-32 buffer/ByteArray:
return BIG-ENDIAN.uint32 buffer 0floitsch
04/04/2024, 9:32 AM