@ginden/blinkstick-v2
Version:
Improved Blickstick API for Node.js
66 lines • 2.54 kB
TypeScript
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';
/**
* @summary Class to run animations on a Blinkstick device.
* @remarks
* 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;
/**
* @summary Runs the animation
*
* @remarks 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>;
/**
* @summary Will replace the current animation and run the new one, returning immediately
* @remarks Optional callback will be called when the animation is finished (may be never)
*/
runAndForget(animations: FrameIterable[], cb?: (err: Error | null) => unknown, { signal }?: {
signal?: AbortSignal;
}): void;
/**
* @summary Runs the animation, replacing the current one
*
* @remarks 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