Skip to content

Commit 0f4fcf8

Browse files
authored
3.4.0: Added support for the ancient Launchpad MK1 (#9)
* 3.4.0: Added support for the ancient Launchpad MK1 * 3.4.1: Fixed typo in inline documentation * 3.4.2: Clarification on terms flashing and pulsing for MK1 * 3.4.3: Replaced resource documents in README with links to archived documents * 3.4.4: Improved compatibility for Launchpad MK1
1 parent aa7dc3d commit 0f4fcf8

File tree

8 files changed

+558
-20
lines changed

8 files changed

+558
-20
lines changed

README.md

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,28 @@ After re-writing a broken launchpad library I decided to release the library to
1111

1212
Some sample programs can be found in the [examples folder](./examples).
1313

14+
15+
1416
## Launchpad models currently supported
1517

18+
- Launchpad MK1 ([limited support][limited-support-mk1])
1619
- Launchpad MK2
1720
- Launchpad MK3 (only tested with Mini)
1821

22+
1923
### Why are only these launchpads supported?
2024

2125
These launchpads are supported because I own them myself and have been able to test them.
2226
If a launchpad is not listed here it means that I do not own one and have not been able to test that one with the program.
2327

28+
29+
30+
## Installation
31+
32+
Install from NPM using `npm i launchpad.js` and make sure you have drivers installed for your device.
33+
34+
35+
2436
## Examples
2537

2638
More examples can be found in the [examples folder](./examples), this is just a simple button listener.
@@ -57,6 +69,8 @@ lp.once('ready', (deviceName) => {
5769
});
5870
```
5971

72+
73+
6074
## Low-level API
6175

6276
A number of methods are available to control the button colors on
@@ -81,6 +95,8 @@ The follow methods control a button's color:
8195
- `lp.pulse(button, color)`: a button will pulse between black and the given
8296
palette color.
8397

98+
99+
84100
## Surface API
85101

86102
There is also a buffer-oriented API you can use, which works much like
@@ -93,16 +109,69 @@ A helper class `Drawing` exists to help with performing common drawing operation
93109
See the [`examples/surface.js`](./examples/surface.js) example for more information
94110
on how to use this API.
95111

112+
113+
114+
## Limited support for the legacy Launchpad MK1
115+
116+
[limited-support-mk1]: #limited-support-for-the-legacy-launchpad-mk1 "Jump to section"
117+
118+
Launchpad MK1 offers less functionality over newer models and therefore has some limitations.
119+
As a result of the implementation for the MK1 being retro-fitted into this package, that has
120+
been designed to work with more advanced models, the API for MK1 isn't fully compatible with
121+
that of newer models. The differences are specified in this section.
122+
123+
124+
### Colors
125+
126+
Buttons on Launchpad MK1 only have two LEDs, red and green, that can output four intensities each:
127+
- `0` off.
128+
- `1` low brightness.
129+
- `2` medium brightness.
130+
- `3` full brightness.
131+
132+
This means the MK1 can only display a few different colors and that `RgColor` and `RgbColor` values (in range
133+
`0..1`) consumed by methods like `lp.setButtonColor()`, `lp.flash()` and `lp.pulse()` are converted to either
134+
one of the four color intensities. See type `RgColor` for more information on this conversion.
135+
136+
Because there is no blue LED, methods that consume an `RgbColor` value also accept `RgColor` values.
137+
138+
139+
### Color palette
140+
141+
The Launchpad MK1 doesn't have a color palette. Methods that consume a `PaletteColor` may instead accept a
142+
`Velocity` value (specific to MK1). See method `lp.velocity()` and type `Velocity` for more information.
143+
144+
Methods that exclusively consume `PaletteColor`s on newer models (being `lp.flash()` and `lp.pulse()`) instead
145+
accept an `RgColor`, `RgbColor` or `Velocity` value on Launchpad MK1.
146+
147+
Method `lp.setButtons()` uses different styles (`Mk1ButtonStyle` and `Mk1Style`) due to color palettes not being
148+
available, see type `Mk1Style` for more information.
149+
150+
151+
### Flashing buttons
152+
153+
Buttons on Launchpad MK1 can only **pulse** between off and a specified color, it does not support **flash**ing
154+
between two specified colors. This results in method `lp.flash()` only accepting one color argument and
155+
thus providing the exact same signature and functionality as `lp.pulse()`.
156+
157+
158+
96159
## TODO
97160

98161
- Add support for the same launchpads as launchpad.py
99162

100-
### Links
101163

102-
- [Launchpad developer manual](https://resource.novationmusic.com/support/product-downloads?product=Launchpad)
164+
## Related resources
165+
166+
- [Launchpad (MK1) programmers reference](https://web.archive.org/web/20240521041224/https://fael-downloads-prod.focusrite.com/customer/prod/downloads/launchpad-programmers-reference.pdf "View on archive.org") (archived)
167+
- [Launchpad MK2 programmers reference](http://web.archive.org/web/20231011173853/https://fael-downloads-prod.focusrite.com/customer/prod/s3fs-public/downloads/Launchpad%20MK2%20Programmers%20Reference%20Manual%20v1.03.pdf "View on archive.org") (archived)
168+
- [Launchpad Mini MK3 programmers reference](https://web.archive.org/web/20240127061723/https://fael-downloads-prod.focusrite.com/customer/prod/s3fs-public/downloads/Launchpad%20Mini%20-%20Programmers%20Reference%20Manual.pdf "View on archive.org") (archived)
169+
170+
More recent versions of programmers references may be available on [Novation Music's website](https://novationmusic.com/ "Visit website").
171+
103172

104-
### Notice
173+
## Notice
105174

106-
This project contains modified code from https://github.com/Lokua/launchpad which was released under the MIT license
175+
This project contains modified code from https://github.com/Lokua/launchpad which was released under the MIT license.
107176

108177
[rewards-interaction]: https://github.com/duncte123/rewards-interaction

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "launchpad.js",
3-
"version": "3.3.0",
3+
"version": "3.4.4",
44
"description": "A javascript api to control your Novation launchpads",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/colorHelpers.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import convert from 'color-convert';
2-
import { RgbColor } from './launchpads/base/ILaunchpad.js';
2+
import { RgbColor, RgColor } from './launchpads/base/ILaunchpad.js';
33

44
export const defaultColors: Record<string, RgbColor> = {
55
off: [0, 0, 0],
@@ -9,6 +9,26 @@ export const defaultColors: Record<string, RgbColor> = {
99
orange: [1, 0.26984127, 0],
1010
};
1111

12+
/**
13+
* Specifies pre-defined colors for the legacy Launchpad (MK1).
14+
*
15+
* @since 3.4.0
16+
*/
17+
export const legacyColors: Record<LegacyColor, RgColor> = {
18+
off: [0, 0],
19+
redLow: [0.1, 0],
20+
redMedium: [0.1, 0],
21+
red: [1, 0],
22+
amberLow: [0.1, 0.1],
23+
amberMedium: [0.5, 0.5],
24+
amber: [1, 1],
25+
yellowMedium: [0.1, 0.5],
26+
yellow: [0.5, 1],
27+
greenLow: [0, 0.1],
28+
greenMedium: [0, 0.5],
29+
green: [0, 1],
30+
};
31+
1232
/**
1333
* How many Palette colors there are
1434
*/
@@ -41,3 +61,10 @@ export function colorFromHex(hex: string): RgbColor {
4161
// scale the colors to fit between, 0-63
4262
.map((v: number) => v / 255) as RgbColor;
4363
}
64+
65+
/**
66+
* Specifies names of pre-defined colors for the legacy Launchpad (MK1).
67+
*
68+
* @since 3.4.0
69+
*/
70+
export type LegacyColor = 'off' | 'redLow' | 'redMedium' | 'red' | 'amberLow' | 'amberMedium' | 'amber' | 'yellowMedium' | 'yellow' | 'greenLow' | 'greenMedium' | 'green';

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SegfaultHandler from 'segfault-handler';
22

3+
export * from './launchpads/MK1/LaunchpadMK1.js';
34
export * from './launchpads/MK2/LaunchpadMK2.js';
45
export * from './launchpads/MK3/LaunchpadMK3.js';
56
export * from './launchpads/base/ILaunchpad.js';

0 commit comments

Comments
 (0)