j5.components package

Submodules

j5.components.battery_sensor module

Classes for Battery Sensing Components.

class j5.components.battery_sensor.BatterySensor(identifier: int, backend: j5.components.battery_sensor.BatterySensorInterface)[source]

Bases: j5.components.component.Component

A sensor capable of monitoring a battery.

current

Get the current of the battery sensor.

identifier

An integer to identify the component on a board.

static interface_class() → Type[j5.components.battery_sensor.BatterySensorInterface][source]

Get the interface class that is required to use this component.

voltage

Get the voltage of the battery sensor.

class j5.components.battery_sensor.BatterySensorInterface[source]

Bases: j5.components.component.Interface

An interface containing the methods required to read data from a BatterySensor.

get_battery_sensor_current(identifier: int) → float[source]

Get the current of a battery sensor.

get_battery_sensor_voltage(identifier: int) → float[source]

Get the voltage of a battery sensor.

j5.components.button module

Classes for Button.

class j5.components.button.Button(identifier: int, backend: j5.components.button.ButtonInterface)[source]

Bases: j5.components.component.Component

A button.

identifier

An integer to identify the component on a board.

static interface_class() → Type[j5.components.button.ButtonInterface][source]

Get the interface class that is required to use this component.

is_pressed

Get the current pushed state of the button.

wait_until_pressed() → None[source]

Halt the program until this button is pushed.

class j5.components.button.ButtonInterface[source]

Bases: j5.components.component.Interface

An interface containing the methods required for a button.

get_button_state(identifier: int) → bool[source]

Set the state of a button.

wait_until_button_pressed(identifier: int) → None[source]

Halt the program until this button is pushed.

j5.components.component module

Base classes for components.

class j5.components.component.Component[source]

Bases: object

A component is the smallest logical part of some hardware.

identifier

An integer to identify the component on a board.

static interface_class() → Type[j5.components.component.Interface][source]

Get the interface class that is required to use this component.

class j5.components.component.DerivedComponent[source]

Bases: j5.components.component.Component

A derived component is a component that can take another component as a parameter.

For example, a device may be attached to various pins on the board, and this could vary depending on what the user wants. We solve this by passing the pins to the derived component.

>>> u = Ultrasound(pin_0, pin_1)
identifier

An integer to identify the component on a board.

static interface_class() → Type[j5.components.component.Interface][source]

Get the interface class that is required to use this component.

class j5.components.component.Interface[source]

Bases: object

A base class for interfaces to inherit from.

exception j5.components.component.NotSupportedByComponentError[source]

Bases: Exception

This is thrown when hardware does not support the action that is attempted.

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.

analogue_value

Get the scaled analogue reading of the pin.

digital_state

Get the digital state of the pin.

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.

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.

write_gpio_pin_digital_state(identifier: int, state: bool) → None[source]

Write to the digital state of a GPIO pin.

write_gpio_pin_pwm_value(identifier: int, duty_cycle: float) → None[source]

Write a scaled analogue value to the PWM 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.

j5.components.led module

Classes for the LED support.

class j5.components.led.LED(identifier: int, backend: j5.components.led.LEDInterface)[source]

Bases: j5.components.component.Component

A standard Light Emitting Diode.

identifier

An integer to identify the component on a board.

static interface_class() → Type[j5.components.led.LEDInterface][source]

Get the interface class that is required to use this component.

state

Get the current state of the LED.

class j5.components.led.LEDInterface[source]

Bases: j5.components.component.Interface

An interface containing the methods required to control an LED.

get_led_state(identifier: int) → bool[source]

Get the state of an LED.

set_led_state(identifier: int, state: bool) → None[source]

Set the state of an LED.

j5.components.motor module

j5.components.piezo module

j5.components.power_output module

j5.components.servo module

Module contents