Skip to content

Commit 40ce66e

Browse files
committed
Add pwmio.py for PWMOut Protocol
1 parent 319b857 commit 40ce66e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

circuitpython_typing/pwmio.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
`circuitpython_typing.pwmio`
7+
================================================================================
8+
9+
Type annotation definitions for PWMOut where Blinka doesn't otherwise define it.
10+
11+
* Author(s): Alec Delaney
12+
"""
13+
14+
# # Protocol was introduced in Python 3.8.
15+
try:
16+
from typing import Union, Tuple, Protocol
17+
except ImportError:
18+
from typing_extensions import Protocol
19+
20+
class PWMOut(Protocol):
21+
"""Protocol that implements, at the bare minimum, the `duty_cycle` property"""
22+
23+
@property
24+
def duty_cycle(self) -> int:
25+
"""The duty cycle as a ratio using 16-bits"""
26+
...
27+
28+
@duty_cycle.setter
29+
def duty_cycle(self, duty_cycle: int) -> None:
30+
...

0 commit comments

Comments
 (0)