Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Latest commit

 

History

History
106 lines (80 loc) · 2.85 KB

getting-started.md

File metadata and controls

106 lines (80 loc) · 2.85 KB

Getting Started

  1. Install Rocketry
npm install @rocketry/core
  1. Create a new .js file
  2. require() the package in your new JavaScript file
// Require Rocketry
const rocketry = require("@rocketry/core");
  1. Create a new device instance
// Make a new device instance
// This method will automatically pick a supported device and its class
const launchpad = new rocketry();
  1. Crete a Button instance
// Get a button instance on the Launchpad at bottom-left button
// There are many other ways to get buttons like column, row, quadrant, etc.
const button = launchpad.query.by.coordinates(0, 0);
  1. Set that button to a color of your choice
// Set its color to pink
// Rocketry supports standard RGB, full RGB, and bi-color values or their names
button.light("pink");
  1. Add an event listener on your button
// Log to console on press of the bottom-left button
// Rocketry passes helpful values into your function, but let's not use them now
button.on("press", function() {
    console.log("3... 2... 1... Blast off!");
});
  1. Reset and close the connection
// Reset the device and close connection on release of the button named "mixer"
launchpad.query.by.name("mixer").on("release", function() {
    console.log("Launch aborted!");

    // You can use `this.device` instead of `launchpad` inside of this, but let's use our own reference
    // Reset the Launchpad to defaults (lights, layout, etc)
    launchpad.reset();
    // Close MIDI ports and cleanup
    launchpad.close();
});
  1. Browse the documentation page about interaction

Result

index.js
// Require Rocketry
const rocketry = require("@rocketry/core");

// Make a new device instance
// This method will automatically pick a supported device and its class
const launchpad = new rocketry();

// Get a button instance on the Launchpad at bottom-left button
// There are many other ways to get buttons like column, row, quadrant, etc.
const button = launchpad.query.by.coordinates(0, 0);

// Set its color to pink
// Rocketry supports standard RGB, full RGB, and bi-color values or their names
button.light("pink");

// Log to console on press of the bottom-left button
// Rocketry passes helpful values into your function, but let's not use them now
button.on("press", function() {
    console.log("3... 2... 1... Blast off!");
});

// Reset the device and close connection on release of the button named "mixer"
launchpad.query.by.name("mixer").on("release", function() {
    console.log("Launch aborted!");

    // You can use `this.device` instead of `launchpad` inside of this, but let's use our own reference
    // Reset the Launchpad to defaults (lights, layout, etc)
    launchpad.reset();
    // Close MIDI ports and cleanup
    launchpad.close();
});