Yes, having a timer as part of a class can be done like this:
#include "Particle.h"
class MyClass {
public:
MyClass();
virtual ~MyClass();
void start();
void timerCallback();
private:
Timer timer;
};
MyClass::MyClass() : timer(1000, &MyClass::timerCallback, *this) {
}
MyClass::~MyClass() {
}
void MyClass::start() {
timer.start();
}
void MyClass::timerCallback() {
Serial.println("timerCallback");
}
MyClass myClass;
void setup() {
Serial.begin(9600);
myClass.start();
}
void loop() {
}