Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blinker.h - How to Encapsulate a Timer and its Callback in a Class / How to choose the right timer? #30

Open
christophepersoz opened this issue Feb 1, 2024 · 2 comments

Comments

@christophepersoz
Copy link

christophepersoz commented Feb 1, 2024

Hi Luna,

Thanks for your TeensyTimerTool, this is a super library.

I was reading your callback examples and discovered the part where you are encapsulating and use this library in an another class, Blinker.h as an example. Is that possible to specify in a such use the kind of timer you want to use for each blinker? (TCK, TCK_RTC, and so...).

Thanks a lot,
Christophe

@luni64
Copy link
Owner

luni64 commented Feb 2, 2024

To call the constructor of a variable that is a member of a class, pass the constructor parameters in the member initialization list. For example, if you want to use the GPT1 module, it would look like this

class Blinker
{
 public:
    Blinker(unsigned _pin, unsigned _period) // add blink period to the constructor
        : timer(GPT1) //<<====
    {
        pin    = _pin;
        period = _period;
    }`
...
protected:
    PeriodicTimer timer;
...
}

@christophepersoz
Copy link
Author

Hi Luna,
Thanks a lot. I dis found that much later yesterday.

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants