Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dist/commonjs/cli/litra-backlight-off.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
21 changes: 21 additions & 0 deletions dist/commonjs/cli/litra-backlight-off.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const driver_1 = require("./../driver");
const utils_1 = require("./utils");
commander_1.program
.name('litra-backlight-off')
.description('Deactivate the backlight on a Litra Beam LX device')
.option('-s, --serial-number <serialNumber>', 'serial number of the Litra Beam LX device to control');
commander_1.program.parse();
const { serialNumber } = commander_1.program.opts();
try {
const device = (0, utils_1.getDeviceForCLI)(serialNumber);
(0, driver_1.backlightOff)(device);
process.exit(0);
}
catch (e) {
console.log(e);
process.exit(1);
}
2 changes: 2 additions & 0 deletions dist/commonjs/cli/litra-backlight-on.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
21 changes: 21 additions & 0 deletions dist/commonjs/cli/litra-backlight-on.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const driver_1 = require("./../driver");
const utils_1 = require("./utils");
commander_1.program
.name('litra-backlight-on')
.description('Activate the backlight on a Litra Beam LX device')
.option('-s, --serial-number <serialNumber>', 'serial number of the Litra Beam LX device to control');
commander_1.program.parse();
const { serialNumber } = commander_1.program.opts();
try {
const device = (0, utils_1.getDeviceForCLI)(serialNumber);
(0, driver_1.backlightOn)(device);
process.exit(0);
}
catch (e) {
console.log(e);
process.exit(1);
}
25 changes: 25 additions & 0 deletions dist/commonjs/driver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,28 @@ export declare const getAllowedTemperaturesInKelvinForDevice: (device: Device) =
* @returns {string} The name of the device, e.g. "Logitech Litra Glow"
*/
export declare const getNameForDevice: (device: Device) => string;
/**
* Turns the backlight on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight on for
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const backlightOn: (device: Device) => void;
/**
* Turns the backlight off for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight off for
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const backlightOff: (device: Device) => void;
/**
* Checks whether the backlight is currently on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to check the backlight status for
* @returns {boolean} true if the backlight is on, false if it is off
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const isBacklightOn: (device: Device) => boolean;
59 changes: 58 additions & 1 deletion dist/commonjs/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameForDevice = exports.getAllowedTemperaturesInKelvinForDevice = exports.getMaximumTemperatureInKelvinForDevice = exports.getMinimumTemperatureInKelvinForDevice = exports.getMaximumBrightnessInLumenForDevice = exports.getMinimumBrightnessInLumenForDevice = exports.setBrightnessPercentage = exports.getBrightnessInLumen = exports.setBrightnessInLumen = exports.getTemperatureInKelvin = exports.setTemperatureInKelvin = exports.isOn = exports.toggle = exports.turnOff = exports.turnOn = exports.findDevices = exports.findDevice = exports.DeviceType = void 0;
exports.isBacklightOn = exports.backlightOff = exports.backlightOn = exports.getNameForDevice = exports.getAllowedTemperaturesInKelvinForDevice = exports.getMaximumTemperatureInKelvinForDevice = exports.getMinimumTemperatureInKelvinForDevice = exports.getMaximumBrightnessInLumenForDevice = exports.getMinimumBrightnessInLumenForDevice = exports.setBrightnessPercentage = exports.getBrightnessInLumen = exports.setBrightnessInLumen = exports.getTemperatureInKelvin = exports.setTemperatureInKelvin = exports.isOn = exports.toggle = exports.turnOff = exports.turnOn = exports.findDevices = exports.findDevice = exports.DeviceType = void 0;
const node_hid_1 = __importDefault(require("node-hid"));
const utils_1 = require("./utils");
var DeviceType;
Expand Down Expand Up @@ -358,3 +358,60 @@ const getNameForDevice = (device) => {
return NAME_BY_DEVICE_TYPE[device.type];
};
exports.getNameForDevice = getNameForDevice;
const buildBacklightOnBytes = () => {
return (0, utils_1.padRight)([0x11, 0xff, 0x0a, 0x4b, 0x01], 20, 0x00);
};
/**
* Turns the backlight on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight on for
* @throws {string} If the device is not a Litra Beam LX
*/
const backlightOn = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const message = buildBacklightOnBytes();
device.hid.write(message);
};
exports.backlightOn = backlightOn;
const buildBacklightOffBytes = () => {
return (0, utils_1.padRight)([0x11, 0xff, 0x0a, 0x4b, 0x00], 20, 0x00);
};
/**
* Turns the backlight off for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight off for
* @throws {string} If the device is not a Litra Beam LX
*/
const backlightOff = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const message = buildBacklightOffBytes();
device.hid.write(message);
};
exports.backlightOff = backlightOff;
const buildBacklightStatusQueryBytes = () => {
return (0, utils_1.padRight)([0x11, 0xff, 0x0a, 0x3b], 20, 0x00);
};
/**
* Checks whether the backlight is currently on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to check the backlight status for
* @returns {boolean} true if the backlight is on, false if it is off
* @throws {string} If the device is not a Litra Beam LX
*/
const isBacklightOn = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const query = buildBacklightStatusQueryBytes();
device.hid.write(query);
const response = device.hid.readSync();
return response[4] === 1;
};
exports.isBacklightOn = isBacklightOn;
2 changes: 2 additions & 0 deletions dist/esm/cli/litra-backlight-off.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
19 changes: 19 additions & 0 deletions dist/esm/cli/litra-backlight-off.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import { program } from 'commander';
import { backlightOff } from './../driver';
import { getDeviceForCLI } from './utils';
program
.name('litra-backlight-off')
.description('Deactivate the backlight on a Litra Beam LX device')
.option('-s, --serial-number <serialNumber>', 'serial number of the Litra Beam LX device to control');
program.parse();
const { serialNumber } = program.opts();
try {
const device = getDeviceForCLI(serialNumber);
backlightOff(device);
process.exit(0);
}
catch (e) {
console.log(e);
process.exit(1);
}
2 changes: 2 additions & 0 deletions dist/esm/cli/litra-backlight-on.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
19 changes: 19 additions & 0 deletions dist/esm/cli/litra-backlight-on.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node
import { program } from 'commander';
import { backlightOn } from './../driver';
import { getDeviceForCLI } from './utils';
program
.name('litra-backlight-on')
.description('Activate the backlight on a Litra Beam LX device')
.option('-s, --serial-number <serialNumber>', 'serial number of the Litra Beam LX device to control');
program.parse();
const { serialNumber } = program.opts();
try {
const device = getDeviceForCLI(serialNumber);
backlightOn(device);
process.exit(0);
}
catch (e) {
console.log(e);
process.exit(1);
}
25 changes: 25 additions & 0 deletions dist/esm/driver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,28 @@ export declare const getAllowedTemperaturesInKelvinForDevice: (device: Device) =
* @returns {string} The name of the device, e.g. "Logitech Litra Glow"
*/
export declare const getNameForDevice: (device: Device) => string;
/**
* Turns the backlight on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight on for
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const backlightOn: (device: Device) => void;
/**
* Turns the backlight off for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight off for
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const backlightOff: (device: Device) => void;
/**
* Checks whether the backlight is currently on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to check the backlight status for
* @returns {boolean} true if the backlight is on, false if it is off
* @throws {string} If the device is not a Litra Beam LX
*/
export declare const isBacklightOn: (device: Device) => boolean;
54 changes: 54 additions & 0 deletions dist/esm/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,57 @@ export const getAllowedTemperaturesInKelvinForDevice = (device) => {
export const getNameForDevice = (device) => {
return NAME_BY_DEVICE_TYPE[device.type];
};
const buildBacklightOnBytes = () => {
return padRight([0x11, 0xff, 0x0a, 0x4b, 0x01], 20, 0x00);
};
/**
* Turns the backlight on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight on for
* @throws {string} If the device is not a Litra Beam LX
*/
export const backlightOn = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const message = buildBacklightOnBytes();
device.hid.write(message);
};
const buildBacklightOffBytes = () => {
return padRight([0x11, 0xff, 0x0a, 0x4b, 0x00], 20, 0x00);
};
/**
* Turns the backlight off for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to turn the backlight off for
* @throws {string} If the device is not a Litra Beam LX
*/
export const backlightOff = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const message = buildBacklightOffBytes();
device.hid.write(message);
};
const buildBacklightStatusQueryBytes = () => {
return padRight([0x11, 0xff, 0x0a, 0x3b], 20, 0x00);
};
/**
* Checks whether the backlight is currently on for your Logitech Litra Beam LX device.
* Note: This feature is only available on Litra Beam LX devices.
*
* @param {Device} device The device to check the backlight status for
* @returns {boolean} true if the backlight is on, false if it is off
* @throws {string} If the device is not a Litra Beam LX
*/
export const isBacklightOn = (device) => {
if (device.type !== DeviceType.LitraBeamLX) {
throw 'Backlight control is only supported on Litra Beam LX devices';
}
const query = buildBacklightStatusQueryBytes();
device.hid.write(query);
const response = device.hid.readSync();
return response[4] === 1;
};
Loading