Skip to content

Commit

Permalink
Allow Pin & Signal to be initialized as an int.
Browse files Browse the repository at this point in the history
ref: #768
Signed-off-by: Jos Verlinde <[email protected]>
  • Loading branch information
Josverl committed Nov 28, 2024
1 parent 76d3fc9 commit c450336
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion micropython-reference/machine/Signal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Signal:
@overload
def __init__(
self,
id: Pin | str,
id: Pin | str | int,
/,
mode: int = -1,
pull: int = -1,
Expand Down
57 changes: 55 additions & 2 deletions micropython-reference/machine/Timer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Timer:
/,
*,
mode: int = PERIODIC,
period: int = -1,
period: int | None = None,
callback: Callable[[Timer], None] | None = None,
):
"""
Expand All @@ -61,11 +61,64 @@ class Timer:
See ``init`` for parameters of initialisation.
"""

@overload
def __init__(
self,
id: int,
/,
*,
mode: int = PERIODIC,
freq: int | None = None,
callback: Callable[[Timer], None] | None = None,
):
"""
Construct a new timer object of the given ``id``. ``id`` of -1 constructs a
virtual timer (if supported by a board).
``id`` shall not be passed as a keyword argument.
See ``init`` for parameters of initialisation.
"""

@overload
def __init__(
self,
id: int,
/,
*,
mode: int = PERIODIC,
tick_hz: int | None = None,
callback: Callable[[Timer], None] | None = None,
):
"""
Construct a new timer object of the given ``id``. ``id`` of -1 constructs a
virtual timer (if supported by a board).
``id`` shall not be passed as a keyword argument.
See ``init`` for parameters of initialisation.
"""

@overload
def init(
self,
*,
mode: int = PERIODIC,
period: int | None = None,
callback: Callable[[Timer], None] | None = None,
) -> None: ...
@overload
def init(
self,
*,
mode: int = PERIODIC,
freq: int | None = None,
callback: Callable[[Timer], None] | None = None,
) -> None: ...
@overload
def init(
self,
*,
mode: int = PERIODIC,
period: int = -1,
tick_hz: int | None = None,
callback: Callable[[Timer], None] | None = None,
) -> None:
"""
Expand Down

0 comments on commit c450336

Please sign in to comment.