tbot_contrib.gpio

A module containing gpio integration

class tbot_contrib.gpio.Gpio(host: LinuxShell, gpio_number: int, *, sys_path: Path | None = None)[source]

Bases: object

Initialize GPIO

Raspberry Pi Model 2 and above use as gpio_number their BCM GPIO Numbers

Parameters:
  • host (linux.LinuxShell) – Linux Shell

  • gpio_number (int) – GPIO Number

  • sys_path (linux.Path) – Path to the /sys/ mountpoint if it differs from the default.

Changed in version 0.10.6: Added the sys_path parameter.

set_direction(direction: str) None[source]

Set Direction

Sets direction to in or out

Parameters:

direction (str) – Direction to set

set_active_low(value: bool) None[source]

Set Active Low

When Active Low is True, the GPIO triggers on a LOW singnal, else on a HIGH signal

Parameters:

value (bool) – Value

get_active_low() bool[source]

Get Active Low

Reads value and returns direction in or out

Return type:

bool

Returns:

Value

get_direction() str[source]

Get Direction of GPIO

Reads direction and returns direction in or out

Return type:

str

Returns:

Value

set_value(value: bool) None[source]

Set Value

Sets value to HIGH and LOW

Parameters:

value (bool) – Value to set

get_value() bool[source]

Get Value

Reads value and returns value True or False

Return type:

bool

Returns:

Value

pulse(on_time: float, off_time: float | None = None) None[source]

Toggle GPIO

Toggles GPIO Pin between HIGH and LOW

Parameters:
  • on_time (float) – Time GPIO is HIGH

  • off_time (float) – Time GPIO is LOW. Defaults to on_time

New in version 0.10.6.