UNPKG

dotstar

Version:

Library to control Adafruit DotStar LED strip

48 lines (47 loc) 1.42 kB
export interface ISpi { write(buffer: Buffer, callback: (error: any, data: any) => void): void; } export interface IDotstarOptions { length?: number; } export declare class Dotstar { static defaultOptions: IDotstarOptions; static startBytesLength: number; static endBytesLength: number; static bytesPerLed: number; device: ISpi; length: number; ledBuffer: Buffer; colorBuffer: Buffer; offBuffer: Buffer; constructor(spi: ISpi, options?: IDotstarOptions); /** * Set every LED in the colorBuffer to the RGBA value. */ all(r: number, g: number, b: number, a?: number): void; /** * Set every LED in the colorBuffer to black/off. */ clear(): void; /** * Turn off every LED without having to update the color buffer. * This is slightly faster and useful when you want to resume with the previous color. */ off(): void; /** * Set a specific LED in the colorBuffer to RGBA value. */ set(led: number, r: number, g: number, b: number, a?: number): void; /** * Update DotStar LED strip with current data in led buffer. */ sync(): void; /** * Convert RGBA value to Buffer */ private convertRgbaToLedBuffer(r, g, b, a?); /** * Wrapper around device.write which rethrows errors */ private write(buffer); }