budryerson / TFMini-Plus-I2C

Arduino library for the Benewake TFMini-Plus LiDAR distance sensor in I2C communication mode
27 stars 16 forks source link

Avoid compiler error on ESP8266 and ESP32 #17

Closed hb020 closed 2 years ago

hb020 commented 2 years ago

TLDR : Set explicit types for calls to Wire.requestFrom, as the signature was ambiguous.

More detail:

The signatures of Wire.requestFrom that I know of are:

Specific for ESP8266 (https://github.com/esp8266/Arduino/blob/master/libraries/Wire/Wire.cpp):

Specific for ESP32 (https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/src/Wire.cpp)

Specific for ArduinoCore-avr (https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/Wire/src/Wire.cpp):

Common for all three:

Calling with (int,int,bool), as originally present, is ambiguous for ESP8266 and ESP32, but not for ArduinoCore-avr. A signature that would be unambiguous is (int,int,int) or (uint8_t,uint8_t,uint8_t). So I went for (int,int,int), as that was the closest to the original code.

Frankly, (uint8_t,size_t,bool) should be the correct one, but avr does not have that as an explicit signature.

In the issue https://github.com/budryerson/TFMini-Plus-I2C/issues/12 I proposed another mapping, but that would be wrong for ArduinoCore-avr.

Not strictly related: 1.7.2 is from 2022, not 2021. I did not correct that.

budryerson commented 2 years ago

Hi. I know nothing about "push/merge," but I suspect that this issue is keeping me from editing the library. While I deeply appreciate your gentle corrections and I welcome your collaboration, I'm going to close this issue for now. In the meantime, can you please tell me more about yourself? I would like to be able to give you credit for your contributions. Thanks, Bud