@elgato-stream-deck/core
Version:
An npm module for interfacing with the Elgato Stream Deck
52 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gen2PropertiesService = void 0;
class Gen2PropertiesService {
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([
0x03,
0x08, percentage, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]);
await this.device.sendFeatureReport(brightnessCommandBuffer);
}
async resetToLogo() {
// prettier-ignore
const resetCommandBuffer = new Uint8Array([
0x03,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]);
await this.device.sendFeatureReport(resetCommandBuffer);
}
async getFirmwareVersion() {
const val = await this.device.getFeatureReport(5, 32);
const end = val[1] + 2;
return new TextDecoder('ascii').decode(val.subarray(6, end));
}
async getAllFirmwareVersions() {
return {
AP2: await this.getFirmwareVersion(),
// TODO AP2_CHECKSUM - uint32be after length
};
}
async getSerialNumber() {
const val = await this.device.getFeatureReport(6, 32);
const end = val[1] + 2;
return new TextDecoder('ascii').decode(val.subarray(2, end));
}
}
exports.Gen2PropertiesService = Gen2PropertiesService;
//# sourceMappingURL=gen2.js.map