Closed TiagoSeverino closed 2 years ago
When I compile, it throws an error:
VL53L0X.cpp:305:36: error: call of overloaded 'write(long unsigned int)' is ambiguous
.
I had to cast all values to make it work. I guess my compiler assumes the result of the bitwise operation is an uint32_t.
I'm using PlatformIO in Visual Studio Code, with STM32Duino on a STM32F103C8T6.
Sorry, seems like we forgot about this back then. I just released an update that should fix this issue using a slightly different method (casting to uint8_t
instead of int
). Thanks for bringing it to our attention and submitting a pull request though.
For some background, we now understand the issue is due to some platform definitions having multiple (unnecessary?) overloads of the Wire.write()
function that take different types (such as uint8_t
and int
), and when we try to call it with something that doesn't exactly match one of those types (in this case a long unsigned int
), the compiler doesn't know which overload to use. So the best thing to do seems to be explicitly casting the argument to uint8_t
since write()
only operates with one byte at a time anyway.
I'm not sure why it would be necessary to cast the result of each calculation to an int before passing it to
Wire.write()
(which takes auint8_t
anyway). What happens when you try to run the code without your changes?