Program
- @ledsign.LEDSignProgram(device: LEDSign)
Generates a program from the decorated function, compatible with
device. SeeLEDSignProgramBuilderfor usage details.
- class ledsign.LEDSignProgram(device: LEDSign, file_path: str | None = None)
Contains information about a complete LED sign program compatible with
device. If thefile_pathargument 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
LEDSignProgramBuilderor__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 thebypass_errorsflag 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_commandsargument (seeLEDSignProgramBuilderfor details about command shorthands).
- compile(bypass_errors: bool = False) LEDSignCompiledProgram
Compiles the program and returns a
LEDSignCompiledProgramobject, and optionally bypasses error verification if thebypass_errorsflag is set. RaisesLEDSignProgramErrorif 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
Trueif the program is unloaded (ie. not yet fetched from the device), andFalseotherwise.
- 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
LEDSigndevice.Raises
LEDSignProtocolErrororLEDSignProgramErrorif 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 thebypass_errorsflag is set), or raisesLEDSignProgramErrorif the program contains unresolved errors.
- verify() bool
Verifies the program, and reports any encountered errors. Returns
Trueif no errors have been found, andFalseotherwise.
- 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 throughLEDSign.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
LEDSignProgramobject, returned byLEDSignProgram.compile().
- exception ledsign.LEDSignProgramError
Raised whenever issues in a program’s configuration are detected.