Program

@ledsign.LEDSignProgram(device: LEDSign)

Generates a program from the decorated function, compatible with device. See LEDSignProgramBuilder for usage details.

class ledsign.LEDSignProgram(device: LEDSign, file_path: str | None = None)

Contains information about a complete LED sign program compatible with device. If the file_path argument is given, the program is loaded from the specified file path.

An instance of this class can be used as a function decorator to generate programs dynamically (see LEDSignProgramBuilder or __call__() for details).

__call__(func: Callable[[], None], args: tuple | list = (), kwargs: dict = {}, inject_commands: bool = True, bypass_errors: bool = False) LEDSignProgram

Explicitly generates a program from the given function func(*args, **kwargs), and optionally bypasses error verification if the bypass_errors flag is set. Explicit uses of this method are required when ‘stitching’ a program from multiple functions, or when it is necessary to pass arguments to the supplied function. An example use case might be the following:

def mark_program_end(duration):
    at(duration)
    end()

program = ledsign.LEDSignProgram(device)
program(mark_program_end, args = (4.0,))
@program # alternatively: program(program_body_fn)
def program_body_fn():
    kp("#ff0000")

For advanced use cases, command alias injection can be disabled through the inject_commands argument (see LEDSignProgramBuilder for details about command shorthands).

compile(bypass_errors: bool = False) LEDSignCompiledProgram

Compiles the program and returns a LEDSignCompiledProgram object, and optionally bypasses error verification if the bypass_errors flag is set. Raises LEDSignProgramError if the program contains unresolved errors.

get_duration() float

Returns the current duration of the program.

get_keypoints(mask: int = -1) Iterator[LEDSignKeypoint]

Iterates over all keypoints containing any pixels selected by mask. If no mask is given, all keypoints are iterated over.

is_unloaded() bool

Returns True if the program is unloaded (ie. not yet fetched from the device), and False otherwise.

load() None

Explicitly loads an unloaded device program. Does nothing if the program was already downloaded, or if the program was not sourced from a LEDSign device.

Raises LEDSignProtocolError or LEDSignProgramError if the device was closed or modified before this method was called.

save(file_path: str, bypass_errors: bool = False) None

Writes the program to a file pointed to by the file_path. Optionally bypasses error verification (if the bypass_errors flag is set), or raises LEDSignProgramError if the program contains unresolved errors.

verify() bool

Verifies the program, and reports any encountered errors. Returns True if no errors have been found, and False otherwise.

class ledsign.LEDSignKeypoint

Represents a single keypoint in a program.

Note

For performance reasons, not all generated keypoints are always coalesced together, as this expensive step is only performed during external program loads (ie. programs loaded using LEDSignProgram() or through LEDSign.get_program()).

get_duration() float

Returns the duration of the keypoint.

get_end() float

Returns the end time of the keypoint.

get_mask() int

Returns the current keypoint’s pixel mask.

get_rgb() int

Returns the raw RGB color of the current keypoint (red in MSB, blue in LSB).

get_rgb_html() str

Returns the HTML color code of the current keypoint.

get_start() float

Returns the start time of the keypoint.

class ledsign.LEDSignCompiledProgram

Represents a compiled LEDSignProgram object, returned by LEDSignProgram.compile().

exception ledsign.LEDSignProgramError

Raised whenever issues in a program’s configuration are detected.