Skip to content

Led

This module contains the LED class.

CLASS DESCRIPTION
LED

LED class

Multi_LED

Multi-channel LED class

Documentation last updated: 2025-02-22

LED

LED(
    port: str = "COM0",
    channel: int = 0,
    *,
    baudrate: int = 9600,
    verbose=False,
    **kwargs,
)

Bases: TimedDeviceMixin, Maker

LED class

ATTRIBUTE DESCRIPTION
channel

channel number

TYPE: int

target_power

target power level

TYPE: int

timer_event

timer event

TYPE: Event

threads

threads

TYPE: dict

METHOD DESCRIPTION
dark

Darken the LED

light

Light up the LED

stop

Stop the LED

getPower

Get the power level of the LED

setPower

Set the power level of the LED

setValue

Set the power level of the LED

updatePower

Update the power level of the LED

execute

Execute the dark and spin steps

shutdown

Shutdown procedure for the LED

Initialize the LED class

PARAMETER DESCRIPTION
port

port to connect to. Defaults to 'COM0'.

TYPE: str DEFAULT: 'COM0'

channel

channel number. Defaults to 0.

TYPE: int DEFAULT: 0

baudrate

baudrate for connection. Defaults to 9600.

TYPE: int DEFAULT: 9600

verbose

verbosity of class. Defaults to False.

TYPE: bool DEFAULT: False

dark

dark(
    duration: int | float, blocking: bool = True, **kwargs
)

Darken the LED for a given duration

PARAMETER DESCRIPTION
duration

duration to darken the LED

TYPE: int | float

blocking

whether to block the thread. Defaults to True.

TYPE: bool DEFAULT: True

execute

execute(
    dark_time: int | float = 0,
    power: int = 255,
    light_time: int | float = 1,
    blocking: bool = True,
    *args,
    **kwargs,
)

Execute the dark and light steps

PARAMETER DESCRIPTION
dark_time

dark time. Defaults to 0.

TYPE: int DEFAULT: 0

power

power level. Defaults to 255.

TYPE: int DEFAULT: 255

light_time

light time. Defaults to 1.

TYPE: int DEFAULT: 1

blocking

whether to block the thread. Defaults to True.

TYPE: bool DEFAULT: True

getAttributes

getAttributes() -> dict

Get relevant attributes of the class

RETURNS DESCRIPTION
dict

relevant attributes

TYPE: dict

getPower

getPower() -> int

Get the current power level of the LED

RETURNS DESCRIPTION
int

power level

TYPE: int

light

light(
    power: int,
    duration: int | float,
    blocking: bool = True,
    **kwargs,
)

Light up the LED at a given power level for a given duration

PARAMETER DESCRIPTION
power

power level

TYPE: int

duration

duration to light up the LED

TYPE: int | float

blocking

whether to block the thread. Defaults to

TYPE: bool DEFAULT: True

setPower

setPower(
    power: int, event: Event | None = None, **kwargs
) -> bool

Set power level of LED

PARAMETER DESCRIPTION
power

power level

TYPE: int

event

event to set. Defaults to None.

TYPE: Event DEFAULT: None

RETURNS DESCRIPTION
bool

whether the power level was set

TYPE: bool

setTargetPower

setTargetPower(power: int) -> bool

Set power level of LED

PARAMETER DESCRIPTION
power

power level

TYPE: int

RETURNS DESCRIPTION
bool

whether the power level was set

TYPE: bool

setValue

setValue(
    value: int, event: Event | None = None, **kwargs
) -> bool

Set the power level of the LED

PARAMETER DESCRIPTION
value

power level

TYPE: int

event

event to set. Defaults to None.

TYPE: Event DEFAULT: None

RETURNS DESCRIPTION
bool

whether the power level was set

TYPE: bool

shutdown

shutdown()

Shutdown procedure for the LED

stop

stop(**kwargs)

Stop the LED from emitting light

updatePower

updatePower()

Update the power level of the LED