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 <[email protected]>
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
idof -2 selects theidof a free timer.Check the timer
idrange.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
idvalueNoneis a better arg?atimer = Timer(None)