UNPKG

@blackmagic-controller/core

Version:

An npm module for interfacing with the Blackmagic usb/bluetooth controllers

26 lines 1.03 kB
import { uint8ArrayToDataView } from '../../util.js'; export class DefaultPropertiesService { #device; #options; constructor(device, options) { this.#device = device; this.#options = options; } async getBatteryLevel() { if (this.#options.batteryReportId === null) return null; const val = await this.#device.getFeatureReport(this.#options.batteryReportId, 3); return val[2] / 100; } async getFirmwareVersion() { const val = await this.#device.getFeatureReport(this.#options.firmwareReportId, 8); const view = uint8ArrayToDataView(val); // Generate a semver format string return `${view.getUint8(5)}.${view.getUint8(6)}.${view.getUint8(7)}+${view.getUint32(1, true).toString(16)}`; } async getSerialNumber() { const val = await this.#device.getFeatureReport(this.#options.serialReportId, 33); return new TextDecoder('ascii').decode(val.subarray(1)); } } //# sourceMappingURL=default.js.map