[RPi.GPIO] General improvement of stubs. (#11516)

This commit is contained in:
Thanos
2024-03-13 11:25:15 -04:00
committed by GitHub
parent 15536bd391
commit 64f009155e

View File

@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Literal, TypedDict
from typing import Final, Literal, TypedDict
from typing_extensions import TypeAlias
class _RPi_Info(TypedDict):
@@ -17,44 +17,50 @@ RPI_REVISION: int
HIGH: Literal[1]
LOW: Literal[0]
OUT: int
IN: int
HARD_PWM: int
SERIAL: int
I2C: int
SPI: int
UNKNOWN: int
OUT: Final = 0
IN: Final = 1
HARD_PWM: Final = 43
SERIAL: Final = 40
I2C: Final = 42
SPI: Final = 41
UNKNOWN: Final = -1
BOARD: int
BCM: int
BOARD: Final = 10
BCM: Final = 11
PUD_OFF: int
PUD_UP: int
PUD_DOWN: int
PUD_OFF: Final = 20
PUD_UP: Final = 22
PUD_DOWN: Final = 21
RISING: int
FALLING: int
BOTH: int
RISING: Final = 31
FALLING: Final = 32
BOTH: Final = 33
_EventCallback: TypeAlias = Callable[[int], object]
def setup(channel: int, dir: int, pull_up_down: int = ..., initial: int = ...) -> None: ...
def cleanup(channel: int = 0) -> None: ...
def output(channel: int, state: int | bool) -> None: ...
def input(channel: int) -> int: ...
def setmode(mode: int) -> None: ...
def getmode() -> int: ...
def add_event_detect(channel: int, edge: int, callback: _EventCallback | None, bouncetime: int = ...) -> None: ...
def remove_event_detect(channel: int) -> None: ...
def event_detected(channel: int) -> bool: ...
def setup(
channel: int | list[int] | tuple[int, ...], direction: Literal[0, 1], pull_up_down: int = 20, initial: int = -1
) -> None: ...
def cleanup(channel: int | list[int] | tuple[int, ...] = -666) -> None: ...
def output(
channel: int | list[int] | tuple[int, ...],
value: Literal[0, 1] | bool | list[Literal[0, 1] | bool] | tuple[Literal[0, 1] | bool, ...],
/,
) -> None: ...
def input(channel: int, /) -> bool: ...
def setmode(mode: Literal[10, 11], /) -> None: ...
def getmode() -> Literal[10, 11] | None: ...
def add_event_detect(channel: int, edge: int, callback: _EventCallback | None = None, bouncetime: int = -666) -> None: ...
def remove_event_detect(channel: int, /) -> None: ...
def event_detected(channel: int, /) -> bool: ...
def add_event_callback(channel: int, callback: _EventCallback) -> None: ...
def wait_for_edge(channel: int, edge: int, bouncetime: int = ..., timeout: int = ...) -> int | None: ...
def gpio_function(channel: int) -> int: ...
def setwarnings(gpio_warnings: bool) -> None: ...
def wait_for_edge(channel: int, edge: int, bouncetime: int = -666, timeout: int = -1) -> int | None: ...
def gpio_function(channel: int, /) -> int: ...
def setwarnings(gpio_warnings: bool, /) -> None: ...
class PWM:
def __init__(self, channel: int, frequency: float) -> None: ...
def start(self, dutycycle: float) -> None: ...
def ChangeDutyCycle(self, dutycycle: float) -> None: ...
def ChangeFrequence(self, frequency: float) -> None: ...
def __init__(self, channel: int, frequency: float, /) -> None: ...
def start(self, dutycycle: float, /) -> None: ...
def ChangeDutyCycle(self, dutycycle: float, /) -> None: ...
def ChangeFrequence(self, frequency: float, /) -> None: ...
def stop(self) -> None: ...