8000 Don't scale color in setButtonColor · duncte123/launchpad.js@ee08263 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee08263

Browse files
committed
Don't scale color in setButtonColor
1 parent df8fd0e commit ee08263

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "dist/index.js",
77
"types": "dist/index.d.ts",
88
"scripts": {
9-
"prepublish": "tsc",
9+
"prepublishOnly": "tsc",
1010
"build": "tsc -b",
1111
"ts:defs": "tsc --declaration --outDir types --emitDeclarationOnly",
1212
"lint": "eslint src/* --ext .js,.jsx,.ts,.tsx",

src/launchpads/MK2/LaunchpadMK2.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ export class LaunchpadMK2 extends BaseLaunchpad {
8888
throw new Error('Invalid color settings supplied');
8989
}
9090

91-
// scale the color so the launchpad understands it
92-
const [r, g, b] = color.map((v: number) => scaleBetween(v, 0, 63, 0, 255));
91+
// make sure the launchpad understands the colors we provide
92+
if (color.some(value => value > 63 || value < 0)) {
93+
throw new Error('RGB color is invalid, please make sure the color values are in range 0-63 (Hint: you can use colors.colorFromRGB as a helper for that');
94+
}
95+
96+
const [r, g, b] = color;
9397
const buttonMapped = this.mapButtonFromXy(button);
9498

9599
this.sendSysEx(11, buttonMapped, r, g, b);

0 commit comments

Comments
 (0)
0