Mist API
A native node.js plugin which uses the C99 Mist implementation. Currently working with Linux x86_64 and nodejs v6.x only. To get it working you need to run a Wish Core on the same host.
Install
npm install mist-api
Example
var Mist = require('mist-api').Mist;
var mist = new Mist();
var model = {
device: "Joystick",
model: {
axis0: {
label: "Axis (left/right)",
type: "float",
scale: "100",
unit: "%",
read: true
},
axis1: {
label: "Axis (up/down)",
type: "float",
scale: "100",
unit: "%",
read: true
},
button0: {
label: "Button 1",
type: "bool",
data: false
},
button1: {
label: "Button 2",
type: "bool",
data: false,
write: true
}
}
};
mist.write(function(endpoint, value) {
console.log("mist write:", endpoint, value);
});
mist.invoke('config', function(args, cb) {
console.log("mist invoke:", args);
cb({ yo: [5,4], all: args });
});
mist.create(model);
var button0 = false;
var interval = setInterval(function() {
button0 = !button0;
var axis0 = Math.sin(Date.now()/4000);
mist.update('axis0', axis0);
mist.update('axis1', Math.round(axis0));
mist.update('button0', button0);
}, 300);