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

Implementation of Functional and Scheduled option in Ticker lib #5030

Merged
merged 7 commits into from
Aug 14, 2018
Merged

Implementation of Functional and Scheduled option in Ticker lib #5030

merged 7 commits into from
Aug 14, 2018

Conversation

hreintke
Copy link
Contributor

No description provided.

@hreintke
Copy link
Contributor Author

@devyte : Next try for Ticker update.
Replaces #5024.

Based on master -> No issue with active() PR.

I do not understand why the travis check fails on the example.
It compiles in my environment , in the travis details I see a lot of duplicate code.
If you give a direction to search I'll update

@earlephilhower
Copy link
Collaborator

https://travis-ci.org/esp8266/Arduino/jobs/415077264

CI failure is related to style on the example code. We check for Arduino formatting to try and get a consistent look to the code. Intent of 2, braces on the function definition line, etc. The link above shows the problem bits.

@hreintke
Copy link
Contributor Author

@earlephilhower
Thx, I did see the travis log but did not understand the red/geen code.

Will update the example.

@hreintke
Copy link
Contributor Author

Updated the example.
The failed travis check is due to connection issue, not PR related.

@devyte devyte merged commit adde93b into esp8266:master Aug 14, 2018
@fabianoriccardi
Copy link

Hi,
probably it is my fault, but I don't get the differences between the "scheduled" and "not-scheduled" methods. Looking at your example (Ticker Functional.ino), it seems they are the same:

From your example, you declare the 2 functions:

void staticBlink() {
  digitalWrite(LED2, !digitalRead(LED2));
}

void scheduledBlink() {
  digitalWrite(LED3, !digitalRead(LED2));
}

And in the setup:

pinMode(LED2, OUTPUT);
 staticTicker.attach_ms(100, staticBlink);

 pinMode(LED3, OUTPUT);
 scheduledTicker.attach_ms_scheduled(100, scheduledBlink);

Links or comments in code could be useful to understand.

However thanks for your work, it seems a needed and important improvement.

@hreintke
Copy link
Contributor Author

hreintke commented Nov 4, 2018

Indeed, the only difference in the code is the
.attach_ms(100, vs the .attach_ms_scheduled(100,

Although the behavior of the both options is different of course.

I made the code this identical in order to keep the focus on the "schedule functionality"

@fabianoriccardi
Copy link

That's perfectly fine, but I would understand what are this "schedule functionality" :)

I mean, I've just learnt that in esp8266 exists schedule.h. Now I'm wondering what are the differences between "scheduling" a function instead the simple ticker.attach(..)

Any links or suggestion is appreciated

@devyte
Copy link
Collaborator

devyte commented Nov 4, 2018

The non scheduled form executes asynchronously in the system context. The code that can execute there has certain restrictions, e.g. you can't yield().
The scheduled form executes in the continuation context, I.e. as though it were in the loop. The time latency until the code starts executing is a bit higher, but the code has the same freedoms as loop() code.

@fabianoriccardi
Copy link

Clear explanation, thank you very much!

I'm searching on readthedocs... Is already there a page documenting this?

@hreintke hreintke deleted the TickerFunctionalScheduled branch August 15, 2020 12:35
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

Successfully merging this pull request may close these issues.

4 participants