I have this 3rd party type definition:
typedef void (*NexTouchEventCb)(void *ptr);
Which is used in a function in the 3rd party library:
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr)
If I have a single .cpp file then I can successfully call the attachPop
without any compiler errors:
NexButton b0 = NexButton(0, 1, "b0");
void b0PopCallback(void *ptr)
{
// do something here
}
b0.attachPop(b0PopCallback, &b0);
But I do OOP, so I have my own header and class files:
MyNextion.h
class MyNextion {
public:
void init();
void b0PopCallback(void *ptr);
private:
NexButton *b0;
}
MyNextion.cpp
#include "MyNextion.h"
void MyNextion::init() {
b0 = new NexButton(0, 1, "b0");
b0->attachPop(/* what should I put here? */);
}
void MyNextion::b0PopCallback(void *ptr) {
// do something here
}
I went through several similar questions like this, this and this one as well. But I just don't get it.
Note that this code is compiled for Arduino, which is a AVR microcontroller. Special C++ syntaxes may not be available.
Can you please tell me how should I call b0->attachPop
and why should I call that way?
Please note, that I'm not able to modify the 3rd party library, which can be found here: https://github.com/itead/ITEADLIB_Arduino_Nextion