Skip to content

Add PWMOut protocol #12

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

Merged
merged 3 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions circuitpython_typing/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
`circuitpython_typing.led`
================================================================================

Type annotation definitions for device drivers. Used for where LEDs are
type annotated.
Type annotation definitions for LEDs.

* Author(s): Alec Delaney
"""
Expand Down
31 changes: 31 additions & 0 deletions circuitpython_typing/pwmio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT

"""
`circuitpython_typing.pwmio`
================================================================================

Type annotation definitions for PWMOut where Blinka doesn't otherwise define it.

* Author(s): Alec Delaney
"""

# # Protocol was introduced in Python 3.8.
try:
from typing import Protocol
except ImportError:
from typing_extensions import Protocol


class PWMOut(Protocol):
"""Protocol that implements, at the bare minimum, the `duty_cycle` property"""

@property
def duty_cycle(self) -> int:
"""The duty cycle as a ratio using 16-bits"""
...

@duty_cycle.setter
def duty_cycle(self, duty_cycle: int) -> None:
...