j5.components package

Submodules

j5.components.base module

Base classes for components.

class j5.components.base.Component[source]

Bases: object

A component is the smallest logical part of some hardware.

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

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

class j5.components.base.Interface[source]

Bases: object

A base class for interfaces to inherit from.

exception j5.components.base.NotSupportedByHardwareError[source]

Bases: Exception

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

j5.components.led module

Classes for the LED support.

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

Bases: j5.components.base.Component

A standard Light Emitting Diode.

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.base.Interface

An interface containing the methods required to control an LED.

get_led_state(board: j5.boards.base.Board, identifier: int) → bool[source]

Get the state of an LED.

set_led_state(board: j5.boards.base.Board, identifier: int, state: bool) → None[source]

Set the state of an LED.

Module contents

This module contains components, which are the smallest logical element of hardware.

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

Bases: j5.components.base.Component

A sensor capable of monitoring a battery.

current

Get the current of the battery sensor.

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.BatterySensorInterface[source]

Bases: j5.components.base.Interface

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

get_battery_sensor_current(board: j5.boards.base.Board, identifier: int) → float[source]

Get the current of a battery sensor.

get_battery_sensor_voltage(board: j5.boards.base.Board, identifier: int) → float[source]

Get the voltage of a battery sensor.

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

Bases: j5.components.base.Component

A button.

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.ButtonInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required for a button.

get_button_state(board: j5.boards.base.Board, identifier: int) → bool[source]

Set the state of a button.

wait_until_button_pressed(board: j5.boards.base.Board, identifier: int) → None[source]

Halt the program until this button is pushed.

class j5.components.Component[source]

Bases: object

A component is the smallest logical part of some hardware.

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

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

class j5.components.GPIOPin(identifier: int, board: j5.boards.base.Board, backend: j5.components.gpio_pin.GPIOPinInterface, supported_modes: List[j5.components.gpio_pin.GPIOPinMode] = [<GPIOPinMode.DIGITAL_OUTPUT: 3>], initial_mode: Optional[j5.components.gpio_pin.GPIOPinMode] = None)[source]

Bases: j5.components.base.Component

A GPIO Pin.

analogue_value

Get the scaled analogue reading of the pin.

digital_state

Get the digital state of the pin.

static interface_class() → Type[j5.components.gpio_pin.GPIOPinInterface][source]

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

mode

Get the hardware mode of this pin.

class j5.components.GPIOPinInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required for a GPIO Pin.

get_gpio_pin_digital_state(board: j5.boards.base.Board, identifier: int) → bool[source]

Get the last written state of the GPIO pin.

get_gpio_pin_mode(board: j5.boards.base.Board, identifier: int) → j5.components.gpio_pin.GPIOPinMode[source]

Get the hardware mode of a GPIO pin.

read_gpio_pin_analogue_value(board: j5.boards.base.Board, identifier: int) → float[source]

Read the scaled analogue value of the GPIO pin.

read_gpio_pin_digital_state(board: j5.boards.base.Board, identifier: int) → bool[source]

Read the digital state of the GPIO pin.

set_gpio_pin_mode(board: j5.boards.base.Board, identifier: int, pin_mode: j5.components.gpio_pin.GPIOPinMode) → None[source]

Set the hardware mode of a GPIO pin.

write_gpio_pin_dac_value(board: j5.boards.base.Board, identifier: int, scaled_value: float) → None[source]

Write a scaled analogue value to the DAC on the GPIO pin.

write_gpio_pin_digital_state(board: j5.boards.base.Board, identifier: int, state: bool) → None[source]

Write to the digital state of a GPIO pin.

write_gpio_pin_pwm_value(board: j5.boards.base.Board, identifier: int, duty_cycle: float) → None[source]

Write a scaled analogue value to the PWM on the GPIO pin.

class j5.components.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.

class j5.components.Interface[source]

Bases: object

A base class for interfaces to inherit from.

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

Bases: j5.components.base.Component

A standard Light Emitting Diode.

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.LEDInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required to control an LED.

get_led_state(board: j5.boards.base.Board, identifier: int) → bool[source]

Get the state of an LED.

set_led_state(board: j5.boards.base.Board, identifier: int, state: bool) → None[source]

Set the state of an LED.

exception j5.components.NotSupportedByHardwareError[source]

Bases: Exception

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

class j5.components.Piezo(identifier: int, board: j5.boards.base.Board, backend: j5.components.piezo.PiezoInterface)[source]

Bases: j5.components.base.Component

A standard piezo.

buzz(duration: datetime.timedelta, pitch: int) → None[source]

Queue a note to be played.

static interface_class() → Type[j5.components.piezo.PiezoInterface][source]

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

class j5.components.PiezoInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required to control an piezo.

buzz(board: j5.boards.base.Board, identifier: int, duration: datetime.timedelta, pitch: int) → None[source]

Queue a pitch to be played.

class j5.components.PowerOutput(identifier: int, board: j5.boards.base.Board, backend: j5.components.power_output.PowerOutputInterface)[source]

Bases: j5.components.base.Component

A power output channel.

It can be enabled/disabled, and the current being drawn on this channel can be measured.

current

Get the current being drawn on this power output, in amperes.

static interface_class() → Type[j5.components.power_output.PowerOutputInterface][source]

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

is_enabled

Get whether the output is enabled.

class j5.components.PowerOutputInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required to control a power output channel.

get_power_output_current(board: j5.boards.base.Board, identifier: int) → float[source]

Get the current being drawn on a power output, in amperes.

get_power_output_enabled(board: j5.boards.base.Board, identifier: int) → bool[source]

Get whether a power output is enabled.

set_power_output_enabled(board: j5.boards.base.Board, identifier: int, enabled: bool) → None[source]

Set whether a power output is enabled.

class j5.components.PowerOutputGroup(outputs: Mapping[T, j5.components.power_output.PowerOutput])[source]

Bases: object

A group of PowerOutputs.

power_off() → None[source]

Disable all outputs in the group.

power_on() → None[source]

Enable all outputs in the group.

class j5.components.Servo(identifier: int, board: j5.boards.base.Board, backend: j5.components.servo.ServoInterface)[source]

Bases: j5.components.base.Component

A standard servomotor.

static interface_class() → Type[j5.components.servo.ServoInterface][source]

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

position

Get the current position of the Servo.

class j5.components.ServoInterface[source]

Bases: j5.components.base.Interface

An interface containing the methods required to control a Servo.

get_servo_position(board: j5.boards.base.Board, identifier: int) → Optional[float][source]

Get the position of a Servo.

set_servo_position(board: j5.boards.base.Board, identifier: int, position: Optional[float]) → None[source]

Set the position of a Servo.