j5.components.gpio_pin module¶
Classes for GPIO Pins.
-
exception
j5.components.gpio_pin.
BadGPIOPinModeError
[source]¶ Bases:
Exception
The pin is not in the correct mode.
-
class
j5.components.gpio_pin.
GPIOPin
(identifier: int, backend: j5.components.gpio_pin.GPIOPinInterface, *, initial_mode: Union[Type[j5.components.component.DerivedComponent], j5.components.gpio_pin.GPIOPinMode], hardware_modes: Set[j5.components.gpio_pin.GPIOPinMode] = {<GPIOPinMode.DIGITAL_OUTPUT: 3>}, firmware_modes: Set[Type[j5.components.component.DerivedComponent]] = {})[source]¶ Bases:
j5.components.component.Component
A GPIO Pin.
-
DEFAULT_FW_MODE
= {}¶
-
DEFAULT_HW_MODE
= {<GPIOPinMode.DIGITAL_OUTPUT: 3>}¶
-
firmware_modes
¶ Get the supported firmware modes.
-
identifier
¶ An integer to identify the component on a board.
-
static
interface_class
() → Type[j5.components.gpio_pin.GPIOPinInterface][source]¶ Get the interface class that is required to use this component.
-
last_digital_write
¶ Get the last set digital state of the pin.
This does not perform a read operation, it only gets the last set value, which is usually cached in memory.
-
mode
¶ Get the mode of this pin.
-
-
class
j5.components.gpio_pin.
GPIOPinInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required for a GPIO Pin.
-
get_gpio_pin_digital_state
(identifier: int) → bool[source]¶ Get the last written state of the GPIO pin.
-
get_gpio_pin_mode
(identifier: int) → j5.components.gpio_pin.GPIOPinMode[source]¶ Get the hardware mode of a GPIO pin.
-
read_gpio_pin_analogue_value
(identifier: int) → float[source]¶ Read the scaled analogue value of the GPIO pin.
-
read_gpio_pin_digital_state
(identifier: int) → bool[source]¶ Read the digital state of the GPIO pin.
-
set_gpio_pin_mode
(identifier: int, pin_mode: j5.components.gpio_pin.GPIOPinMode) → None[source]¶ Set the hardware mode of a GPIO pin.
-
write_gpio_pin_dac_value
(identifier: int, scaled_value: float) → None[source]¶ Write a scaled analogue value to the DAC on the GPIO pin.
-
-
class
j5.components.gpio_pin.
GPIOPinMode
[source]¶ Bases:
enum.IntEnum
Hardware modes that a GPIO pin can be set to.
-
ANALOGUE_INPUT
= 4¶ The analogue voltage of the pin can be read.
-
ANALOGUE_OUTPUT
= 5¶ The analogue voltage of the pin can be set using a DAC.
-
DIGITAL_INPUT
= 0¶ The digital state of the pin can be read
-
DIGITAL_INPUT_PULLDOWN
= 2¶ Same as DIGITAL_INPUT but internal pull-down is enabled
-
DIGITAL_INPUT_PULLUP
= 1¶ Same as DIGITAL_INPUT but internal pull-up is enabled
-
DIGITAL_OUTPUT
= 3¶ The digital state of the pin can be set.
-
PWM_OUTPUT
= 6¶ A PWM output signal can be created on the pin.
-