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

Access machine data in callback #56

Open
gtom opened this issue Apr 11, 2018 · 1 comment
Open

Access machine data in callback #56

gtom opened this issue Apr 11, 2018 · 1 comment

Comments

@gtom
Copy link

gtom commented Apr 11, 2018

Hi,
I have a machine with a state named POWER. In private-part of my machine class definition I added a timer:

Atm_timer timer;

Within the ENT_POWER part of this machine actions I want to start this timer that fires every 1000 ms:

timer.begin(1000).repeat(-1).onTimer( timer_callback ).start();

My callback function is:

void timer_callback( int idx, int v, int up ) {

Serial.print("callback: ");

Serial.println(up); // just counting

}

in EXT_POWER I stop() my timer later on. This works fine.
But now I want to have access to one of my machines public attributes within my callback. How can I achieve that? Is there any possibility to send more arguments (eg. this->value) to my callback?
I think this problem is not about Automaton itself but perhaps anyone knows a working solution?
gTom

@tinkerspy
Copy link
Owner

Why don't you use a standard atm_timer_millis object inside your state machine and then change state when the timer expires. Then you stay inside the machine and have access to all values.

Rgdz, Tinkerspy

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