I have created a class called CLongTimer - it is essentially a timer that counts down as you call a member function poll() in the main loop() function.
All it does is the
m_nTrigger = millis() + (nMin * 60 * 1000)
while (millis() < m_nTrigger)
It is a generic and conveniently re-useable solution to the problem of Timer1 etc being limited to about 8 seconds max.
Inside the class I have a pointer to a function of this type void (*FuncPtrType)() m_pFunc;.
When the trigger value is reached the function is called *m_pFunc();
It seems as though a global function of type void (*FuncPtrType)() works just fine.
But if I try and pass a void function that is the member of a class then all hell breaks loose.
When m_pFunc is de-referenced by my CLongTime object, it is being called on an invalid object.
This is clearly what is happening because Serial.println of various data members of my object reveal that they contain garbage.
So the question is how would one declare a function pointer type in a way that you can pass either a global void function or a void function that is the member of a class/object?
Is it possible?
LongTimer.cpp (1.64 KB)
LongTimer.h (1.08 KB)
Program.cpp (4.72 KB)
Program.h (987 Bytes)
ProgramStation.cpp (6.89 KB)
ProgramStation.h (1.68 KB)