Thanks for the link, I’ve been having a play around and it all makes sense now.
I have a further question about SWtimers…
I have a class called musicPlayer, one of the methods is called playNote . playNote, plays a single note then set up a timer to fire playNote again in X milliseconds. From a different thread, @ScruffR noted that rather than spawning timers you would just change the delay and reuse the same timer. this all works fine but I have one problem.
Where do I declare my timer? I need to pass a pointer to the function, but also the class instance. I can’t declare it in my class because I dont know the class instance here. Is there a C++ equivalent of “this” ? If I declare my timer in the main .ino I’ll need to pass a pointer to the timer in the constructor of the musicPlayer class, but I need to construct the class first to pass the instance to the timer!
A long winded solution would be to crate and instance of the class, declare the timer, then call a method musicPlayer.setTimer(&myTimer) but this seems messy.
Any better ideas?