{"size": 1059, "ext": "js", "max_stars_repo_path": "examples/led.js", "max_stars_repo_name": "mohayonao/launch-control", "max_stars_repo_stars_event_min_datetime": "2015-06-20T00:54:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-24T03:38:52.000Z", "max_issues_repo_path": "examples/led.js", "max_issues_repo_name": "mohayonao/launch-control", "max_issues_repo_issues_event_min_datetime": "2015-06-19T07:51:04.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-22T01:08:53.000Z", "max_forks_repo_path": "examples/led.js", "max_forks_repo_name": "mohayonao/launch-control", "max_forks_repo_forks_event_min_datetime": "2017-10-17T23:31:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-22T11:05:02.000Z"}
{"max_stars_count": 16, "max_issues_count": 3, "max_forks_count": 2, "avg_line_length": 27.1538461538, "max_line_length": 123, "alphanum_fraction": 0.4711992446}
(function(LaunchControl) {
  "use strict";

  var ctrl = new LaunchControl();
  var values = [ [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ] ];

  Promise.resolve().then(function() {
    return ctrl.open();
  }).then(function() {
    for (var ch = 0; ch < 15; ch++) {
      ctrl.led("all", "off", ch);
    }
  }).then(function() {
    ctrl.on("message", function(e) {
      var track = e.track;

      if (e.control === "knob1") {
        values[track][0] = e.value >> 5;
      }
      if (e.control === "knob2") {
        values[track][1] = e.value >> 5;
      }
      if (e.control === "pad") {
        values[track][0] = 0;
        values[track][1] = 0;
      }

      var color = (values[track][0] << 2) + values[track][1];

      ctrl.led(track, color);

      console.log("track: " + track + ", green: " + values[track][0] + ", red: " + values[track][1] + ", color: " + color);
    });
  }).catch(function(e) {
    console.log("ERROR: " + e.toString());
  });

})((this.self || global).LaunchControl || require("../"));
