GPIO

GPIO(etp)

GPIO class.

Methods:

Name Description
get_info

Get GPIO port and pin information.

init

Initialize GPIO pins with the given configuration.

read

Read GPIO pins provided as list.

write

Write GPIO pins provided as dictionary.

get_info

get_info() -> dict

Get GPIO port and pin information.

Returns:
  • dict

    Dictionary containing GPIO port count and pin information.

Dictionary format
  • port_count (int): Number of GPIO ports.
  • info (list): List of dictionaries containing GPIO port and pin information.
    • port (str): GPIO port identifier.
    • pins (int): GPIO pins available in the port.

init

init(pin_list: dict) -> int

Initialize GPIO pins with the given configuration.

Parameters:
  • pin_list (dict) –

    A dictionary where keys are GPIO pin identifiers and values are dictionaries containing configuration options for each pin. Configuration options include:

    Dictionary format:

    • mode: Specifies the direction of the pin ('input' or 'output').

    • type: Specifies the pull type of the pin ('pull_up' or 'pull_down').

    • interrupt: Specifies the interrupt type for the pin ('rising_edge', 'falling_edge', or 'both_edges').

Returns:
  • int

    Status of the operation.

read

read(pin_list: list[str]) -> dict

Read GPIO pins provided as list.

Parameters:
  • pin_list (list[str]) –

    List of GPIO pins to read.

Returns:
  • dict

    Dictionary of GPIO pins and their states.

write

write(pin_state: dict)

Write GPIO pins provided as dictionary.

Parameters:
  • pin_state (dict) –

    Dictionary of GPIO pins and their states.