-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
esp32/machine_timer: Add find free timer id. #12155
Conversation
Check if the timer is already in use:
Traceback (most recent call last): Check the timer id range:
Traceback (most recent call last): Timer() constructor id of -2 selects the id of a free timer:
Timer(3, mode=ONE_SHOT, period=0) |
48e27e5
to
7432c58
Compare
2704e28
to
32a1dcd
Compare
32a1dcd
to
c8e1bf4
Compare
c8e1bf4
to
b987291
Compare
b987291
to
a2e89b1
Compare
``id`` of -2 selects the ``id`` of a free timer. Check the timer `id` range. Check if the timer is already in use. Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
a2e89b1
to
f5ffe43
Compare
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Is this still ongoing? I think it might ve a very helpful feature, since sw timers are not supported on esp32 Boards |
Sorry @IhorNehrutsa that no one has gotten back to you about this, and thanks @cnadler86 for the heads up. In general, it's better if MicroPython APIs behave the same across ports. If I understand correctly, the main reason for adding this special -2 value on esp32 port is precisely because software timers aren't supported on esp32. There's probably not really a need for it on the ports with software timers. So the way forward for |
I'm going to close this out, but please refer to comment above - a PR that implements softtimers on esp32 port would be very welcome (I think probably using esp_timer API). |
atimer = Timer(-2)
The constructor
id
of -2 selects theid
of a free timer.Check the timer
id
range.Check if the timer is already in use.
This allows you to write separated library modules without worrying about the timer id. For example:
EDITED: Maybe
id
valueNone
is a better arg?atimer = Timer(None)