hexenmeister / AS_BH1750

a (Arduino) library for the BH1750FVI Digital Light Sensor
GNU Lesser General Public License v2.1
8 stars 10 forks source link

Library doesn't compile when used with ESP32 #5

Open tonhuisman opened 3 years ago

tonhuisman commented 3 years ago

When using the library code for the ESP32 platform, a compilation error is shown: error: invalid conversion from 'void (*)(uint32_t) {aka void (*)(unsigned int)}' to 'DelayFuncPtr {aka void (*)(long unsigned int)}' This can be corrected by correcting this code: typedef void (*DelayFuncPtr)(unsigned long); to look like this:

#ifdef ESP32
typedef void (*DelayFuncPtr)(uint32_t);
#endif
#ifdef ESP8266
typedef void (*DelayFuncPtr)(unsigned long);
#endif

If you are accepting pull-requests I can make one for you, but as there isn't much activity here lately, I'll leave this info here for who might need it, and await your response before actually creating a PR.

SamyAorus commented 1 year ago

@tonhuisman hi, where do you have to add this corection? i added it in example code and ccp file but didnt work.

tonhuisman commented 1 year ago

@tonhuisman hi, where do you have to add this corection? i added it in example code and ccp file but didnt work.

It depends how you compile your code, and where the Library is stored. I've been using PlatformIO as my build platform (working on ESPEasy code), and don't have much Arduino IDE experience (and not interested in gaining much of that), but if the library is automatically pulled from the interwebz, you won't be able to replace this code in the library. When having this library in a local libs folder. you should change the code in AS_BH1750.h or AS_BH1750A.h (whatever you have included in your .ino file), around line 90. Just replace that 1 typedef line by the 6 lines I showed above.

SamyAorus commented 1 year ago

Thank you, i had to replace it in both AS_BH1750A.h and AS_BH1750.h for it to work, i verified the code only since im not in my lab to test it , but it compiled, i hope it will give the extra range measurement.