API Reference

The API of rpi-lgpio (naturally) follows that of rpi-gpio (aka RPi.GPIO) as closely as possible. As such the following is simply a re-iteration of that API.

Initialization

Pin Usage

Edge Detection

Miscellaneous

PWM

Constants

RPi.GPIO.RPI_INFO

A dictionary that provides information about the model of Raspberry Pi that the library is loaded onto. Includes the following keys:

P1_REVISION

The revision of the P1 header. 0 indicates no P1 header (typical on the compute module range), 1 and 2 vary on the oldest Raspberry Pi models, and 3 is the typical 40-pin header present on all modern Raspberry Pis.

REVISION

The hex board revision code as a str.

TYPE

The name of the Pi model, e.g. “Pi 4 Model B”

MANUFACTURER

The name of the board manufacturer, e.g. “Sony UK”

PROCESSOR

The name of the SoC used on the board, e.g. “BCM2711”

RAM

The amount of RAM installed on the board, e.g. “4GB”

The board revision can be overridden with the RPI_LGPIO_REVISION environment variable; see Pi Revision for further details.

RPi.GPIO.RPI_REVISION

The same as the P1_REVISION key in RPI_INFO

RPi.GPIO.BOARD

Indicates to setmode() that physical board numbering is requested

RPi.GPIO.BCM

Indicates to setmode() that GPIO numbering is requested

RPi.GPIO.PUD_OFF

Used with setup() to disable internal pull resistors on an input

RPi.GPIO.PUD_DOWN

Used with setup() to enable the internal pull-down resistor on an input

RPi.GPIO.PUD_UP

Used with setup() to enable the internal pull-up resistor on an input

RPi.GPIO.OUT

Used with setup() to set a GPIO to an output, and gpio_function() to report a GPIO is an output

RPi.GPIO.IN

Used with setup() to set a GPIO to an input, and gpio_function() to report a GPIO is an input

RPi.GPIO.HARD_PWM
RPi.GPIO.SERIAL
RPi.GPIO.I2C
RPi.GPIO.SPI

Used with gpio_function() to indicate “alternate” modes of certain GPIO pins.

Note

In rpi-lgpio these values will never be returned as the kernel device cannot report if pins are in alternate modes.

RPi.GPIO.LOW = 0

Used with output() to turn an output GPIO off

RPi.GPIO.HIGH = 1

Used with output() to turn an output GPIO on

RPi.GPIO.RISING

Used with wait_for_edge() and add_event_detect() to specify that rising edges only should be sampled

RPi.GPIO.FALLING

Used with wait_for_edge() and add_event_detect() to specify that falling edges only should be sampled

RPi.GPIO.BOTH

Used with wait_for_edge() and add_event_detect() to specify that all edges should be sampled