UNPKG

@elgato-stream-deck/core

Version:

An npm module for interfacing with the Elgato Stream Deck

59 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Gen1PropertiesService = void 0; class Gen1PropertiesService { #device; constructor(device) { this.#device = device; } async setBrightness(percentage) { if (percentage < 0 || percentage > 100) { throw new RangeError('Expected brightness percentage to be between 0 and 100'); } // prettier-ignore const brightnessCommandBuffer = new Uint8Array([ 0x05, 0x55, 0xaa, 0xd1, 0x01, percentage, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]); await this.#device.sendFeatureReport(brightnessCommandBuffer); } async resetToLogo() { // prettier-ignore const resetCommandBuffer = new Uint8Array([ 0x0b, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]); await this.#device.sendFeatureReport(resetCommandBuffer); } async getFirmwareVersion() { let val; try { val = await this.#device.getFeatureReport(4, 32); } catch (_e) { // In case some devices can't handle the different report length val = await this.#device.getFeatureReport(4, 17); } const end = val.indexOf(0, 5); return new TextDecoder('ascii').decode(val.subarray(5, end === -1 ? undefined : end)); } async getAllFirmwareVersions() { // Not supported for gen1 models return {}; } async getSerialNumber() { let val; try { val = await this.#device.getFeatureReport(3, 32); } catch (_e) { // In case some devices can't handle the different report length val = await this.#device.getFeatureReport(3, 17); } return new TextDecoder('ascii').decode(val.subarray(5, 17)); } } exports.Gen1PropertiesService = Gen1PropertiesService; //# sourceMappingURL=gen1.js.map