Skip to content

Commit

Permalink
fix: add support for Litra Beam devices with alternative USD product ID
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Sep 7, 2023
1 parent 8cce3f8 commit 4300e68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 6 additions & 4 deletions dist/commonjs/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ var DeviceType;
(function (DeviceType) {
DeviceType["LitraGlow"] = "litra_glow";
DeviceType["LitraBeam"] = "litra_beam";
})(DeviceType = exports.DeviceType || (exports.DeviceType = {}));
})(DeviceType || (exports.DeviceType = DeviceType = {}));
const VENDOR_ID = 0x046d;
const PRODUCT_IDS = [
0xc900,
0xc901, // Litra Beam
0xc901,
0xb901, // Litra Beam
];
const USAGE_PAGE = 0xff43;
const MINIMUM_BRIGHTNESS_IN_LUMEN_BY_DEVICE_TYPE = {
Expand Down Expand Up @@ -218,9 +219,10 @@ exports.setBrightnessPercentage = setBrightnessPercentage;
*/
const getDeviceTypeByProductId = (productId) => {
switch (productId) {
case 0xc900:
case PRODUCT_IDS[0]:
return DeviceType.LitraGlow;
case 0xc901:
case PRODUCT_IDS[1]:
case PRODUCT_IDS[2]:
return DeviceType.LitraBeam;
default:
throw 'Unknown device type';
Expand Down
8 changes: 5 additions & 3 deletions dist/esm/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export var DeviceType;
const VENDOR_ID = 0x046d;
const PRODUCT_IDS = [
0xc900,
0xc901, // Litra Beam
0xc901,
0xb901, // Litra Beam
];
const USAGE_PAGE = 0xff43;
const MINIMUM_BRIGHTNESS_IN_LUMEN_BY_DEVICE_TYPE = {
Expand Down Expand Up @@ -201,9 +202,10 @@ export const setBrightnessPercentage = (device, brightnessPercentage) => {
*/
const getDeviceTypeByProductId = (productId) => {
switch (productId) {
case 0xc900:
case PRODUCT_IDS[0]:
return DeviceType.LitraGlow;
case 0xc901:
case PRODUCT_IDS[1]:
case PRODUCT_IDS[2]:
return DeviceType.LitraBeam;
default:
throw 'Unknown device type';
Expand Down
6 changes: 4 additions & 2 deletions src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const VENDOR_ID = 0x046d;
const PRODUCT_IDS = [
0xc900, // Litra Glow
0xc901, // Litra Beam
0xb901, // Litra Beam
];
const USAGE_PAGE = 0xff43;

Expand Down Expand Up @@ -265,9 +266,10 @@ export const setBrightnessPercentage = (
*/
const getDeviceTypeByProductId = (productId: number): DeviceType => {
switch (productId) {
case 0xc900:
case PRODUCT_IDS[0]:
return DeviceType.LitraGlow;
case 0xc901:
case PRODUCT_IDS[1]:
case PRODUCT_IDS[2]:
return DeviceType.LitraBeam;
default:
throw 'Unknown device type';
Expand Down

0 comments on commit 4300e68

Please sign in to comment.