UNPKG

1.98 kBTypeScriptView Raw
1/// <reference types="node" />
2import { EventEmitter } from "eventemitter3";
3export declare const VENDOR_ID = "0403";
4export declare const PRODUCT_ID = "6001";
5interface Events {
6 ready: [];
7 error: [Error];
8}
9type Usleep = (microSeconds: number) => unknown;
10export declare class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
11 private shouldBeSending;
12 private sendTimeout;
13 private buffer;
14 private readonly port;
15 private readonly usleep;
16 /**
17 * @param path A path returned by {@link EnttecOpenDMXUSBDevice.listDevices} or
18 * {@link EnttecOpenDMXUSBDevice.getFirstAvailableDevice}.
19 * @param [startSending=true] Whether the device should start sending as soon as it is ready.
20 * @param [usleep=null] A function blocking the event loop for `n` microseconds. See the README.md for more information.
21 */
22 constructor(path: string, startSending?: boolean, usleep?: Usleep | null);
23 /**
24 * Start sending.
25 * @param [interval=0] The milliseconds between each attempt to send. Most of the time `0` works fine.
26 * @throws When the device is not ready yet.
27 */
28 startSending(interval?: number): void;
29 /**
30 * Stop sending.
31 */
32 stopSending(): void;
33 /**
34 * Set channel values.
35 * If channels is an Object, the keys are the channel numbers.
36 *
37 * @param channels
38 * @param [clear=false] Whether all previously assigned channels should be set to `0`
39 */
40 setChannels(channels: Buffer | number[] | Record<number, number>, clear?: boolean): void;
41 /**
42 * @returns A Promise resolved when the whole universe was sent.
43 * @private
44 */
45 _sendUniverse(): Promise<void>;
46 /**
47 * Get the paths of all available devices.
48 */
49 static listDevices(): Promise<string[]>;
50 /**
51 * Get the path of the first available device.
52 * @throws When no device is found.
53 */
54 static getFirstAvailableDevice(): Promise<string>;
55}
56export {};