diff --git a/circuitpython_typing/led.py b/circuitpython_typing/led.py index 741996b..5943ea0 100644 --- a/circuitpython_typing/led.py +++ b/circuitpython_typing/led.py @@ -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 """ diff --git a/circuitpython_typing/pwmio.py b/circuitpython_typing/pwmio.py new file mode 100644 index 0000000..8eed314 --- /dev/null +++ b/circuitpython_typing/pwmio.py @@ -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: + ...