SMFSW / SmoothADC

Arduino library for smooth ADC results
GNU Lesser General Public License v2.1
9 stars 5 forks source link

data type compile error in example ino #4

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi,

I have just installed your library and looks nice. However I do have a compiler error with the example which I cannot manage to get around. SmoothADC.h:100:12: error: invalid conversion from 'long unsigned int ()()' to 'uint32_t ()() {aka unsigned int (*)()}' [-fpermissive

I am not very familiar with cpp but it appears that in the line: get_tick = (Resolution == TB_US) ? micros : millis; } there is an incompatibility between the unsigned-long type pointer to either Millis() and Micros() and the Uint_32 and unit_32 data pointer types.

I am using Arduino IDE (latest version) and Adafruit Huzzah EP8266 hardware, if that is relevant.

Cheers, Derek

SMFSW commented 4 years ago

I did not check if the library was working on all platforms and it seems some of them (ESP8266 included) are using 64b return value for micros& millis.

I will investigate a little more on how to implement this difference in a consistent way for all platforms.

In the meantime, changing the declaration of get_tick should be enough to compile without error for the platform: SmoothADC.h line 49: replacing uint32_t (*get_tick)(void); //!< Time base function pointer with uint64_t (*get_tick)(void); //!< Time base function pointer

Thanks for the feedback and your interest in the library, Cheers, SMFSW

Dexter0007 commented 1 year ago

Hi, I have the same problem on ESP32. I changed declaration to uint64_t (*get_tick)(void); but I still have an error "SmoothADC.h: 100:36: error: invalid conversion from 'long unsigned int ()()' to 'uint64_t ()()' {aka 'long long unsigned int (*)()'} [-fpermissive] millis; }"

On ESP32 working good like this unsigned long (*get_tick)(void); so you can implement it in the future. Greetings