-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Ticker updated to match extensions in ESP8266 API #2849
Conversation
0ad1943
to
cfe6a0b
Compare
@full-stack-ex You've recently made a change to Ticker, could you please review this PR? I've adopted the ULL integer literal fix from your patch. |
Well, it looks like the function called from Timer accepts a 64 bit us time (period): esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period); But this one, which calls it, accepts 32 bits only (micros, passed to the above as period): void Ticker::_attach_us(uint32_t micros, bool repeat, callback_with_arg_t callback, void* arg) Should it also accept 64 bits, like this, to pass any valid value without truncation? void Ticker::_attach_us(uint64_t micros, bool repeat, callback_with_arg_t callback, void* arg) |
@full-stack-ex Converted API to 64bit time values. Thanks! Good to merge now? |
As far as 64 bit conversion is concerned:
Good to go. By the way, there is a side effect, though positive. Just in case, it might affect some documentation, tests, etc. I don't know of any. The old 32 bit millisecond range used to limit the period to UINT32_MAX ms, which is 4294967295/1000/60/60/24 = 49.7 days. The 64 bit millisecond range eliminates that constraint, and so the period may be any practical value. Say, a year, should anybody need that. |
@hreintke I don't understand - microseconds attach is there on ESP32. And, is the comment on "alternative timer usage" a suggestion to any action/change? |
@dok-net Sorry for the confusion. Did not check the PR properly. |
12c38f1
to
49752e1
Compare
@me-no-dev Just a heads up :-) All reviewers gave their OK, I've recently followed your request to move as much from the header into the compilation unit as possible. |
Thanks a lot Dok-Net for this work. It think this PR is very usefull. I'm just trying to upgrade my first ESP8266 project to ESP32 and encounter this missing feature... |
53d51d9
to
cc71ffd
Compare
Hi all, |
cc94e44
to
c68b5a7
Compare
@dok-net Congrats on updating your PR. Unfortunately it deletes one of the examples and the third parameter is wrong on one of the calls. I'm a fellow developer (not a maintainer), so I can't tell you what to do. That said, your PR introduces a lot of changes. It is more likely to get merged with just a few clear changes. For instance adding new example files. I like the update on keywords.txt. I don't know if it is necessary (I don't use Arduino IDE), but seems reasonable. I don't agree with changing _attach_ms() to _attach_us(). I'm curious about introducing Honestly at this point I would likely start with a fresh PR and just introduce minimal changes. I have successfully written and merged several PRs for this project. Happy to give feedback. See example below of how I'm bringing over some changes from ESP8266. Note I reference prior PRs and code lines. |
"Congrats"? You're welcome. Whenever you spend your time and find issues in code, be as precise as you can when you mention them to the devs, just letting me know that I've got a (third) parameter wrong isn't quite so helpful. I did just fix a warning that occurs in the TickerParameter.ino sample. I believe my original thinking was that the three examples in this PR are more comprehensible than the previous one, the one I have deleted. Nevermind. Take care! |
Thank you for your efforts.
Correct. I didn't go into details because it sounds like you've given up on the PR. I don't blame you. It's hard to get a PR merged. I hear your frustration. Let's take a step back. What functionality would you like to see added? |
Really sad to see that such useful change cannot be merged in 4 years. I'm working on few esp32 projects and constantly having issues with inability to use Ticker in classes, due to (honestly speaking) ridiculous type incompatibility. This would nail it, I assume. |
@anabolyc I suspect the Ticker class is about to be refactored due to changes in IDF 5.1. What functionality are you looking for? |
@mrengineer7777 I'm compiling this simple class
No issues compiling against esp8266, but on the esp32 getting
|
@anabolyc |
Point is, in the current shape it would only accept free function, then you need workarounds and compromises to access class members. While it just builds against esp8266 version. |
Status update:
|
👋 Hello dok-net, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This PR updates the Ticker class to the ESP8266 in corresponding PR there.
Additional info:
This also prepares for an enhancement in another PR that would provide a co-op single-thread, IRQ safe Scheduler.
Even on FreeRTOS a single-thread scheduler in the loop-context is useful: for most sketches OS-level multitasking is not necessary, but synchronization is a difficult effort to get right. Also, the single-thread performance of the ESP32 in measured tests is lower than that of current non-OS SDK ESP8266, so an efficient user-context scheduler for timed and IRQ-based tasks is useful - besides, the async programming pattern this affords is quite popular.