halvves / webmonome

we've moved to sourcehut! this is just a mirror of: https://sr.ht/~merl/webmonome/
https://www.npmjs.com/package/webmonome/v/alpha
MIT License
11 stars 1 forks source link
grid monome music serialosc webusb

WebMonome

npm 0.0.1-alpha.8
size 1.96kb minzipped
dependencies zero
license MIT

communicate with devices beyond a translator

webmonome is a little library designed to enable communication with monome devices directly from the web browser (bypassing serialosc). while serialosc is the best choice 99% of the time, i thought that it might be nice to enable the creation of monome apps that required zero install/config.

usage

script include

<script src="https://unpkg.com/webmonome@alpha"></script>
const monome = new WebMonome();

const btn = document.createElement('button');
btn.innerHTML = 'connect';
btn.addEventListener('click', () => {
  monome.connect();
});
document.body.appendChild(btn);

const keydown = e => {
  monome.gridLed(e.x, e.y, true);
};

const keyup = e => {
  monome.gridLed(e.x, e.y);
};

monome.on('gridKeyDown', keydown);
monome.on('gridKeyUp', keyup);

import

npm install webmonome@alpha

import WebMonome from 'webmonome';

const monome = new WebMonome();

const btn = document.createElement('button');
btn.innerHTML = 'connect';
btn.addEventListener('click', () => {
  monome.connect();
});
document.body.appendChild(btn);

const keydown = e => {
  monome.gridLed(e.x, e.y, true);
};

const keyup = e => {
  monome.gridLed(e.x, e.y);
};

monome.on('gridKeyDown', keydown);
monome.on('gridKeyUp', keyup);

requirements

webmonome relies on the WebUSB api. information on browser support for the WebUSB api can be found over at caniuse.

webmonome also requires that serialosc is disabled. On macOS open Terminal and execute:

launchctl unload /Library/LaunchAgents/org.monome.serialosc.plist

To re-enable:

launchctl load /Library/LaunchAgents/org.monome.serialosc.plist

api

webmonome is currently very bare bones (as i'm still working out the kinks with WebUSB and the monome serial protocol), but there is enough there to perform most grid operations.

connect

system

system responses come in the form of events (see below), but this may be changed to include a callback or promise for ergonomics.

grid ops

event system

events

next steps

see also