m5stack / M5Core-Ink

M5Stack CoreInk Arduino Library
MIT License
44 stars 33 forks source link

Ambiguous "begin" overload #18

Closed andreburto closed 2 years ago

andreburto commented 2 years ago

When following the CoreInk Quick Start tutorial I got the following error:

/Users/andrew/Documents/Arduino/libraries/M5-CoreInk/src/M5CoreInk.cpp: In member function 'int M5CoreInk::begin(bool, bool, bool)':
/Users/andrew/Documents/Arduino/libraries/M5-CoreInk/src/M5CoreInk.cpp:23:33: error: call of overloaded 'begin(int, int, int)' is ambiguous
         Wire.begin(32, 33, 10000);
                                 ^
In file included from /Users/andrew/Documents/Arduino/libraries/M5-CoreInk/src/utility/BM8563.h:4,
                 from /Users/andrew/Documents/Arduino/libraries/M5-CoreInk/src/M5CoreInk.h:8,
                 from /Users/andrew/Documents/Arduino/libraries/M5-CoreInk/src/M5CoreInk.cpp:1:
/Users/andrew/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.1/libraries/Wire/src/Wire.h:79:10: note: candidate: 'bool TwoWire::begin(int, int, uint32_t)'
     bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
          ^~~~~
/Users/andrew/Library/Arduino15/packages/m5stack/hardware/esp32/2.0.1/libraries/Wire/src/Wire.h:80:10: note: candidate: 'bool TwoWire::begin(uint8_t, int, int, uint32_t)'
     bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);
          ^~~~~
exit status 1
Error compiling for board M5Stack-CoreInk.

My fix was to change line 23 in M5CoreInk.cpp from...

Wire.begin(32, 33, 10000);

to...

Wire.begin(32, 33, (uint32_t) 10000);

That eliminated the ambiguity and the code compiled as expected. Is this a common issue or something unique to my setup? Is it worth my making a branch? I am using the following setup:

OS: macOS Catalina Arduino: 1.8.19 M5Stack CoreInk: 0.0.2 ESP32 libraries: 2.0.1

felmue commented 2 years ago

Hello @andreburto

thank you for your proposed fix. I've seen the issue in other projects and I think it is related to the 2.0.x version of the ESP32 libraries.

Thanks Felix

Tinyu-Zhao commented 2 years ago

Thank you for your feedback, we have solved the problem, please try to pull the latest library