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.
j5.components.button module¶
Classes for Button.
Bases:
j5.components.component.Component
A button.
An integer to identify the component on a board.
Get the interface class that is required to use this component.
Get the current pushed state of the button.
Halt the program until this button is pushed.
Bases:
j5.components.component.Interface
An interface containing the methods required for a button.
Set the state of a button.
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.
-
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: j5.components.gpio_pin.GPIOPinMode, supported_modes: Set[j5.components.gpio_pin.GPIOPinMode] = {<GPIOPinMode.DIGITAL_OUTPUT: 3>})[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.
-
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 hardware 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.
-
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.
j5.components.motor module¶
Classes for Motor support.
-
class
j5.components.motor.
Motor
(identifier: int, backend: j5.components.motor.MotorInterface)[source]¶ Bases:
j5.components.component.Component
Brushed DC motor output.
-
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.
-
state
¶ Get the current state of this output.
-
-
class
j5.components.motor.
MotorInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control a motor board.
j5.components.piezo module¶
Classes for Piezo support.
-
class
j5.components.piezo.
Note
[source]¶ -
An enumeration of notes.
An enumeration of notes from scientific pitch notation and their related frequencies in Hz.
-
A6
= 1760.0¶
-
A7
= 3520.0¶
-
B6
= 1975.5¶
-
B7
= 3951.1¶
-
C6
= 1047.0¶
-
C7
= 2093.0¶
-
C8
= 4186.0¶
-
D6
= 1174.7¶
-
D7
= 2349.3¶
-
E6
= 1318.5¶
-
E7
= 2637.0¶
-
F6
= 1396.9¶
-
F7
= 2793.8¶
-
G6
= 1568.0¶
-
G7
= 3136.0¶
-
-
class
j5.components.piezo.
Piezo
(identifier: int, backend: j5.components.piezo.PiezoInterface)[source]¶ Bases:
j5.components.component.Component
A standard piezo.
-
buzz
(duration: datetime.timedelta, pitch: Union[int, float, j5.components.piezo.Note]) → None[source]¶ Queue a note to be played.
-
identifier
¶ An integer to identify the component on a board.
-
static
interface_class
() → Type[j5.components.piezo.PiezoInterface][source]¶ Get the interface class that is required to use this component.
-
-
class
j5.components.piezo.
PiezoInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control an piezo.
j5.components.power_output module¶
Classes for supporting toggleable power output channels.
-
class
j5.components.power_output.
PowerOutput
(identifier: int, backend: j5.components.power_output.PowerOutputInterface)[source]¶ Bases:
j5.components.component.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.
-
identifier
¶ An integer to identify the component on a board.
-
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.power_output.
PowerOutputGroup
(outputs: Mapping[T, j5.components.power_output.PowerOutput])[source]¶ Bases:
object
A group of PowerOutputs.
-
class
j5.components.power_output.
PowerOutputInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control a power output channel.
j5.components.servo module¶
Classes for supporting Servomotors.
-
class
j5.components.servo.
Servo
(identifier: int, backend: j5.components.servo.ServoInterface)[source]¶ Bases:
j5.components.component.Component
A standard servomotor.
-
identifier
¶ An integer to identify the component on a board.
-
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.servo.
ServoInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control a Servo.
Module contents¶
This module contains components, which are the smallest logical element of hardware.
-
class
j5.components.
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.
BatterySensorInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to read data from a BatterySensor.
-
class
j5.components.
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.
-
-
class
j5.components.
ButtonInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required for a button.
Set the state of a button.
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.
-
identifier
¶ An integer to identify the component on a board.
-
-
class
j5.components.
GPIOPin
(identifier: int, backend: j5.components.gpio_pin.GPIOPinInterface, *, initial_mode: j5.components.gpio_pin.GPIOPinMode, supported_modes: Set[j5.components.gpio_pin.GPIOPinMode] = {<GPIOPinMode.DIGITAL_OUTPUT: 3>})[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.
-
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 hardware mode of this pin.
-
-
class
j5.components.
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.
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.
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.
LEDInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control an LED.
-
class
j5.components.
Motor
(identifier: int, backend: j5.components.motor.MotorInterface)[source]¶ Bases:
j5.components.component.Component
Brushed DC motor output.
-
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.
-
state
¶ Get the current state of this output.
-
-
class
j5.components.
MotorInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control a motor board.
-
class
j5.components.
MotorSpecialState
[source]¶ Bases:
enum.Enum
An enum of the special states that a motor can be set to.
-
BRAKE
= 1¶
-
COAST
= 0¶
-
-
exception
j5.components.
NotSupportedByComponentError
[source]¶ Bases:
Exception
This is thrown when hardware does not support the action that is attempted.
-
class
j5.components.
Piezo
(identifier: int, backend: j5.components.piezo.PiezoInterface)[source]¶ Bases:
j5.components.component.Component
A standard piezo.
-
buzz
(duration: datetime.timedelta, pitch: Union[int, float, j5.components.piezo.Note]) → None[source]¶ Queue a note to be played.
-
identifier
¶ An integer to identify the component on a board.
-
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.component.Interface
An interface containing the methods required to control an piezo.
-
class
j5.components.
PowerOutput
(identifier: int, backend: j5.components.power_output.PowerOutputInterface)[source]¶ Bases:
j5.components.component.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.
-
identifier
¶ An integer to identify the component on a board.
-
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.component.Interface
An interface containing the methods required to control a power output channel.
-
class
j5.components.
PowerOutputGroup
(outputs: Mapping[T, j5.components.power_output.PowerOutput])[source]¶ Bases:
object
A group of PowerOutputs.
-
class
j5.components.
Servo
(identifier: int, backend: j5.components.servo.ServoInterface)[source]¶ Bases:
j5.components.component.Component
A standard servomotor.
-
identifier
¶ An integer to identify the component on a board.
-
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.component.Interface
An interface containing the methods required to control a Servo.