UNPKG

@ginden/blinkstick-v2

Version:
63 lines 2.37 kB
import type { BlinkstickAny } from '../core/blinkstick'; import type { FrameIterable } from './animation-description'; import { SimpleFrame } from './frame/simple-frame'; import { ComplexFrame } from './frame/complex-frame'; import type { Frame } from './frame/frame'; /** * This class is responsible for running animations on a Blinkstick device. * It handles the animation loop, applying frames to the device, and managing * the animation state. * * It's bound to a single Blinkstick device and can only run one animation at a time. * @category Animation */ export declare class AnimationRunner { readonly blinkstick: BlinkstickAny; protected abortController: AbortController; protected ledGroup: import("..").LedGroup; protected leds: import("..").Led[]; ledCount: number; protected buffer: Buffer<ArrayBuffer>; protected isRunning: boolean; constructor(blinkstick: BlinkstickAny); /** * Stops current animation */ stop(): void; /** * Runs the animation * If the animation is already running, it will throw an error * * Will wait for the animation to finish before returning * @param animations */ run(animations: FrameIterable[], { signal }?: { signal?: AbortSignal; }): Promise<void>; /** * Will replace the current animation and run the new one * Optional callback will be called when the animation is finished */ runAndForget(animations: FrameIterable[], cb?: (err: Error | null) => unknown, { signal }?: { signal?: AbortSignal; }): void; /** * Runs the animation, replacing the current one * * If the animation is already running, it will be stopped * * You can pass an optional AbortSignal to cancel the animation at any time */ runNew(animations: FrameIterable[], { signal: userSignal }?: { signal?: AbortSignal; }): Promise<void>; protected applySimpleFrame(frame: SimpleFrame): Promise<void>; protected applyComplexFrame(frame: ComplexFrame): Promise<void>; /** * Applies a frame to the device and waits for the duration of the frame. * @protected */ protected applyFrame(frame: Frame, signal: AbortSignal): Promise<void>; protected emitWarningForShortFrameDuration(frame: Frame): void; } //# sourceMappingURL=animation-runner.d.ts.map