Skip to content

Commit 98cb267

Browse files
authored
Merge pull request #12 from tekktrik/dev/add-pwmout
Add PWMOut protocol
2 parents 982dee3 + 7b31522 commit 98cb267

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

circuitpython_typing/led.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
`circuitpython_typing.led`
77
================================================================================
88
9-
Type annotation definitions for device drivers. Used for where LEDs are
10-
type annotated.
9+
Type annotation definitions for LEDs.
1110
1211
* Author(s): Alec Delaney
1312
"""

circuitpython_typing/pwmio.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 Protocol
17+
except ImportError:
18+
from typing_extensions import Protocol
19+
20+
21+
class PWMOut(Protocol):
22+
"""Protocol that implements, at the bare minimum, the `duty_cycle` property"""
23+
24+
@property
25+
def duty_cycle(self) -> int:
26+
"""The duty cycle as a ratio using 16-bits"""
27+
...
28+
29+
@duty_cycle.setter
30+
def duty_cycle(self, duty_cycle: int) -> None:
31+
...

0 commit comments

Comments
 (0)