@ginden/blinkstick-v2
    Preparing search index...

    Class BlinkStick<HidDevice>

    Main class responsible for controlling BlinkStick devices.

    Type Parameters

    • HidDevice extends HID | HIDAsync
    Index

    Constructors

    • Type Parameters

      • HidDevice extends HIDAsync | HID

      Parameters

      • device: HidDevice

        The USB device

      • OptionalserialNumber: string

        Serial number of the device. Used only in Windows.

      • Optionalmanufacturer: string

        Manufacturer of the device. Used only in Windows.

      • Optionalproduct: string

        Product name of the device. Used only in Windows.

      Returns BlinkStick<HidDevice>

    Properties

    animationsEnabled: boolean
    device: HidDevice
    inverse: boolean
    manufacturer: string
    product: string
    requiresSoftwareColorPatch: boolean
    serial: string

    Methods

    • This allows BlinkStick instances to be used with explicit resource management

      Returns Promise<void>

    • Close BlinkStick device and stop all animations

      Returns Promise<void>

    • Get the current color visible on BlinkStick

      Parameters

      • index: number = 0

        The index of the LED, 0 is default

      Returns Promise<[red: number, green: number, blue: number]>

    • Get the current color frame on BlinkStick Pro

      Parameters

      • count: number

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

      Callback returns an array of LED data in the following format: [g0, r0, b0, g1, r1, b1...] *

      .getColors(8);
      
    • Get the current color as hex string.

      Parameters

      • index: number = 0

        The index of the LED, 0 is default

      Returns Promise<`#${string}`>

    • Get the description of the device

      Returns string

    • Get a feature report from the device.

      Parameters

      • reportId: number

        Report ID to receive

      • length: number

        Expected length of the report

      • maxRetries: number = 5

        Maximum number of retries

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

    • Get the infoblock1 of the device. This is a 32 byte array that can contain any data. It's supposed to hold the "Name" of the device making it easier to identify rather than a serial number.

      Returns Promise<string>

    • Get the infoblock2 of the device. This is a 32 byte array that can contain any data.

      Usage:

      Returns Promise<string>

      getInfoBlock2(function(err, data) {
      console.log(data);
      });
    • Get the manufacturer of the device

      Returns string

    • Returns Promise<Buffer<ArrayBufferLike> | number[]>

    • Returns the serial number of device.

      BSnnnnnn-1.0
      ||  |    | |- Software minor version
      ||  |    |--- Software major version
      ||  |-------- Denotes sequential number
      ||----------- Denotes BlinkStick device
      

      Software version defines the capabilities of the device

      Returns string

    • Get the major version from serial number

      Returns number

      Major version number from serial

    • Get the minor version from serial number

      Returns number

      Minor version number from serial

    • Morphs to specified RGB color from current color.

      Function supports the following overloads:

      Parameters

      Returns Promise<void>

      //Available overloads
      morph(red, green, blue, [options], [callback]); // use [0..255] ranges for intensity

      morph(color, [options], [callback]); // use '#rrggbb' format

      morph(color_name, [options], [callback]); // use 'random', 'red', 'green', 'yellow' and other CSS supported names

      Options can contain the following parameters for object:

      - channel=0: Channel is represented as 0=R, 1=G, 2=B
      - index=0: The index of the LED
      - duration=1000: How long should the morph animation last in milliseconds
      - steps=50: How many steps for color changes
    • Pulses specified RGB color.

      Function supports the following overloads:

      Parameters

      Returns Promise<void>

      //Available overloads
      pulse(red, green, blue, [options], [callback]); // use [0..255] ranges for intensity

      pulse(color, [options], [callback]); // use '#rrggbb' format

      pulse(color_name, [options], [callback]); // use 'random', 'red', 'green', 'yellow' and other CSS supported names

      Options can contain the following parameters for object:

      - channel=0: Channel is represented as 0=R, 1=G, 2=B
      - index=0: The index of the LED
      - duration=1000: How long should the pulse animation last in milliseconds
      - steps=50: How many steps for color changes
    • Low-level method that directly sends a feature report to the device.

      Parameters

      • data: Buffer<ArrayBufferLike> | number[]

      Returns Promise<number>

    • Set the color of LEDs

      Parameters

      Returns Promise<null | Buffer<ArrayBufferLike> | number[]>

      //Available overloads
      setColor(red, green, blue, [options]); // use [0..255] ranges for intensity

      setColor(color, [options]); // use '#rrggbb' format

      setColor(color_name, [options]); // use 'random', 'red', 'green', 'yellow' and other CSS supported names
    • Set the color frame on BlinkStick Pro Missing colors are filled with zeros.

      Parameters

      • channel: Channel

        Channel is represented as 0=R, 1=G, 2=B

      • data: number[] | Uint8Array<ArrayBufferLike>

        LED data in the following format: [g0, r0, b0, g1, r1, b1...]

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

    • Set a feature report to the device.

      Parameters

      • reportId: number

        Report ID to receive

      • data: Buffer<ArrayBufferLike> | number[]

        Data to send to the device

      • maxRetries: number = 5

        Maximum number of retries

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

    • Sets the infoblock1 with specified string. It fills the rest of bytes with zeros.

      Usage:

      Parameters

      • data: string

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

      setInfoBlock1("abcdefg");
      
    • Parameters

      • data: string

      Returns Promise<Buffer<ArrayBufferLike> | number[]>

    • Set inverse mode for IKEA DIODER in conjunction with BlinkStick v1.0

      Parameters

      • inverse: boolean

        Set true for inverse mode and false otherwise

      Returns void

    • Returns Promise<null | Buffer<ArrayBufferLike> | number[]>

    • Parameters

      • index: number = 0

      Returns Promise<null | Buffer<ArrayBufferLike> | number[]>

    • Parameters

      • ledCount: number = ...

      Returns Promise<void>