591 lines
24 KiB
HTML
591 lines
24 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width">
|
|
<title>DocStrap Source: wedo2smarthub.js</title>
|
|
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
|
|
|
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<a class="navbar-brand" href="index.html">DocStrap</a>
|
|
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
</div>
|
|
<div class="navbar-collapse collapse" id="topNavigation">
|
|
<ul class="nav navbar-nav">
|
|
|
|
<li class="dropdown">
|
|
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
|
|
<ul class="dropdown-menu ">
|
|
<li><a href="BoostMoveHub.html">BoostMoveHub</a></li><li><a href="DuploTrainBase.html">DuploTrainBase</a></li><li><a href="Hub.html">Hub</a></li><li><a href="LPF2Hub.html">LPF2Hub</a></li><li><a href="PoweredUP.html">PoweredUP</a></li><li><a href="PUPHub.html">PUPHub</a></li><li><a href="PUPRemote.html">PUPRemote</a></li><li><a href="WeDo2SmartHub.html">WeDo2SmartHub</a></li>
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
|
|
<ul class="dropdown-menu ">
|
|
<li><a href="BoostMoveHub.html#event:attach">BoostMoveHub#event:attach</a></li><li><a href="BoostMoveHub.html#event:button">BoostMoveHub#event:button</a></li><li><a href="BoostMoveHub.html#event:color">BoostMoveHub#event:color</a></li><li><a href="BoostMoveHub.html#event:colorAndDistance">BoostMoveHub#event:colorAndDistance</a></li><li><a href="BoostMoveHub.html#event:detach">BoostMoveHub#event:detach</a></li><li><a href="BoostMoveHub.html#event:distance">BoostMoveHub#event:distance</a></li><li><a href="BoostMoveHub.html#event:rotate">BoostMoveHub#event:rotate</a></li><li><a href="BoostMoveHub.html#event:tilt">BoostMoveHub#event:tilt</a></li><li><a href="DuploTrainBase.html#event:color">DuploTrainBase#event:color</a></li><li><a href="DuploTrainBase.html#event:speed">DuploTrainBase#event:speed</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:detach">Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:attach">LPF2Hub#event:attach</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:color">LPF2Hub#event:color</a></li><li><a href="LPF2Hub.html#event:colorAndDistance">LPF2Hub#event:colorAndDistance</a></li><li><a href="LPF2Hub.html#event:detach">LPF2Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:distance">LPF2Hub#event:distance</a></li><li><a href="LPF2Hub.html#event:rotate">LPF2Hub#event:rotate</a></li><li><a href="LPF2Hub.html#event:speed">LPF2Hub#event:speed</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="PoweredUP.html#event:discover">PoweredUP#event:discover</a></li><li><a href="PUPHub.html#event:attach">PUPHub#event:attach</a></li><li><a href="PUPHub.html#event:button">PUPHub#event:button</a></li><li><a href="PUPHub.html#event:color">PUPHub#event:color</a></li><li><a href="PUPHub.html#event:colorAndDistance">PUPHub#event:colorAndDistance</a></li><li><a href="PUPHub.html#event:detach">PUPHub#event:detach</a></li><li><a href="PUPHub.html#event:distance">PUPHub#event:distance</a></li><li><a href="PUPHub.html#event:tilt">PUPHub#event:tilt</a></li><li><a href="PUPRemote.html#event:button">PUPRemote#event:button</a></li><li><a href="PUPRemote.html#event:colorAndDistance">PUPRemote#event:colorAndDistance</a></li><li><a href="WeDo2SmartHub.html#event:attach">WeDo2SmartHub#event:attach</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</a></li><li><a href="WeDo2SmartHub.html#event:color">WeDo2SmartHub#event:color</a></li><li><a href="WeDo2SmartHub.html#event:detach">WeDo2SmartHub#event:detach</a></li><li><a href="WeDo2SmartHub.html#event:distance">WeDo2SmartHub#event:distance</a></li><li><a href="WeDo2SmartHub.html#event:rotate">WeDo2SmartHub#event:rotate</a></li><li><a href="WeDo2SmartHub.html#event:tilt">WeDo2SmartHub#event:tilt</a></li>
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="dropdown">
|
|
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
|
|
<ul class="dropdown-menu ">
|
|
<li><a href="global.html">Global</a></li>
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div class="col-sm-3 col-md-3">
|
|
<form class="navbar-form" role="search">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
|
|
<div class="input-group-btn">
|
|
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="container" id="toc-content">
|
|
<div class="row">
|
|
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div id="main">
|
|
|
|
|
|
<h1 class="page-title">Source: wedo2smarthub.js</h1>
|
|
|
|
<section>
|
|
<article>
|
|
<pre
|
|
class="sunlight-highlight-javascript linenums">"use strict";
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const hub_1 = require("./hub");
|
|
const port_1 = require("./port");
|
|
const Consts = __importStar(require("./consts"));
|
|
const Debug = require("debug");
|
|
const debug = Debug("wedo2smarthub");
|
|
/**
|
|
* The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
|
|
* @class WeDo2SmartHub
|
|
* @extends Hub
|
|
*/
|
|
class WeDo2SmartHub extends hub_1.Hub {
|
|
constructor(peripheral, autoSubscribe = true) {
|
|
super(peripheral, autoSubscribe);
|
|
this._lastTiltX = 0;
|
|
this._lastTiltY = 0;
|
|
this.type = Consts.HubType.WEDO2_SMART_HUB;
|
|
this._ports = {
|
|
"A": new port_1.Port("A", 1),
|
|
"B": new port_1.Port("B", 2)
|
|
};
|
|
debug("Discovered WeDo 2.0 Smart Hub");
|
|
}
|
|
// We set JSDoc to ignore these events as a WeDo 2.0 Smart Hub will never emit them.
|
|
/**
|
|
* @event WeDo2SmartHub#speed
|
|
* @ignore
|
|
*/
|
|
static IsWeDo2SmartHub(peripheral) {
|
|
return (peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.WEDO2_SMART_HUB.replace(/-/g, "")) >= 0);
|
|
}
|
|
connect() {
|
|
return new Promise(async (resolve, reject) => {
|
|
debug("Connecting to WeDo 2.0 Smart Hub");
|
|
await super.connect();
|
|
this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE), this._parsePortMessage.bind(this));
|
|
this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE), this._parseSensorMessage.bind(this));
|
|
this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON), this._parseSensorMessage.bind(this));
|
|
this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY), this._parseBatteryMessage.bind(this));
|
|
this._subscribeToCharacteristic(this._getCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT), this._parseHighCurrentAlert.bind(this));
|
|
this._getCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY).read((err, data) => {
|
|
this._parseBatteryMessage(data);
|
|
});
|
|
this._getCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION).read((err, data) => {
|
|
this._parseFirmwareRevisionString(data);
|
|
});
|
|
setTimeout(() => {
|
|
this._activatePortDevice(0x03, 0x15, 0x00, 0x00); // Activate voltage reports
|
|
this._activatePortDevice(0x04, 0x14, 0x00, 0x00); // Activate current reports
|
|
}, 1000);
|
|
debug("Connect completed");
|
|
return resolve();
|
|
});
|
|
}
|
|
/**
|
|
* Set the name of the Hub.
|
|
* @method WeDo2SmartHub#setName
|
|
* @param {string} name New name of the hub (14 characters or less, ASCII only).
|
|
* @returns {Promise} Resolved upon successful issuance of command.
|
|
*/
|
|
setName(name) {
|
|
if (name.length > 14) {
|
|
throw new Error("Name must be 14 characters or less");
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
const data = Buffer.from(name, "ascii");
|
|
// Send this twice, as sometimes the first time doesn't take
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_NAME_ID, data);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_NAME_ID, data);
|
|
this._name = name;
|
|
return resolve();
|
|
});
|
|
}
|
|
/**
|
|
* Set the color of the LED on the Hub via a color value.
|
|
* @method WeDo2SmartHub#setLEDColor
|
|
* @param {Color} color
|
|
* @returns {Promise} Resolved upon successful issuance of command.
|
|
*/
|
|
setLEDColor(color) {
|
|
return new Promise((resolve, reject) => {
|
|
let data = Buffer.from([0x06, 0x17, 0x01, 0x01]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, data);
|
|
if (color === false) {
|
|
color = 0;
|
|
}
|
|
data = Buffer.from([0x06, 0x04, 0x01, color]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data);
|
|
return resolve();
|
|
});
|
|
}
|
|
/**
|
|
* Set the color of the LED on the Hub via RGB values.
|
|
* @method WeDo2SmartHub#setLEDRGB
|
|
* @param {number} red
|
|
* @param {number} green
|
|
* @param {number} blue
|
|
* @returns {Promise} Resolved upon successful issuance of command.
|
|
*/
|
|
setLEDRGB(red, green, blue) {
|
|
return new Promise((resolve, reject) => {
|
|
let data = Buffer.from([0x06, 0x17, 0x01, 0x02]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, data);
|
|
data = Buffer.from([0x06, 0x04, 0x03, red, green, blue]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data);
|
|
return resolve();
|
|
});
|
|
}
|
|
/**
|
|
* Set the motor speed on a given port.
|
|
* @method WeDo2SmartHub#setMotorSpeed
|
|
* @param {string} port
|
|
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
* @param {number} [time] How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.
|
|
* @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
|
|
*/
|
|
setMotorSpeed(port, speed, time) {
|
|
const portObj = this._portLookup(port);
|
|
let cancelEventTimer = true;
|
|
if (typeof time === "boolean") {
|
|
if (time === true) {
|
|
cancelEventTimer = false;
|
|
}
|
|
time = undefined;
|
|
}
|
|
if (cancelEventTimer) {
|
|
portObj.cancelEventTimer();
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, this._mapSpeed(speed)]));
|
|
if (time && typeof time === "number") {
|
|
const timeout = global.setTimeout(() => {
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, Buffer.from([portObj.value, 0x01, 0x02, 0x00]));
|
|
return resolve();
|
|
}, time);
|
|
portObj.setEventTimer(timeout);
|
|
}
|
|
else {
|
|
return resolve();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Ramp the motor speed on a given port.
|
|
* @method WeDo2SmartHub#rampMotorSpeed
|
|
* @param {string} port
|
|
* @param {number} fromSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
* @param {number} toSpeed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
* @param {number} time How long the ramp should last (in milliseconds).
|
|
* @returns {Promise} Resolved upon successful completion of command.
|
|
*/
|
|
rampMotorSpeed(port, fromSpeed, toSpeed, time) {
|
|
const portObj = this._portLookup(port);
|
|
portObj.cancelEventTimer();
|
|
return new Promise((resolve, reject) => {
|
|
this._calculateRamp(fromSpeed, toSpeed, time, portObj)
|
|
.on("changeSpeed", (speed) => {
|
|
this.setMotorSpeed(port, speed, true);
|
|
})
|
|
.on("finished", resolve);
|
|
});
|
|
}
|
|
/**
|
|
* Fully (hard) stop the motor on a given port.
|
|
* @method WeDo2SmartHub#brakeMotor
|
|
* @param {string} port
|
|
* @returns {Promise} Resolved upon successful completion of command.
|
|
*/
|
|
brakeMotor(port) {
|
|
return this.setMotorSpeed(port, 127);
|
|
}
|
|
/**
|
|
* Play a tone on the Hub's in-built buzzer
|
|
* @method WeDo2SmartHub#playTone
|
|
* @param {number} frequency
|
|
* @param {number} time How long the tone should play for (in milliseconds).
|
|
* @returns {Promise} Resolved upon successful completion of command (ie. once the tone has finished playing).
|
|
*/
|
|
playTone(frequency, time) {
|
|
return new Promise((resolve, reject) => {
|
|
const data = Buffer.from([0x05, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00]);
|
|
data.writeUInt16LE(frequency, 3);
|
|
data.writeUInt16LE(time, 5);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data);
|
|
global.setTimeout(resolve, time);
|
|
});
|
|
}
|
|
/**
|
|
* Set the light brightness on a given port.
|
|
* @method WeDo2SmartHub#setLightBrightness
|
|
* @param {string} port
|
|
* @param {number} brightness Brightness value between 0-100 (0 is off)
|
|
* @param {number} [time] How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.
|
|
* @returns {Promise} Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
|
|
*/
|
|
setLightBrightness(port, brightness, time) {
|
|
const portObj = this._portLookup(port);
|
|
portObj.cancelEventTimer();
|
|
return new Promise((resolve, reject) => {
|
|
const data = Buffer.from([portObj.value, 0x01, 0x02, brightness]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data);
|
|
if (time) {
|
|
const timeout = global.setTimeout(() => {
|
|
const data = Buffer.from([portObj.value, 0x01, 0x02, 0x00]);
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE, data);
|
|
return resolve();
|
|
}, time);
|
|
portObj.setEventTimer(timeout);
|
|
}
|
|
else {
|
|
return resolve();
|
|
}
|
|
});
|
|
}
|
|
sendRaw(message, characteristic = Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE) {
|
|
return new Promise((resolve, reject) => {
|
|
this._writeMessage(characteristic, message, () => {
|
|
return resolve();
|
|
});
|
|
});
|
|
}
|
|
_activatePortDevice(port, type, mode, format, callback) {
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x01]), callback);
|
|
}
|
|
_deactivatePortDevice(port, type, mode, format, callback) {
|
|
this._writeMessage(Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x00]), callback);
|
|
}
|
|
_writeMessage(uuid, message, callback) {
|
|
const characteristic = this._getCharacteristic(uuid);
|
|
if (characteristic) {
|
|
if (debug.enabled) {
|
|
debug(`Sent Message (${this._getCharacteristicNameFromUUID(uuid)})`, message);
|
|
}
|
|
characteristic.write(message, false, callback);
|
|
}
|
|
}
|
|
_getCharacteristicNameFromUUID(uuid) {
|
|
const keys = Object.keys(Consts.BLECharacteristic);
|
|
for (let i = 0; i < keys.length; i++) {
|
|
const key = keys[i];
|
|
if (Consts.BLECharacteristic[key] === uuid) {
|
|
return key;
|
|
}
|
|
}
|
|
return "UNKNOWN";
|
|
}
|
|
_parseHighCurrentAlert(data) {
|
|
debug("Received Message (WEDO2_HIGH_CURRENT_ALERT)", data);
|
|
// console.log(data);
|
|
}
|
|
_parseBatteryMessage(data) {
|
|
debug("Received Message (WEDO2_BATTERY)", data);
|
|
this._batteryLevel = data[0];
|
|
}
|
|
_parseFirmwareRevisionString(data) {
|
|
debug("Received Message (WEDO2_FIRMWARE_REVISION)", data);
|
|
const parts = data.toString().split(".");
|
|
this._firmwareInfo = { major: parseInt(parts[0], 10), minor: parseInt(parts[1], 10), bugFix: parseInt(parts[2], 10), build: parseInt(parts[3], 10) };
|
|
}
|
|
_parsePortMessage(data) {
|
|
debug("Received Message (WEDO2_PORT_TYPE)", data);
|
|
const port = this._getPortForPortNumber(data[0]);
|
|
if (!port) {
|
|
return;
|
|
}
|
|
port.connected = data[1] === 1 ? true : false;
|
|
this._registerDeviceAttachment(port, data[3]);
|
|
}
|
|
_parseSensorMessage(data) {
|
|
debug("Received Message (WEDO2_SENSOR_VALUE)", data);
|
|
if (data[0] === 0x01) {
|
|
/**
|
|
* Emits when a button is pressed.
|
|
* @event WeDo2SmartHub#button
|
|
* @param {string} button
|
|
* @param {ButtonState} state
|
|
*/
|
|
this.emit("button", "GREEN", Consts.ButtonState.PRESSED);
|
|
return;
|
|
}
|
|
else if (data[0] === 0x00) {
|
|
this.emit("button", "GREEN", Consts.ButtonState.RELEASED);
|
|
return;
|
|
}
|
|
// Voltage
|
|
if (data[1] === 0x03) {
|
|
const voltage = data.readInt16LE(2);
|
|
this._voltage = voltage / 40;
|
|
// Current
|
|
}
|
|
else if (data[1] === 0x04) {
|
|
const current = data.readInt16LE(2);
|
|
this._current = current / 1000;
|
|
}
|
|
const port = this._getPortForPortNumber(data[1]);
|
|
if (!port) {
|
|
return;
|
|
}
|
|
if (port && port.connected) {
|
|
switch (port.type) {
|
|
case Consts.DeviceType.WEDO2_DISTANCE: {
|
|
let distance = data[2];
|
|
if (data[3] === 1) {
|
|
distance = data[2] + 255;
|
|
}
|
|
/**
|
|
* Emits when a distance sensor is activated.
|
|
* @event WeDo2SmartHub#distance
|
|
* @param {string} port
|
|
* @param {number} distance Distance, in millimeters.
|
|
*/
|
|
this.emit("distance", port.id, distance * 10);
|
|
break;
|
|
}
|
|
case Consts.DeviceType.BOOST_DISTANCE: {
|
|
const distance = data[2];
|
|
/**
|
|
* Emits when a color sensor is activated.
|
|
* @event WeDo2SmartHub#color
|
|
* @param {string} port
|
|
* @param {Color} color
|
|
*/
|
|
this.emit("color", port.id, distance);
|
|
break;
|
|
}
|
|
case Consts.DeviceType.WEDO2_TILT: {
|
|
this._lastTiltX = data[2];
|
|
if (this._lastTiltX > 100) {
|
|
this._lastTiltX = -(255 - this._lastTiltX);
|
|
}
|
|
this._lastTiltY = data[3];
|
|
if (this._lastTiltY > 100) {
|
|
this._lastTiltY = -(255 - this._lastTiltY);
|
|
}
|
|
/**
|
|
* Emits when a tilt sensor is activated.
|
|
* @event WeDo2SmartHub#tilt
|
|
* @param {string} port
|
|
* @param {number} x
|
|
* @param {number} y
|
|
*/
|
|
this.emit("tilt", port.id, this._lastTiltX, this._lastTiltY);
|
|
break;
|
|
}
|
|
case Consts.DeviceType.BOOST_TACHO_MOTOR: {
|
|
const rotation = data.readInt32LE(2);
|
|
/**
|
|
* Emits when a rotation sensor is activated.
|
|
* @event WeDo2SmartHub#rotate
|
|
* @param {string} port
|
|
* @param {number} rotation
|
|
*/
|
|
this.emit("rotate", port.id, rotation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exports.WeDo2SmartHub = WeDo2SmartHub;
|
|
</pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="modal fade" id="searchResults">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
<h4 class="modal-title">Search results</h4>
|
|
</div>
|
|
<div class="modal-body"></div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
</div>
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div>
|
|
|
|
|
|
<footer>
|
|
|
|
|
|
<span class="copyright">
|
|
node-poweredup by Nathan Kellenicki licensed under the MIT license.
|
|
</span>
|
|
|
|
<span class="jsdoc-message">
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
|
|
|
|
on Wed Jan 30th 2019
|
|
|
|
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
|
|
</span>
|
|
</footer>
|
|
|
|
<script src="scripts/docstrap.lib.js"></script>
|
|
<script src="scripts/toc.js"></script>
|
|
|
|
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
|
|
|
|
|
|
<script>
|
|
$( function () {
|
|
$( "[id*='$']" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
} );
|
|
|
|
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
|
|
var $this = $( this );
|
|
|
|
var example = $this.find( "code" );
|
|
exampleText = example.html();
|
|
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
if ( lang && lang[1] ) {
|
|
exampleText = exampleText.replace( lang[0], "" );
|
|
example.html( exampleText );
|
|
lang = lang[1];
|
|
} else {
|
|
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
|
|
lang = langClassMatch ? langClassMatch[1] : "javascript";
|
|
}
|
|
|
|
if ( lang ) {
|
|
|
|
$this
|
|
.addClass( "sunlight-highlight-" + lang )
|
|
.addClass( "linenums" )
|
|
.html( example.html() );
|
|
|
|
}
|
|
} );
|
|
|
|
Sunlight.highlightAll( {
|
|
lineNumbers : true,
|
|
showMenu : true,
|
|
enableDoclinks : true
|
|
} );
|
|
|
|
$.catchAnchorLinks( {
|
|
navbarOffset: 10
|
|
} );
|
|
$( "#toc" ).toc( {
|
|
anchorName : function ( i, heading, prefix ) {
|
|
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
},
|
|
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
|
|
showAndHide : false,
|
|
smoothScrolling: true
|
|
} );
|
|
|
|
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
$( '.dropdown-toggle' ).dropdown();
|
|
|
|
$( "table" ).each( function () {
|
|
var $this = $( this );
|
|
$this.addClass('table');
|
|
} );
|
|
|
|
} );
|
|
</script>
|
|
|
|
|
|
|
|
<!--Navigation and Symbol Display-->
|
|
|
|
|
|
<!--Google Analytics-->
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
SearcherDisplay.init();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|