5. API - GPIO

5.1. Regular Classes

The following classes are intended for general use with the devices they represent. All classes in this section are concrete (not abstract).

5.1.1. GPIO

class lannerpsp.GPIO(check_platform: bool = False)[source]

General Purpose Input/Output.

Parameters:

check_platform (bool) – Set to True to check if the platform supports this feature. Defaults to False for better compatibility.

Raises:
get_info() GPIOInfoModel[source]

Get the GPIO information supported by this platform.

Example:

>>> gpio = GPIO()
>>> gpio_info = gpio.get_info()
>>> gpio_info
GPIOInfoModel(number_of_di_pins=8, number_of_do_pins=4)
>>> gpio_info.number_of_di_pins
8
>>> gpio_info.number_of_do_pins
4
>>> gpio_info.to_dict()
{'number_of_di_pins': 8, 'number_of_do_pins': 4}
Returns:

The GPIO information.

Return type:

GPIOInfoModel

Raises:
get_digital_in() int[source]

Get the GPI/DI status.

Example:

>>> gpio = GPIO()
>>> gpio.get_digital_in()
12
Returns:

GPI/DI status in decimal. When converted to binary, the LSB represents DI_0.

Return type:

int

Raises:
get_digital_out() int[source]

Get the GPO/DO status.

Example:

>>> gpio = GPIO()
>>> gpio.get_digital_out()
3
Returns:

GPO/DO status in decimal. When converted to binary, the LSB represents DO_0.

Return type:

int

Raises:
set_digital_out(status: int) None[source]

Set the GPO/DO status.

Example:

>>> gpio = GPIO()
>>> gpio.set_digital_out(0x0A)
Parameters:

status (int) – GPO/DO status. This value can be binary, octal, decimal or hexadecimal with type int. For example, to write the [high, low, high, low] signal from DO_3 to DO_0, just set this parameter to 0b1010, 0o12, 0x0A or 10.

Raises:

5.2. Models

The following models are used to store data for data modeling.

5.2.1. GPIOInfoModel

class lannerpsp.GPIOInfoModel(number_of_di_pins: int, number_of_do_pins: int)[source]

To store GPIO information.

to_dict() Dict[str, Any][source]

Convert to dict.

5.3. Supported Platforms

The following platforms have been verified and confirmed to be supported: