Updated vernie sample, added braking style

This commit is contained in:
Nathan Kellenicki 2020-02-07 14:28:32 -08:00
parent e34eea98ba
commit c0009f8f08
53 changed files with 22479 additions and 24273 deletions

View File

@ -69,17 +69,22 @@ const poweredUP = new PoweredUP.PoweredUP();
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
console.log(`Discovered ${hub.name}!`);
await hub.connect(); // Connect to the Hub
const motorA = hub.waitForDeviceAtPort("A"); // Make sure a motor is plugged into port A
const motorB = hub.waitForDeviceAtPort("B"); // Make sure a motor is plugged into port B
console.log("Connected");
await hub.sleep(3000); // Sleep for 3 seconds before starting
while (true) { // Repeat indefinitely
console.log("Running motor B at speed 75");
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
motorB.setPower("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
console.log("Running motor A at speed 100 for 2 seconds");
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
motorA.setPower("A", 100); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
await hub.sleep(2000);
motorA.setPower("A", 0);
await hub.sleep(1000); // Do nothing for 1 second
console.log("Running motor A at speed -50 for 1 seconds");
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
console.log("Running motor A at speed -50 for 1 second");
motorA.setPower("A", -50); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop
hub.sleep(1000);
motorA.setPower("A", 0);
await hub.sleep(1000); // Do nothing for 1 second
}
});

1419
docs/BaseHub.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2412
docs/MoveHub.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2412
docs/RemoteControl.html Normal file

File diff suppressed because it is too large Load Diff

2412
docs/TechnicMediumHub.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,296 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/absolutemotor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/absolutemotor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 tachomotor_1 = require("./tachomotor");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
class AbsoluteMotor extends tachomotor_1.TachoMotor {
constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
super(hub, portId, Object.assign({}, modeMap, exports.ModeMap), type);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.ABSOLUTE:
const angle = utils_1.normalizeAngle(message.readInt16LE(this.isWeDo2SmartHub ? 2 : 4));
/**
* Emits when a the motors absolute position is changed.
* @event AbsoluteMotor#absolute
* @param {number} absolute
*/
this.notify("absolute", { angle });
break;
default:
super.receive(message);
break;
}
}
/**
* Rotate a motor by a given angle.
* @method AbsoluteMotor#gotoAngle
* @param {number} angle Absolute position the motor should go to (degrees from 0).
* @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
gotoAngle(angle, speed = 100) {
if (!this.isVirtualPort &amp;&amp; angle instanceof Array) {
throw new Error("Only virtual ports can accept multiple positions");
}
if (this.isWeDo2SmartHub) {
throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub");
}
this.cancelEventTimer();
return new Promise((resolve) => {
this._busy = true;
if (speed === undefined || speed === null) {
speed = 100;
}
let message;
if (angle instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
message.writeInt32LE(utils_1.normalizeAngle(angle[0]), 4);
message.writeInt32LE(utils_1.normalizeAngle(angle[1]), 8);
}
else {
message = Buffer.from([0x81, this.portId, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
message.writeInt32LE(utils_1.normalizeAngle(angle), 4);
}
this.send(message);
this._finished = () => {
return resolve();
};
});
}
}
exports.AbsoluteMotor = AbsoluteMotor;
var Mode;
(function (Mode) {
Mode[Mode["ROTATION"] = 2] = "ROTATION";
Mode[Mode["ABSOLUTE"] = 3] = "ABSOLUTE";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"rotate": Mode.ROTATION,
"absolute": Mode.ABSOLUTE
};
//# sourceMappingURL=absolutemotor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,285 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/basicmotor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/basicmotor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
class BasicMotor extends device_1.Device {
constructor(hub, portId, modeMap, type = Consts.DeviceType.UNKNOWN) {
super(hub, portId, modeMap, type);
}
/**
* Set the motor power.
* @method BasicMotor#setPower
* @param {number} power For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
* @returns {Promise} Resolved upon successful completion of command.
*/
setPower(power, interrupt = true) {
if (interrupt) {
this.cancelEventTimer();
}
return new Promise((resolve) => {
this.writeDirect(0x00, Buffer.from([utils_1.mapSpeed(power)]));
return resolve();
});
}
/**
* Ramp the motor power.
* @method BasicMotor#rampPower
* @param {number} fromPower For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
* @param {number} toPower 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.
*/
rampPower(fromPower, toPower, time) {
this.cancelEventTimer();
return new Promise((resolve) => {
utils_1.calculateRamp(this, fromPower, toPower, time)
.on("changePower", (power) => {
this.setPower(power, false);
})
.on("finished", resolve);
});
}
/**
* Stop the motor.
* @method BasicMotor#stop
* @returns {Promise} Resolved upon successful completion of command.
*/
stop() {
this.cancelEventTimer();
return this.setPower(0);
}
/**
* Brake the motor.
* @method BasicMotor#brake
* @returns {Promise} Resolved upon successful completion of command.
*/
brake() {
this.cancelEventTimer();
return this.setPower(Consts.BrakingStyle.BRAKE);
}
}
exports.BasicMotor = BasicMotor;
//# sourceMappingURL=basicmotor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,295 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/colordistancesensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/colordistancesensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class ColorDistanceSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.COLOR_DISTANCE_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.COLOR:
if (message[this.isWeDo2SmartHub ? 2 : 4] &lt;= 10) {
const color = message[this.isWeDo2SmartHub ? 2 : 4];
/**
* Emits when a color sensor is activated.
* @event ColorDistanceSensor#color
* @param {Color} color
*/
this.notify("color", { color });
}
break;
case Mode.DISTANCE:
if (this.isWeDo2SmartHub) {
break;
}
if (message[4] &lt;= 10) {
const distance = Math.floor(message[4] * 25.4) - 20;
/**
* Emits when a distance sensor is activated.
* @event ColorDistanceSensor#distance
* @param {number} distance Distance, in millimeters.
*/
this.notify("distance", { distance });
}
break;
case Mode.COLOR_AND_DISTANCE:
if (this.isWeDo2SmartHub) {
break;
}
let distance = message[5];
const partial = message[7];
if (partial > 0) {
distance += 1.0 / partial;
}
distance = Math.floor(distance * 25.4) - 20;
/**
* A combined color and distance event, emits when the sensor is activated.
* @event ColorDistanceSensor#colorAndDistance
* @param {Color} color
* @param {number} distance Distance, in millimeters.
*/
if (message[4] &lt;= 10) {
const color = message[4];
this.notify("colorAndDistance", { color, distance });
}
break;
}
}
}
exports.ColorDistanceSensor = ColorDistanceSensor;
var Mode;
(function (Mode) {
Mode[Mode["COLOR"] = 0] = "COLOR";
Mode[Mode["DISTANCE"] = 1] = "DISTANCE";
Mode[Mode["COLOR_AND_DISTANCE"] = 8] = "COLOR_AND_DISTANCE";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"color": Mode.COLOR,
"distance": Mode.DISTANCE,
"colorAndDistance": Mode.COLOR_AND_DISTANCE
};
//# sourceMappingURL=colordistancesensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,275 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/currentsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/currentsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class CurrentSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.CURRENT_SENSOR);
}
receive(message) {
const mode = this.mode;
switch (mode) {
case Mode.CURRENT:
if (this.isWeDo2SmartHub) {
const current = message.readInt16LE(2) / 1000;
this.notify("current", { current });
}
else {
let maxCurrentValue = MaxCurrentValue[this.hub.type];
if (maxCurrentValue === undefined) {
maxCurrentValue = MaxCurrentValue[Consts.HubType.UNKNOWN];
}
let maxCurrentRaw = MaxCurrentRaw[this.hub.type];
if (maxCurrentRaw === undefined) {
maxCurrentRaw = MaxCurrentRaw[Consts.HubType.UNKNOWN];
}
const current = message.readUInt16LE(4) * maxCurrentValue / maxCurrentRaw;
/**
* Emits when a current change is detected.
* @event CurrentSensor#current
* @param {number} current
*/
this.notify("current", { current });
}
break;
}
}
}
exports.CurrentSensor = CurrentSensor;
var Mode;
(function (Mode) {
Mode[Mode["CURRENT"] = 0] = "CURRENT";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"current": Mode.CURRENT
};
const MaxCurrentValue = {
[Consts.HubType.UNKNOWN]: 2444,
[Consts.HubType.TECHNIC_MEDIUM_HUB]: 4175,
};
const MaxCurrentRaw = {
[Consts.HubType.UNKNOWN]: 4095,
};
//# sourceMappingURL=currentsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,256 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/duplotrainbasecolorsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/duplotrainbasecolorsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class DuploTrainBaseColorSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.COLOR:
if (message[4] &lt;= 10) {
const color = message[4];
/**
* Emits when a color sensor is activated.
* @event DuploTrainBaseColorSensor#color
* @param {Color} color
*/
this.notify("color", { color });
}
break;
}
}
}
exports.DuploTrainBaseColorSensor = DuploTrainBaseColorSensor;
var Mode;
(function (Mode) {
Mode[Mode["COLOR"] = 0] = "COLOR";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"color": Mode.COLOR
};
//# sourceMappingURL=duplotrainbasecolorsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,250 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/duplotrainbasespeaker.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/duplotrainbasespeaker.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class DuploTrainBaseSpeaker extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, {}, Consts.DeviceType.DUPLO_TRAIN_BASE_SPEAKER);
}
/**
* Play a built-in train sound.
* @method DuploTrainBaseSpeaker#playSound
* @param {DuploTrainBaseSound} sound
* @returns {Promise} Resolved upon successful issuance of command.
*/
playSound(sound) {
return new Promise((resolve, reject) => {
this.subscribe(Mode.SOUND);
this.writeDirect(0x01, Buffer.from([sound]));
return resolve();
});
}
}
exports.DuploTrainBaseSpeaker = DuploTrainBaseSpeaker;
var Mode;
(function (Mode) {
Mode[Mode["SOUND"] = 1] = "SOUND";
})(Mode = exports.Mode || (exports.Mode = {}));
//# sourceMappingURL=duplotrainbasespeaker.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,254 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/duplotrainbasespeedometer.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/duplotrainbasespeedometer.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class DuploTrainBaseSpeedometer extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.SPEED:
const speed = message.readInt16LE(4);
/**
* Emits on a speed change.
* @event DuploTrainBaseSpeedometer#speed
* @param {number} speed
*/
this.notify("speed", { speed });
break;
}
}
}
exports.DuploTrainBaseSpeedometer = DuploTrainBaseSpeedometer;
var Mode;
(function (Mode) {
Mode[Mode["SPEED"] = 0] = "SPEED";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"speed": Mode.SPEED
};
//# sourceMappingURL=duplotrainbasespeedometer.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

281
docs/devices_hubled.js.html Normal file
View File

@ -0,0 +1,281 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/hubled.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/hubled.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class HubLED extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, {}, Consts.DeviceType.HUB_LED);
}
/**
* Set the color of the LED on the Hub via a color value.
* @method HubLED#setColor
* @param {Color} color
* @returns {Promise} Resolved upon successful issuance of command.
*/
setColor(color) {
return new Promise((resolve, reject) => {
if (typeof color === "boolean") {
color = 0;
}
if (this.isWeDo2SmartHub) {
this.send(Buffer.from([0x06, 0x17, 0x01, 0x01]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
this.send(Buffer.from([0x06, 0x04, 0x01, color]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
}
else {
this.subscribe(Mode.COLOR);
this.writeDirect(0x00, Buffer.from([color]));
}
return resolve();
});
}
/**
* Set the color of the LED on the Hub via RGB values.
* @method HubLED#setRGB
* @param {number} red
* @param {number} green
* @param {number} blue
* @returns {Promise} Resolved upon successful issuance of command.
*/
setRGB(red, green, blue) {
return new Promise((resolve, reject) => {
if (this.isWeDo2SmartHub) {
this.send(Buffer.from([0x06, 0x17, 0x01, 0x02]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
this.send(Buffer.from([0x06, 0x04, 0x03, red, green, blue]), Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
}
else {
this.subscribe(Mode.RGB);
this.writeDirect(0x01, Buffer.from([red, green, blue]));
}
return resolve();
});
}
}
exports.HubLED = HubLED;
var Mode;
(function (Mode) {
Mode[Mode["COLOR"] = 0] = "COLOR";
Mode[Mode["RGB"] = 1] = "RGB";
})(Mode = exports.Mode || (exports.Mode = {}));
//# sourceMappingURL=hubled.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

267
docs/devices_light.js.html Normal file
View File

@ -0,0 +1,267 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/light.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/light.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
class Light extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, {}, Consts.DeviceType.LIGHT);
}
/**
* Set the light brightness.
* @method Light#setBrightness
* @param {number} brightness Brightness value between 0-100 (0 is off)
* @returns {Promise} Resolved upon successful completion of command.
*/
setBrightness(brightness, interrupt = true) {
if (interrupt) {
this.cancelEventTimer();
}
return new Promise((resolve) => {
this.writeDirect(0x00, Buffer.from([brightness]));
return resolve();
});
}
/**
* Ramp the light brightness.
* @method Light#rampBrightness
* @param {number} fromBrightness Brightness value between 0-100 (0 is off)
* @param {number} toBrightness Brightness value between 0-100 (0 is off)
* @param {number} time How long the ramp should last (in milliseconds).
* @returns {Promise} Resolved upon successful completion of command.
*/
rampBrightness(fromBrightness, toBrightness, time) {
this.cancelEventTimer();
return new Promise((resolve) => {
utils_1.calculateRamp(this, fromBrightness, toBrightness, time)
.on("changePower", (power) => {
this.setBrightness(power, false);
})
.on("finished", resolve);
});
}
}
exports.Light = Light;
//# sourceMappingURL=light.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,258 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/motionsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/motionsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class MotionSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.MOTION_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.DISTANCE:
let distance = message[this.isWeDo2SmartHub ? 2 : 4];
if (message[this.isWeDo2SmartHub ? 3 : 5] === 1) {
distance = distance + 255;
}
distance *= 10;
/**
* Emits when a distance sensor is activated.
* @event MotionSensor#distance
* @param {number} distance Distance, in millimeters.
*/
this.notify("distance", { distance });
break;
}
}
}
exports.MotionSensor = MotionSensor;
var Mode;
(function (Mode) {
Mode[Mode["DISTANCE"] = 0] = "DISTANCE";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"distance": Mode.DISTANCE
};
//# sourceMappingURL=motionsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,256 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/movehubtiltsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/movehubtiltsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class MoveHubTiltSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.MOVE_HUB_TILT_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.TILT:
/**
* Emits when a tilt sensor is activated.
* @event MoveHubTiltSensor#tilt
* @param {number} x
* @param {number} y
*/
const x = -message.readInt8(4);
const y = message.readInt8(5);
this.notify("tilt", { x, y });
break;
}
}
}
exports.MoveHubTiltSensor = MoveHubTiltSensor;
var Mode;
(function (Mode) {
Mode[Mode["TILT"] = 0] = "TILT";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"tilt": Mode.TILT
};
//# sourceMappingURL=movehubtiltsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,249 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/piezobuzzer.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/piezobuzzer.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class PiezoBuzzer extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, {}, Consts.DeviceType.PIEZO_BUZZER);
}
/**
* Play a tone on the Hub's in-built buzzer
* @method PiezoBuzzer#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) => {
const data = Buffer.from([0x05, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00]);
data.writeUInt16LE(frequency, 3);
data.writeUInt16LE(time, 5);
this.send(data, Consts.BLECharacteristic.WEDO2_MOTOR_VALUE_WRITE);
global.setTimeout(resolve, time);
});
}
}
exports.PiezoBuzzer = PiezoBuzzer;
//# sourceMappingURL=piezobuzzer.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,260 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/remotecontrolbutton.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/remotecontrolbutton.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class RemoteControlButton extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.REMOTE_CONTROL_BUTTON);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.BUTTON_EVENTS:
/**
* Emits when a button on the remote is pressed or released.
* @event RemoteControlButton#button
* @param {number} event
*/
const event = message[4];
this.notify("remoteButton", { event });
break;
}
}
}
exports.RemoteControlButton = RemoteControlButton;
var Mode;
(function (Mode) {
Mode[Mode["BUTTON_EVENTS"] = 0] = "BUTTON_EVENTS";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"remoteButton": Mode.BUTTON_EVENTS
};
exports.ButtonState = {
"UP": 0x01,
"DOWN": 0xff,
"STOP": 0x7f,
"RELEASED": 0x00,
};
//# sourceMappingURL=remotecontrolbutton.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,336 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/tachomotor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/tachomotor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 basicmotor_1 = require("./basicmotor");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
class TachoMotor extends basicmotor_1.BasicMotor {
constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
super(hub, portId, Object.assign({}, modeMap, exports.ModeMap), type);
this._brakeStyle = Consts.BrakingStyle.BRAKE;
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.ROTATION:
const degrees = message.readInt32LE(this.isWeDo2SmartHub ? 2 : 4);
/**
* Emits when a rotation sensor is activated.
* @event TachoMotor#rotate
* @param {number} rotation
*/
this.notify("rotate", { degrees });
break;
}
}
setBrakingStyle(style) {
this._brakeStyle = style;
}
/**
* Set the motor speed.
* @method TachoMotor#setSpeed
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
* @returns {Promise} Resolved upon successful completion of command.
*/
setSpeed(speed, time) {
if (!this.isVirtualPort &amp;&amp; speed instanceof Array) {
throw new Error("Only virtual ports can accept multiple speeds");
}
if (this.isWeDo2SmartHub) {
throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub");
}
this.cancelEventTimer();
return new Promise((resolve) => {
this._busy = true;
if (speed === undefined || speed === null) {
speed = 100;
}
let message;
if (time !== undefined) {
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0a, 0x00, 0x00, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
}
else {
message = Buffer.from([0x81, this.portId, 0x11, 0x09, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
}
message.writeUInt16LE(time, 4);
}
else {
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x08, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
}
else {
message = Buffer.from([0x81, this.portId, 0x11, 0x07, utils_1.mapSpeed(speed), 0x64, 0x03, 0x64, this._brakeStyle, 0x00]);
}
}
this.send(message);
this._finished = () => {
return resolve();
};
});
}
/**
* Rotate a motor by a given amount of degrees.
* @method TachoMotor#rotateByDegrees
* @param {number} degrees How much the motor should be rotated (in degrees).
* @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
rotateByDegrees(degrees, speed) {
if (!this.isVirtualPort &amp;&amp; speed instanceof Array) {
throw new Error("Only virtual ports can accept multiple speeds");
}
if (this.isWeDo2SmartHub) {
throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub");
}
this.cancelEventTimer();
return new Promise((resolve) => {
this._busy = true;
if (speed === undefined || speed === null) {
speed = 100;
}
let message;
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed[0]), utils_1.mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x03]);
}
else {
message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, utils_1.mapSpeed(speed), 0x64, this._brakeStyle, 0x03]);
}
message.writeUInt32LE(degrees, 4);
this.send(message);
this._finished = () => {
return resolve();
};
});
}
}
exports.TachoMotor = TachoMotor;
var Mode;
(function (Mode) {
Mode[Mode["ROTATION"] = 2] = "ROTATION";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"rotate": Mode.ROTATION
};
//# sourceMappingURL=tachomotor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,278 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/techniccolorsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/techniccolorsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicColorSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_COLOR_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.COLOR:
if (message[4] &lt;= 10) {
const color = message[4];
/**
* Emits when a color sensor is activated.
* @event TechnicColorSensor#color
* @param {Color} color
*/
this.notify("color", { color });
}
break;
case Mode.REFLECTIVITY:
const reflect = message[4];
/**
* Emits when the light reflectivity changes.
* @event TechnicColorSensor#reflect Percentage, from 0 to 100.
* @param {number} reflect
*/
this.notify("reflect", { reflect });
break;
case Mode.AMBIENT_LIGHT:
const ambient = message[4];
/**
* Emits when the ambient light changes.
* @event TechnicColorSensor#ambient Percentage, from 0 to 100.
* @param {number} ambient
*/
this.notify("ambient", { ambient });
break;
}
}
}
exports.TechnicColorSensor = TechnicColorSensor;
var Mode;
(function (Mode) {
Mode[Mode["COLOR"] = 0] = "COLOR";
Mode[Mode["REFLECTIVITY"] = 1] = "REFLECTIVITY";
Mode[Mode["AMBIENT_LIGHT"] = 2] = "AMBIENT_LIGHT";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"color": Mode.COLOR,
"reflect": Mode.REFLECTIVITY,
"ambient": Mode.AMBIENT_LIGHT
};
//# sourceMappingURL=techniccolorsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,277 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/technicdistancesensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/technicdistancesensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicDistanceSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_DISTANCE_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.DISTANCE:
const distance = message.readUInt16LE(4);
/**
* Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).
* @event TechnicDistanceSensor#distance Distance, from 40 to 2500mm
* @param {number} distance
*/
this.notify("distance", { distance });
break;
case Mode.FAST_DISTANCE:
const fastDistance = message.readUInt16LE(4);
/**
* Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).
* @event TechnicDistanceSensor#fastDistance Distance, from 50 to 320mm
* @param {number} fastDistance
*/
this.notify("fastDistance", { fastDistance });
break;
}
}
/**
* Set the brightness (or turn on/off) the lights around the eyes.
* @method TechnicDistanceSensor#setBrightness
* @param {number} topLeft Top left quadrant (above left eye). 0-100 brightness.
* @param {number} bottomLeft Bottom left quadrant (below left eye). 0-100 brightness.
* @param {number} topRight Top right quadrant (above right eye). 0-100 brightness.
* @param {number} bottomRight Bottom right quadrant (below right eye). 0-100 brightness.
* @returns {Promise} Resolved upon successful completion of command.
*/
setBrightness(topLeft, bottomLeft, topRight, bottomRight) {
this.writeDirect(0x05, Buffer.from([topLeft, topRight, bottomLeft, bottomRight]));
}
}
exports.TechnicDistanceSensor = TechnicDistanceSensor;
var Mode;
(function (Mode) {
Mode[Mode["DISTANCE"] = 0] = "DISTANCE";
Mode[Mode["FAST_DISTANCE"] = 1] = "FAST_DISTANCE";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"distance": Mode.DISTANCE,
"fastDistance": Mode.FAST_DISTANCE
};
//# sourceMappingURL=technicdistancesensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,276 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/technicforcesensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/technicforcesensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicForceSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_FORCE_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.FORCE:
const force = message[4] / 10;
/**
* Emits when force is applied.
* @event TechnicForceSensor#force Force, in newtons (0-10).
* @param {number} force
*/
this.notify("force", { force });
break;
case Mode.TOUCHED:
const touched = message[4] ? true : false;
/**
* Emits when the sensor is touched.
* @event TechnicForceSensor#touch Touched on/off (boolean).
* @param {boolean} touch
*/
this.notify("touched", { touched });
break;
case Mode.TAPPED:
const tapped = message[4];
/**
* Emits when the sensor is tapped.
* @event TechnicForceSensor#tapped How hard the sensor was tapped, from 0-3.
* @param {number} tapped
*/
this.notify("tapped", { tapped });
break;
}
}
}
exports.TechnicForceSensor = TechnicForceSensor;
var Mode;
(function (Mode) {
Mode[Mode["FORCE"] = 0] = "FORCE";
Mode[Mode["TOUCHED"] = 1] = "TOUCHED";
Mode[Mode["TAPPED"] = 2] = "TAPPED";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"force": Mode.FORCE,
"touched": Mode.TOUCHED,
"tapped": Mode.TAPPED
};
//# sourceMappingURL=technicforcesensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,259 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/technicmediumhubaccelerometersensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/technicmediumhubaccelerometersensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicMediumHubAccelerometerSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.ACCEL:
/**
* Emits when accelerometer detects movement. Measured in mG.
* @event LPF2Hub#accel
* @param {string} port
* @param {number} x
* @param {number} y
* @param {number} z
*/
const x = Math.round(message.readInt16LE(4) / 4.096);
const y = Math.round(message.readInt16LE(6) / 4.096);
const z = Math.round(message.readInt16LE(8) / 4.096);
this.notify("accel", { x, y, z });
break;
}
}
}
exports.TechnicMediumHubAccelerometerSensor = TechnicMediumHubAccelerometerSensor;
var Mode;
(function (Mode) {
Mode[Mode["ACCEL"] = 0] = "ACCEL";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"accel": Mode.ACCEL
};
//# sourceMappingURL=technicmediumhubaccelerometersensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,258 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/technicmediumhubgyrosensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/technicmediumhubgyrosensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicMediumHubGyroSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.GYRO:
/**
* Emits when gyroscope detects movement. Measured in DPS - degrees per second.
* @event TechnicMediumHubGyroSensor#gyro
* @param {number} x
* @param {number} y
* @param {number} z
*/
const x = Math.round(message.readInt16LE(4) * 7 / 400);
const y = Math.round(message.readInt16LE(6) * 7 / 400);
const z = Math.round(message.readInt16LE(8) * 7 / 400);
this.notify("gyro", { x, y, z });
break;
}
}
}
exports.TechnicMediumHubGyroSensor = TechnicMediumHubGyroSensor;
var Mode;
(function (Mode) {
Mode[Mode["GYRO"] = 0] = "GYRO";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"gyro": Mode.GYRO
};
//# sourceMappingURL=technicmediumhubgyrosensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,258 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/technicmediumhubtiltsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/technicmediumhubtiltsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TechnicMediumHubTiltSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.TILT:
/**
* Emits when a tilt sensor is activated.
* @event TechnicMediumHubTiltSensor#tilt
* @param {number} x
* @param {number} y
* @param {number} z
*/
const z = -message.readInt16LE(4);
const y = message.readInt16LE(6);
const x = message.readInt16LE(8);
this.notify("tilt", { x, y, z });
break;
}
}
}
exports.TechnicMediumHubTiltSensor = TechnicMediumHubTiltSensor;
var Mode;
(function (Mode) {
Mode[Mode["TILT"] = 0] = "TILT";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"tilt": Mode.TILT
};
//# sourceMappingURL=technicmediumhubtiltsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,256 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/tiltsensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/tiltsensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class TiltSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.TILT_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.TILT:
const x = message.readInt8(this.isWeDo2SmartHub ? 2 : 4);
const y = message.readInt8(this.isWeDo2SmartHub ? 3 : 5);
/**
* Emits when a tilt sensor is activated.
* @event LPF2Hub#tilt
* @param {number} x
* @param {number} y
*/
this.notify("tilt", { x, y });
break;
}
}
}
exports.TiltSensor = TiltSensor;
var Mode;
(function (Mode) {
Mode[Mode["TILT"] = 0] = "TILT";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"tilt": Mode.TILT
};
//# sourceMappingURL=tiltsensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,279 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: devices/voltagesensor.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: devices/voltagesensor.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 device_1 = require("./device");
const Consts = __importStar(require("../consts"));
class VoltageSensor extends device_1.Device {
constructor(hub, portId) {
super(hub, portId, exports.ModeMap, Consts.DeviceType.VOLTAGE_SENSOR);
}
receive(message) {
const mode = this._mode;
switch (mode) {
case Mode.VOLTAGE:
if (this.isWeDo2SmartHub) {
const voltage = message.readInt16LE(2) / 40;
this.notify("voltage", { voltage });
}
else {
let maxVoltageValue = MaxVoltageValue[this.hub.type];
if (maxVoltageValue === undefined) {
maxVoltageValue = MaxVoltageValue[Consts.HubType.UNKNOWN];
}
let maxVoltageRaw = MaxVoltageRaw[this.hub.type];
if (maxVoltageRaw === undefined) {
maxVoltageRaw = MaxVoltageRaw[Consts.HubType.UNKNOWN];
}
const voltage = message.readUInt16LE(4) * maxVoltageValue / maxVoltageRaw;
/**
* Emits when a voltage change is detected.
* @event VoltageSensor#voltage
* @param {number} voltage
*/
this.notify("voltage", { voltage });
}
break;
}
}
}
exports.VoltageSensor = VoltageSensor;
var Mode;
(function (Mode) {
Mode[Mode["VOLTAGE"] = 0] = "VOLTAGE";
})(Mode = exports.Mode || (exports.Mode = {}));
exports.ModeMap = {
"voltage": Mode.VOLTAGE
};
const MaxVoltageValue = {
[Consts.HubType.UNKNOWN]: 9.615,
[Consts.HubType.DUPLO_TRAIN_BASE]: 6.4,
[Consts.HubType.REMOTE_CONTROL]: 6.4,
};
const MaxVoltageRaw = {
[Consts.HubType.UNKNOWN]: 3893,
[Consts.HubType.DUPLO_TRAIN_BASE]: 3047,
[Consts.HubType.REMOTE_CONTROL]: 3200,
[Consts.HubType.TECHNIC_MEDIUM_HUB]: 4095,
};
//# sourceMappingURL=voltagesensor.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

File diff suppressed because one or more lines are too long

543
docs/hubs_basehub.js.html Normal file
View File

@ -0,0 +1,543 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/basehub.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/basehub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 events_1 = require("events");
const colordistancesensor_1 = require("../devices/colordistancesensor");
const currentsensor_1 = require("../devices/currentsensor");
const device_1 = require("../devices/device");
const duplotrainbasecolorsensor_1 = require("../devices/duplotrainbasecolorsensor");
const duplotrainbasemotor_1 = require("../devices/duplotrainbasemotor");
const duplotrainbasespeaker_1 = require("../devices/duplotrainbasespeaker");
const duplotrainbasespeedometer_1 = require("../devices/duplotrainbasespeedometer");
const hubled_1 = require("../devices/hubled");
const light_1 = require("../devices/light");
const mediumlinearmotor_1 = require("../devices/mediumlinearmotor");
const motionsensor_1 = require("../devices/motionsensor");
const movehubmediumlinearmotor_1 = require("../devices/movehubmediumlinearmotor");
const movehubtiltsensor_1 = require("../devices/movehubtiltsensor");
const piezobuzzer_1 = require("../devices/piezobuzzer");
const remotecontrolbutton_1 = require("../devices/remotecontrolbutton");
const simplemediumlinearmotor_1 = require("../devices/simplemediumlinearmotor");
const techniccolorsensor_1 = require("../devices/techniccolorsensor");
const technicdistancesensor_1 = require("../devices/technicdistancesensor");
const technicforcesensor_1 = require("../devices/technicforcesensor");
const techniclargeangularmotor_1 = require("../devices/techniclargeangularmotor");
const techniclargelinearmotor_1 = require("../devices/techniclargelinearmotor");
const technicmediumangularmotor_1 = require("../devices/technicmediumangularmotor");
const technicmediumhubaccelerometersensor_1 = require("../devices/technicmediumhubaccelerometersensor");
const technicmediumhubgyrosensor_1 = require("../devices/technicmediumhubgyrosensor");
const technicmediumhubtiltsensor_1 = require("../devices/technicmediumhubtiltsensor");
const technicxlargelinearmotor_1 = require("../devices/technicxlargelinearmotor");
const tiltsensor_1 = require("../devices/tiltsensor");
const trainmotor_1 = require("../devices/trainmotor");
const voltagesensor_1 = require("../devices/voltagesensor");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("basehub");
/**
* @class BaseHub
* @extends EventEmitter
*/
class BaseHub extends events_1.EventEmitter {
constructor(bleDevice, portMap = {}, type = Consts.HubType.UNKNOWN) {
super();
this._attachedDevices = {};
this._name = "";
this._firmwareVersion = "0.0.00.0000";
this._hardwareVersion = "0.0.00.0000";
this._primaryMACAddress = "00:00:00:00:00:00";
this._batteryLevel = 100;
this._rssi = -60;
this._portMap = {};
this._virtualPorts = [];
this._attachCallbacks = [];
this.setMaxListeners(23); // Technic Medium Hub has 9 built in devices + 4 external ports. Node.js throws a warning after 10 attached event listeners.
this._type = type;
this._bleDevice = bleDevice;
this._portMap = Object.assign({}, portMap);
bleDevice.on("disconnect", () => {
/**
* Emits when the hub is disconnected.
* @event Hub#disconnect
*/
this.emit("disconnect");
});
}
/**
* @readonly
* @property {string} name Name of the hub
*/
get name() {
return this._bleDevice.name;
}
/**
* @readonly
* @property {string} type Hub type
*/
get type() {
return this._type;
}
/**
* @readonly
* @property {string[]} ports Array of port names
*/
get ports() {
return Object.keys(this._portMap);
}
/**
* @readonly
* @property {string} firmwareVersion Firmware version of the hub
*/
get firmwareVersion() {
return this._firmwareVersion;
}
/**
* @readonly
* @property {string} firmwareVersion Hardware version of the hub
*/
get hardwareVersion() {
return this._hardwareVersion;
}
/**
* @readonly
* @property {string} primaryMACAddress Primary MAC address of the hub
*/
get primaryMACAddress() {
return this._primaryMACAddress;
}
/**
* @readonly
* @property {string} uuid UUID of the hub
*/
get uuid() {
return this._bleDevice.uuid;
}
/**
* @readonly
* @property {number} batteryLevel Battery level of the hub (Percentage between 0-100)
*/
get batteryLevel() {
return this._batteryLevel;
}
/**
* @readonly
* @property {number} rssi Signal strength of the hub
*/
get rssi() {
return this._rssi;
}
/**
* Connect to the Hub.
* @method Hub#connect
* @returns {Promise} Resolved upon successful connect.
*/
connect() {
return new Promise(async (connectResolve, connectReject) => {
if (this._bleDevice.connecting) {
return connectReject("Already connecting");
}
else if (this._bleDevice.connected) {
return connectReject("Already connected");
}
await this._bleDevice.connect();
return connectResolve();
});
}
/**
* Disconnect the Hub.
* @method Hub#disconnect
* @returns {Promise} Resolved upon successful disconnect.
*/
disconnect() {
return this._bleDevice.disconnect();
}
getDeviceAtPort(portName) {
const portId = this._portMap[portName];
if (portId !== undefined) {
return this._attachedDevices[portId];
}
else {
return undefined;
}
}
waitForDeviceAtPort(portName) {
return new Promise((resolve) => {
const existingDevice = this.getDeviceAtPort(portName);
if (existingDevice) {
return resolve(existingDevice);
}
this._attachCallbacks.push((device) => {
if (device.portName === portName) {
resolve(device);
return true;
}
else {
return false;
}
});
});
}
getDevices() {
return Object.values(this._attachedDevices);
}
getDevicesByType(deviceType) {
return this.getDevices().filter((device) => device.type === deviceType);
}
waitForDeviceByType(deviceType) {
return new Promise((resolve) => {
const existingDevices = this.getDevicesByType(deviceType);
if (existingDevices.length >= 1) {
return resolve(existingDevices[0]);
}
this._attachCallbacks.push((device) => {
if (device.type === deviceType) {
resolve(device);
return true;
}
else {
return false;
}
});
});
}
getPortNameForPortId(portId) {
for (const port of Object.keys(this._portMap)) {
if (this._portMap[port] === portId) {
return port;
}
}
return;
}
isPortVirtual(portId) {
return (this._virtualPorts.indexOf(portId) > -1);
}
/**
* Sleep a given amount of time.
*
* This is a helper method to make it easier to add delays into a chain of commands.
* @method Hub#sleep
* @param {number} delay How long to sleep (in milliseconds).
* @returns {Promise} Resolved after the delay is finished.
*/
sleep(delay) {
return new Promise((resolve) => {
global.setTimeout(resolve, delay);
});
}
/**
* Wait until a given list of concurrently running commands are complete.
*
* This is a helper method to make it easier to wait for concurrent commands to complete.
* @method Hub#wait
* @param {Array&lt;Promise&lt;any>>} commands Array of executing commands.
* @returns {Promise} Resolved after the commands are finished.
*/
wait(commands) {
return Promise.all(commands);
}
send(message, uuid, callback) {
if (callback) {
callback();
}
}
subscribe(portId, deviceType, mode) {
// NK Do nothing here
}
unsubscribe(portId, deviceType, mode) {
// NK Do nothing here
}
_attachDevice(device) {
this._attachedDevices[device.portId] = device;
/**
* Emits when a device is attached to the Hub.
* @event Hub#attach
* @param {Device} device
*/
this.emit("attach", device);
debug(`Attached device type ${device.type} (${Consts.DeviceTypeNames[device.type]}) on port ${device.portName} (${device.portId})`);
let i = this._attachCallbacks.length;
while (i--) {
const callback = this._attachCallbacks[i];
if (callback(device)) {
this._attachCallbacks.splice(i, 1);
}
}
}
_detachDevice(device) {
delete this._attachedDevices[device.portId];
/**
* Emits when a device is detached from the Hub.
* @event Hub#attach
* @param {Device} device
*/
this.emit("detach", device);
debug(`Detached device type ${device.type} (${Consts.DeviceTypeNames[device.type]}) on port ${device.portName} (${device.portId})`);
}
_createDevice(deviceType, portId) {
let constructor;
// NK TODO: This needs to go in a better place
const deviceConstructors = {
[Consts.DeviceType.LIGHT]: light_1.Light,
[Consts.DeviceType.TRAIN_MOTOR]: trainmotor_1.TrainMotor,
[Consts.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR]: simplemediumlinearmotor_1.SimpleMediumLinearMotor,
[Consts.DeviceType.MOVE_HUB_MEDIUM_LINEAR_MOTOR]: movehubmediumlinearmotor_1.MoveHubMediumLinearMotor,
[Consts.DeviceType.MOTION_SENSOR]: motionsensor_1.MotionSensor,
[Consts.DeviceType.TILT_SENSOR]: tiltsensor_1.TiltSensor,
[Consts.DeviceType.MOVE_HUB_TILT_SENSOR]: movehubtiltsensor_1.MoveHubTiltSensor,
[Consts.DeviceType.PIEZO_BUZZER]: piezobuzzer_1.PiezoBuzzer,
[Consts.DeviceType.TECHNIC_COLOR_SENSOR]: techniccolorsensor_1.TechnicColorSensor,
[Consts.DeviceType.TECHNIC_DISTANCE_SENSOR]: technicdistancesensor_1.TechnicDistanceSensor,
[Consts.DeviceType.TECHNIC_FORCE_SENSOR]: technicforcesensor_1.TechnicForceSensor,
[Consts.DeviceType.TECHNIC_MEDIUM_HUB_TILT_SENSOR]: technicmediumhubtiltsensor_1.TechnicMediumHubTiltSensor,
[Consts.DeviceType.TECHNIC_MEDIUM_HUB_GYRO_SENSOR]: technicmediumhubgyrosensor_1.TechnicMediumHubGyroSensor,
[Consts.DeviceType.TECHNIC_MEDIUM_HUB_ACCELEROMETER]: technicmediumhubaccelerometersensor_1.TechnicMediumHubAccelerometerSensor,
[Consts.DeviceType.MEDIUM_LINEAR_MOTOR]: mediumlinearmotor_1.MediumLinearMotor,
[Consts.DeviceType.TECHNIC_MEDIUM_ANGULAR_MOTOR]: technicmediumangularmotor_1.TechnicMediumAngularMotor,
[Consts.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR]: techniclargeangularmotor_1.TechnicLargeAngularMotor,
[Consts.DeviceType.TECHNIC_LARGE_LINEAR_MOTOR]: techniclargelinearmotor_1.TechnicLargeLinearMotor,
[Consts.DeviceType.TECHNIC_XLARGE_LINEAR_MOTOR]: technicxlargelinearmotor_1.TechnicXLargeLinearMotor,
[Consts.DeviceType.COLOR_DISTANCE_SENSOR]: colordistancesensor_1.ColorDistanceSensor,
[Consts.DeviceType.VOLTAGE_SENSOR]: voltagesensor_1.VoltageSensor,
[Consts.DeviceType.CURRENT_SENSOR]: currentsensor_1.CurrentSensor,
[Consts.DeviceType.REMOTE_CONTROL_BUTTON]: remotecontrolbutton_1.RemoteControlButton,
[Consts.DeviceType.HUB_LED]: hubled_1.HubLED,
[Consts.DeviceType.DUPLO_TRAIN_BASE_COLOR_SENSOR]: duplotrainbasecolorsensor_1.DuploTrainBaseColorSensor,
[Consts.DeviceType.DUPLO_TRAIN_BASE_MOTOR]: duplotrainbasemotor_1.DuploTrainBaseMotor,
[Consts.DeviceType.DUPLO_TRAIN_BASE_SPEAKER]: duplotrainbasespeaker_1.DuploTrainBaseSpeaker,
[Consts.DeviceType.DUPLO_TRAIN_BASE_SPEEDOMETER]: duplotrainbasespeedometer_1.DuploTrainBaseSpeedometer
};
constructor = deviceConstructors[deviceType];
if (constructor) {
return new constructor(this, portId);
}
else {
return new device_1.Device(this, portId, undefined, deviceType);
}
}
_getDeviceByPortId(portId) {
return this._attachedDevices[portId];
}
}
exports.BaseHub = BaseHub;
//# sourceMappingURL=basehub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,263 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/duplotrainbase.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/duplotrainbase.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 lpf2hub_1 = require("./lpf2hub");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("duplotrainbase");
/**
* The DuploTrainBase is emitted if the discovered device is a Duplo Train Base.
* @class DuploTrainBase
* @extends LPF2Hub
* @extends BaseHub
*/
class DuploTrainBase extends lpf2hub_1.LPF2Hub {
static IsDuploTrainBase(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp;
peripheral.advertisement.manufacturerData &amp;&amp;
peripheral.advertisement.manufacturerData.length > 3 &amp;&amp;
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_BASE_ID);
}
constructor(device) {
super(device, exports.PortMap, Consts.HubType.DUPLO_TRAIN_BASE);
debug("Discovered Duplo Train Base");
}
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Duplo Train Base");
await super.connect();
debug("Connect completed");
return resolve();
});
}
}
exports.DuploTrainBase = DuploTrainBase;
exports.PortMap = {
"MOTOR": 0,
"COLOR": 18,
"SPEEDOMETER": 19
};
//# sourceMappingURL=duplotrainbase.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

275
docs/hubs_hub.js.html Normal file
View File

@ -0,0 +1,275 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/hub.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/hub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 compare_versions_1 = __importDefault(require("compare-versions"));
const lpf2hub_1 = require("./lpf2hub");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("hub");
/**
* The Hub is emitted if the discovered device is a Hub.
* @class Hub
* @extends LPF2Hub
* @extends BaseHub
*/
class Hub extends lpf2hub_1.LPF2Hub {
constructor(device) {
super(device, exports.PortMap, Consts.HubType.HUB);
this._currentPort = 0x3b;
debug("Discovered Powered UP Hub");
}
static IsHub(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp;
peripheral.advertisement.manufacturerData &amp;&amp;
peripheral.advertisement.manufacturerData.length > 3 &amp;&amp;
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.HUB_ID);
}
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Powered UP Hub");
await super.connect();
debug("Connect completed");
return resolve();
});
}
_checkFirmware(version) {
if (compare_versions_1.default("1.1.00.0004", version) === 1) {
throw new Error(`Your Powered Up Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
}
}
}
exports.Hub = Hub;
exports.PortMap = {
"A": 0,
"B": 1,
"HUB_LED": 50,
"CURRENT_SENSOR": 59,
"VOLTAGE_SENSOR": 60
};
//# sourceMappingURL=hub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

552
docs/hubs_lpf2hub.js.html Normal file
View File

@ -0,0 +1,552 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/lpf2hub.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/lpf2hub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 basehub_1 = require("./basehub");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
const Debug = require("debug");
const debug = Debug("lpf2hub");
const modeInfoDebug = Debug("lpf2hubmodeinfo");
/**
* @class LPF2Hub
* @extends BaseHub
*/
class LPF2Hub extends basehub_1.BaseHub {
constructor() {
super(...arguments);
this._messageBuffer = Buffer.alloc(0);
this._propertyRequestCallbacks = {};
}
connect() {
return new Promise(async (resolve, reject) => {
debug("LPF2Hub connecting");
await super.connect();
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.LPF2_HUB);
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.LPF2_ALL, this._parseMessage.bind(this));
await this.sleep(500);
this._requestHubPropertyReports(0x02); // Activate button reports
await this._requestHubPropertyValue(0x03); // Request firmware version
await this._requestHubPropertyValue(0x04); // Request hardware version
this._requestHubPropertyReports(0x05); // Activate RSSI updates
this._requestHubPropertyReports(0x06); // Activate battery level reports
await this._requestHubPropertyValue(0x0d); // Request primary MAC address
this.emit("connect");
debug("LPF2Hub connected");
resolve();
});
}
/**
* Shutdown the Hub.
* @method LPF2Hub#shutdown
* @returns {Promise} Resolved upon successful disconnect.
*/
shutdown() {
return new Promise((resolve, reject) => {
this.send(Buffer.from([0x02, 0x01]), Consts.BLECharacteristic.LPF2_ALL, () => {
return resolve();
});
});
}
/**
* Set the name of the Hub.
* @method LPF2Hub#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) => {
let data = Buffer.from([0x01, 0x01, 0x01]);
data = Buffer.concat([data, Buffer.from(name, "ascii")]);
// Send this twice, as sometimes the first time doesn't take
this.send(data, Consts.BLECharacteristic.LPF2_ALL);
this.send(data, Consts.BLECharacteristic.LPF2_ALL);
this._name = name;
return resolve();
});
}
send(message, uuid, callback) {
message = Buffer.concat([Buffer.alloc(2), message]);
message[0] = message.length;
debug("Sent Message (LPF2_ALL)", message);
this._bleDevice.writeToCharacteristic(uuid, message, callback);
}
subscribe(portId, deviceType, mode) {
this.send(Buffer.from([0x41, portId, mode, 0x01, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL);
}
unsubscribe(portId, mode) {
this.send(Buffer.from([0x41, portId, mode, 0x01, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.LPF2_ALL);
}
createVirtualPort(firstPortName, secondPortName) {
const firstDevice = this.getDeviceAtPort(firstPortName);
if (!firstDevice) {
throw new Error(`Port ${firstPortName} does not have an attached device`);
}
const secondDevice = this.getDeviceAtPort(secondPortName);
if (!secondDevice) {
throw new Error(`Port ${secondPortName} does not have an attached device`);
}
if (firstDevice.type !== secondDevice.type) {
throw new Error(`Both devices must be of the same type to create a virtual port`);
}
this.send(Buffer.from([0x61, 0x01, firstDevice.portId, secondDevice.portId]), Consts.BLECharacteristic.LPF2_ALL);
}
_checkFirmware(version) {
return;
}
_parseMessage(data) {
if (data) {
this._messageBuffer = Buffer.concat([this._messageBuffer, data]);
}
if (this._messageBuffer.length &lt;= 0) {
return;
}
const len = this._messageBuffer[0];
if (len >= this._messageBuffer.length) {
const message = this._messageBuffer.slice(0, len);
this._messageBuffer = this._messageBuffer.slice(len);
debug("Received Message (LPF2_ALL)", message);
switch (message[2]) {
case 0x01: {
const property = message[3];
const callback = this._propertyRequestCallbacks[property];
if (callback) {
callback(message);
}
else {
this._parseHubPropertyResponse(message);
}
delete this._propertyRequestCallbacks[property];
break;
}
case 0x04: {
this._parsePortMessage(message);
break;
}
case 0x43: {
this._parsePortInformationResponse(message);
break;
}
case 0x44: {
this._parseModeInformationResponse(message);
break;
}
case 0x45: {
this._parseSensorMessage(message);
break;
}
case 0x82: {
this._parsePortAction(message);
break;
}
}
if (this._messageBuffer.length > 0) {
this._parseMessage();
}
}
}
_requestHubPropertyValue(property) {
return new Promise((resolve) => {
this._propertyRequestCallbacks[property] = (message) => {
this._parseHubPropertyResponse(message);
return resolve();
};
this.send(Buffer.from([0x01, property, 0x05]), Consts.BLECharacteristic.LPF2_ALL);
});
}
_requestHubPropertyReports(property) {
this.send(Buffer.from([0x01, property, 0x02]), Consts.BLECharacteristic.LPF2_ALL);
}
_parseHubPropertyResponse(message) {
// Button press reports
if (message[3] === 0x02) {
if (message[5] === 1) {
/**
* Emits when a button is pressed.
* @event LPF2Hub#button
* @param {string} button
* @param {ButtonState} state
*/
this.emit("button", { event: Consts.ButtonState.PRESSED });
return;
}
else if (message[5] === 0) {
this.emit("button", { event: Consts.ButtonState.RELEASED });
return;
}
// Firmware version
}
else if (message[3] === 0x03) {
this._firmwareVersion = utils_1.decodeVersion(message.readInt32LE(5));
this._checkFirmware(this._firmwareVersion);
// Hardware version
}
else if (message[3] === 0x04) {
this._hardwareVersion = utils_1.decodeVersion(message.readInt32LE(5));
// RSSI update
}
else if (message[3] === 0x05) {
const rssi = message.readInt8(5);
if (rssi !== 0) {
this._rssi = rssi;
this.emit("rssi", { rssi: this._rssi });
}
// primary MAC Address
}
else if (message[3] === 0x0d) {
this._primaryMACAddress = utils_1.decodeMACAddress(message.slice(5));
// Battery level reports
}
else if (message[3] === 0x06) {
const batteryLevel = message[5];
if (batteryLevel !== this._batteryLevel) {
this._batteryLevel = batteryLevel;
this.emit("batteryLevel", { batteryLevel });
}
}
}
_parsePortMessage(message) {
const portId = message[3];
const event = message[4];
const deviceType = event ? message.readUInt16LE(5) : 0;
// Handle device attachments
if (event === 0x01) {
if (modeInfoDebug.enabled) {
const deviceTypeName = Consts.DeviceTypeNames[message[5]] || "Unknown";
modeInfoDebug(`Port ${utils_1.toHex(portId)}, type ${utils_1.toHex(deviceType, 4)} (${deviceTypeName})`);
const hwVersion = utils_1.decodeVersion(message.readInt32LE(7));
const swVersion = utils_1.decodeVersion(message.readInt32LE(11));
modeInfoDebug(`Port ${utils_1.toHex(portId)}, hardware version ${hwVersion}, software version ${swVersion}`);
this._sendPortInformationRequest(portId);
}
const device = this._createDevice(deviceType, portId);
this._attachDevice(device);
// Handle device detachments
}
else if (event === 0x00) {
const device = this._getDeviceByPortId(portId);
if (device) {
this._detachDevice(device);
if (this.isPortVirtual(portId)) {
const portName = this.getPortNameForPortId(portId);
if (portName) {
delete this._portMap[portName];
}
this._virtualPorts = this._virtualPorts.filter((virtualPortId) => virtualPortId !== portId);
}
}
// Handle virtual port creation
}
else if (event === 0x02) {
const firstPortName = this.getPortNameForPortId(message[7]);
const secondPortName = this.getPortNameForPortId(message[8]);
// @ts-ignore NK These should never be undefined
const virtualPortName = firstPortName + secondPortName;
const virtualPortId = message[3];
this._portMap[virtualPortName] = virtualPortId;
this._virtualPorts.push(virtualPortId);
const device = this._createDevice(deviceType, virtualPortId);
this._attachDevice(device);
}
}
_sendPortInformationRequest(port) {
this.send(Buffer.from([0x21, port, 0x01]), Consts.BLECharacteristic.LPF2_ALL);
this.send(Buffer.from([0x21, port, 0x02]), Consts.BLECharacteristic.LPF2_ALL); // Mode combinations
}
_parsePortInformationResponse(message) {
const port = message[3];
if (message[4] === 2) {
const modeCombinationMasks = [];
for (let i = 5; i &lt; message.length; i += 2) {
modeCombinationMasks.push(message.readUInt16LE(i));
}
modeInfoDebug(`Port ${utils_1.toHex(port)}, mode combinations [${modeCombinationMasks.map((c) => utils_1.toBin(c, 0)).join(", ")}]`);
return;
}
const count = message[6];
const input = utils_1.toBin(message.readUInt16LE(7), count);
const output = utils_1.toBin(message.readUInt16LE(9), count);
modeInfoDebug(`Port ${utils_1.toHex(port)}, total modes ${count}, input modes ${input}, output modes ${output}`);
for (let i = 0; i &lt; count; i++) {
this._sendModeInformationRequest(port, i, 0x00); // Mode Name
this._sendModeInformationRequest(port, i, 0x01); // RAW Range
this._sendModeInformationRequest(port, i, 0x02); // PCT Range
this._sendModeInformationRequest(port, i, 0x03); // SI Range
this._sendModeInformationRequest(port, i, 0x04); // SI Symbol
this._sendModeInformationRequest(port, i, 0x80); // Value Format
}
}
_sendModeInformationRequest(port, mode, type) {
this.send(Buffer.from([0x22, port, mode, type]), Consts.BLECharacteristic.LPF2_ALL);
}
_parseModeInformationResponse(message) {
const port = utils_1.toHex(message[3]);
const mode = message[4];
const type = message[5];
switch (type) {
case 0x00: // Mode Name
modeInfoDebug(`Port ${port}, mode ${mode}, name ${message.slice(6, message.length).toString()}`);
break;
case 0x01: // RAW Range
modeInfoDebug(`Port ${port}, mode ${mode}, RAW min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
break;
case 0x02: // PCT Range
modeInfoDebug(`Port ${port}, mode ${mode}, PCT min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
break;
case 0x03: // SI Range
modeInfoDebug(`Port ${port}, mode ${mode}, SI min ${message.readFloatLE(6)}, max ${message.readFloatLE(10)}`);
break;
case 0x04: // SI Symbol
modeInfoDebug(`Port ${port}, mode ${mode}, SI symbol ${message.slice(6, message.length).toString()}`);
break;
case 0x80: // Value Format
const numValues = message[6];
const dataType = ["8bit", "16bit", "32bit", "float"][message[7]];
const totalFigures = message[8];
const decimals = message[9];
modeInfoDebug(`Port ${port}, mode ${mode}, Value ${numValues} x ${dataType}, Decimal format ${totalFigures}.${decimals}`);
}
}
_parsePortAction(message) {
const portId = message[3];
const device = this._getDeviceByPortId(portId);
if (device) {
const finished = (message[4] === 0x0a);
if (finished) {
device.finish();
}
}
}
_parseSensorMessage(message) {
const portId = message[3];
const device = this._getDeviceByPortId(portId);
if (device) {
device.receive(message);
}
}
}
exports.LPF2Hub = LPF2Hub;
//# sourceMappingURL=lpf2hub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

277
docs/hubs_movehub.js.html Normal file
View File

@ -0,0 +1,277 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/movehub.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/movehub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 compare_versions_1 = __importDefault(require("compare-versions"));
const lpf2hub_1 = require("./lpf2hub");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("movehub");
/**
* The MoveHub is emitted if the discovered device is a Move Hub.
* @class MoveHub
* @extends LPF2Hub
* @extends BaseHub
*/
class MoveHub extends lpf2hub_1.LPF2Hub {
static IsMoveHub(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp;
peripheral.advertisement.manufacturerData &amp;&amp;
peripheral.advertisement.manufacturerData.length > 3 &amp;&amp;
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.MOVE_HUB_ID);
}
constructor(device) {
super(device, exports.PortMap, Consts.HubType.MOVE_HUB);
debug("Discovered Move Hub");
}
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Move Hub");
await super.connect();
debug("Connect completed");
return resolve();
});
}
_checkFirmware(version) {
if (compare_versions_1.default("2.0.00.0017", version) === 1) {
throw new Error(`Your Move Hub's (${this.name}) firmware is out of date and unsupported by this library. Please update it via the official Powered Up app.`);
}
}
}
exports.MoveHub = MoveHub;
exports.PortMap = {
"A": 0,
"B": 1,
"C": 2,
"D": 3,
"HUB_LED": 50,
"TILT_SENSOR": 58,
"CURRENT_SENSOR": 59,
"VOLTAGE_SENSOR": 60
};
//# sourceMappingURL=movehub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,265 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/remotecontrol.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/remotecontrol.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 lpf2hub_1 = require("./lpf2hub");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("remotecontrol");
/**
* The RemoteControl is emitted if the discovered device is a Remote Control.
* @class RemoteControl
* @extends LPF2Hub
* @extends BaseHub
*/
class RemoteControl extends lpf2hub_1.LPF2Hub {
static IsRemoteControl(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp;
peripheral.advertisement.manufacturerData &amp;&amp;
peripheral.advertisement.manufacturerData.length > 3 &amp;&amp;
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.REMOTE_CONTROL_ID);
}
constructor(device) {
super(device, exports.PortMap, Consts.HubType.REMOTE_CONTROL);
debug("Discovered Powered UP Remote");
}
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Powered UP Remote");
await super.connect();
debug("Connect completed");
return resolve();
});
}
}
exports.RemoteControl = RemoteControl;
exports.PortMap = {
"LEFT": 0,
"RIGHT": 1,
"HUB_LED": 52,
"VOLTAGE_SENSOR": 59,
"REMOTE_CONTROL_RSSI": 60
};
//# sourceMappingURL=remotecontrol.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,271 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/technicmediumhub.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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/technicmediumhub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 lpf2hub_1 = require("./lpf2hub");
const Consts = __importStar(require("../consts"));
const Debug = require("debug");
const debug = Debug("technicmediumhub");
/**
* The TechnicMediumHub is emitted if the discovered device is a Technic Medium Hub.
* @class TechnicMediumHub
* @extends LPF2Hub
* @extends BaseHub
*/
class TechnicMediumHub extends lpf2hub_1.LPF2Hub {
static IsTechnicMediumHub(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp;
peripheral.advertisement.manufacturerData &amp;&amp;
peripheral.advertisement.manufacturerData.length > 3 &amp;&amp;
peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.TECHNIC_MEDIUM_HUB);
}
constructor(device) {
super(device, exports.PortMap, Consts.HubType.TECHNIC_MEDIUM_HUB);
debug("Discovered Control+ Hub");
}
connect() {
return new Promise(async (resolve, reject) => {
debug("Connecting to Control+ Hub");
await super.connect();
this.send(Buffer.from([0x41, 0x3d, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.LPF2_ALL); // Temperature
debug("Connect completed");
return resolve();
});
}
}
exports.TechnicMediumHub = TechnicMediumHub;
exports.PortMap = {
"A": 0,
"B": 1,
"C": 2,
"D": 3,
"HUB_LED": 50,
"CURRENT_SENSOR": 59,
"VOLTAGE_SENSOR": 60,
"ACCELEROMETER": 97,
"GYRO_SENSOR": 98,
"TILT_SENSOR": 99
};
//# sourceMappingURL=technicmediumhub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

View File

@ -0,0 +1,417 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>node-poweredup Source: hubs/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">node-poweredup</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="BaseHub.html">BaseHub</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="MoveHub.html">MoveHub</a></li><li><a href="RemoteControl.html">RemoteControl</a></li><li><a href="TechnicMediumHub.html">TechnicMediumHub</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="AbsoluteMotor.html#event:absolute">AbsoluteMotor#event:absolute</a></li><li><a href="ColorDistanceSensor.html#event:color">ColorDistanceSensor#event:color</a></li><li><a href="ColorDistanceSensor.html#event:colorAndDistance">ColorDistanceSensor#event:colorAndDistance</a></li><li><a href="ColorDistanceSensor.html#event:distance">ColorDistanceSensor#event:distance</a></li><li><a href="CurrentSensor.html#event:current">CurrentSensor#event:current</a></li><li><a href="DuploTrainBase.html#event:accel">DuploTrainBase#event:accel</a></li><li><a href="DuploTrainBase.html#event:button">DuploTrainBase#event:button</a></li><li><a href="DuploTrainBase.html#event:tilt">DuploTrainBase#event:tilt</a></li><li><a href="DuploTrainBaseColorSensor.html#event:color">DuploTrainBaseColorSensor#event:color</a></li><li><a href="DuploTrainBaseSpeedometer.html#event:speed">DuploTrainBaseSpeedometer#event:speed</a></li><li><a href="Hub.html#event:accel">Hub#event:accel</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:button">Hub#event:button</a></li><li><a href="Hub.html#event:disconnect">Hub#event:disconnect</a></li><li><a href="Hub.html#event:tilt">Hub#event:tilt</a></li><li><a href="LPF2Hub.html#event:accel">LPF2Hub#event:accel</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="MotionSensor.html#event:distance">MotionSensor#event:distance</a></li><li><a href="MoveHub.html#event:accel">MoveHub#event:accel</a></li><li><a href="MoveHub.html#event:button">MoveHub#event:button</a></li><li><a href="MoveHub.html#event:tilt">MoveHub#event:tilt</a></li><li><a href="MoveHubTiltSensor.html#event:tilt">MoveHubTiltSensor#event:tilt</a></li><li><a href="RemoteControl.html#event:accel">RemoteControl#event:accel</a></li><li><a href="RemoteControl.html#event:button">RemoteControl#event:button</a></li><li><a href="RemoteControl.html#event:tilt">RemoteControl#event:tilt</a></li><li><a href="RemoteControlButton.html#event:button">RemoteControlButton#event:button</a></li><li><a href="TachoMotor.html#event:rotate">TachoMotor#event:rotate</a></li><li><a href="TechnicColorSensor_ambient%2520Percentage.html#event:from0to100.">TechnicColorSensor#ambient Percentage,event: from 0 to 100.</a></li><li><a href="TechnicColorSensor.html#event:color">TechnicColorSensor#event:color</a></li><li><a href="TechnicColorSensor_reflect%2520Percentage.html#event:from0to100.">TechnicColorSensor#reflect Percentage,event: from 0 to 100.</a></li><li><a href="TechnicDistanceSensor_distance%2520Distance.html#event:from40to2500mm">TechnicDistanceSensor#distance Distance,event: from 40 to 2500mm</a></li><li><a href="TechnicDistanceSensor_fastDistance%2520Distance.html#event:from50to320mm">TechnicDistanceSensor#fastDistance Distance,event: from 50 to 320mm</a></li><li><a href="TechnicForceSensor.html#event:touchTouchedon/off(boolean).">TechnicForceSensor#event:touch Touched on/off (boolean).</a></li><li><a href="TechnicForceSensor_force%2520Force.html#event:innewtons(0-10).">TechnicForceSensor#force Force,event: in newtons (0-10).</a></li><li><a href="TechnicForceSensor_tapped%2520How%2520hard%2520the%2520sensor%2520was%2520tapped.html#event:from0-3.">TechnicForceSensor#tapped How hard the sensor was tapped,event: from 0-3.</a></li><li><a href="TechnicMediumHub.html#event:accel">TechnicMediumHub#event:accel</a></li><li><a href="TechnicMediumHub.html#event:button">TechnicMediumHub#event:button</a></li><li><a href="TechnicMediumHub.html#event:tilt">TechnicMediumHub#event:tilt</a></li><li><a href="TechnicMediumHubGyroSensor.html#event:gyro">TechnicMediumHubGyroSensor#event:gyro</a></li><li><a href="TechnicMediumHubTiltSensor.html#event:tilt">TechnicMediumHubTiltSensor#event:tilt</a></li><li><a href="VoltageSensor.html#event:voltage">VoltageSensor#event:voltage</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</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: hubs/wedo2smarthub.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; 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 basehub_1 = require("./basehub");
const Consts = __importStar(require("../consts"));
const utils_1 = require("../utils");
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 BaseHub
*/
class WeDo2SmartHub extends basehub_1.BaseHub {
constructor(device) {
super(device, exports.PortMap, Consts.HubType.WEDO2_SMART_HUB);
this._lastTiltX = 0;
this._lastTiltY = 0;
debug("Discovered WeDo 2.0 Smart Hub");
}
static IsWeDo2SmartHub(peripheral) {
return (peripheral.advertisement &amp;&amp;
peripheral.advertisement.serviceUuids &amp;&amp;
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();
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2);
if (!utils_1.isWebBluetooth) {
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5);
}
else {
await this._bleDevice.discoverCharacteristicsForService("battery_service");
await this._bleDevice.discoverCharacteristicsForService("device_information");
}
debug("Connect completed");
this.emit("connect");
resolve();
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this));
if (!utils_1.isWebBluetooth) {
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this));
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => {
if (data) {
this._parseBatteryMessage(data);
}
});
}
else {
this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseBatteryMessage(data);
}
});
this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", this._parseHighCurrentAlert.bind(this));
}
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
if (!utils_1.isWebBluetooth) {
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => {
if (data) {
this._parseFirmwareRevisionString(data);
}
});
}
else {
this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseFirmwareRevisionString(data);
}
});
}
});
}
/**
* Shutdown the Hub.
* @method WeDo2SmartHub#shutdown
* @returns {Promise} Resolved upon successful disconnect.
*/
shutdown() {
return new Promise((resolve, reject) => {
this.send(Buffer.from([0x00]), Consts.BLECharacteristic.WEDO2_DISCONNECT, () => {
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.send(data, Consts.BLECharacteristic.WEDO2_NAME_ID);
this.send(data, Consts.BLECharacteristic.WEDO2_NAME_ID);
this._name = name;
return resolve();
});
}
send(message, uuid, callback) {
if (debug.enabled) {
debug(`Sent Message (${this._getCharacteristicNameFromUUID(uuid)})`, message);
}
this._bleDevice.writeToCharacteristic(uuid, message, callback);
}
subscribe(portId, deviceType, mode) {
this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
}
unsubscribe(portId, deviceType, mode) {
this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
}
_getCharacteristicNameFromUUID(uuid) {
const keys = Object.keys(Consts.BLECharacteristic);
for (let i = 0; i &lt; 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);
}
_parseBatteryMessage(data) {
debug("Received Message (WEDO2_BATTERY)", data);
const batteryLevel = data[0];
if (batteryLevel !== this._batteryLevel) {
this._batteryLevel = batteryLevel;
this.emit("batteryLevel", { batteryLevel });
}
}
_parseFirmwareRevisionString(data) {
debug("Received Message (WEDO2_FIRMWARE_REVISION)", data);
this._firmwareVersion = data.toString();
}
_parsePortMessage(data) {
debug("Received Message (WEDO2_PORT_TYPE)", data);
const portId = data[0];
const event = data[1];
const deviceType = event ? data[3] : 0;
if (event === 0x01) {
const device = this._createDevice(deviceType, portId);
this._attachDevice(device);
}
else if (event === 0x00) {
const device = this._getDeviceByPortId(portId);
if (device) {
this._detachDevice(device);
}
}
}
_parseSensorMessage(message) {
debug("Received Message (WEDO2_SENSOR_VALUE)", message);
if (message[0] === 0x01) {
/**
* Emits when a button is pressed.
* @event WeDo2SmartHub#button
* @param {string} button
* @param {ButtonState} state
*/
this.emit("button", { event: Consts.ButtonState.PRESSED });
return;
}
else if (message[0] === 0x00) {
this.emit("button", { event: Consts.ButtonState.RELEASED });
return;
}
const portId = message[1];
const device = this._getDeviceByPortId(portId);
if (device) {
device.receive(message);
}
}
}
exports.WeDo2SmartHub = WeDo2SmartHub;
exports.PortMap = {
"A": 1,
"B": 2,
"CURRENT_SENSOR": 3,
"VOLTAGE_SENSOR": 4,
"PIEZO_BUZZER": 5,
"HUB_LED": 6
};
//# sourceMappingURL=wedo2smarthub.js.map</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">&times;</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.6.3</a>
on Fri Feb 7th 2020
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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,55 +16,65 @@ let remote = null;
poweredUP.on("discover", async (hub) => { // Wait to discover Vernie and Remote
if (hub instanceof PoweredUP.BoostMoveHub) {
if (hub.type === PoweredUP.Consts.HubType.MOVE_HUB) {
vernie = hub;
await vernie.connect();
vernie.setLEDColor(PoweredUP.Consts.Color.BLUE);
const led = await vernie.waitForDeviceByType(PoweredUP.Consts.DeviceType.HUB_LED);
led.setColor(PoweredUP.Consts.Color.BLUE);
console.log(`Connected to Vernie (${vernie.name})!`);
} else if (hub instanceof PoweredUP.PUPRemote) {
} else if (hub.type === PoweredUP.Consts.HubType.REMOTE_CONTROL) {
remote = hub;
remote.on("button", async (button, state) => {
remote.on("remoteButton", async (device, { event }) => {
if (vernie) {
switch (state) {
const leftTrack = await vernie.waitForDeviceAtPort("A");
const rightTrack = await vernie.waitForDeviceAtPort("B");
const head = await vernie.waitForDeviceAtPort("D");
console.log(event);
switch (event) {
case PoweredUP.Consts.ButtonState.UP: // If up is pressed, move the track forward
{
vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 50);
console.log(device.portName);
device.portName === "LEFT" ? leftTrack.setSpeed(50) : rightTrack.setSpeed(50);
break;
}
case PoweredUP.Consts.ButtonState.DOWN: // If down is pressed, move the track backwards
{
vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", -50);
device.portName === "LEFT" ? leftTrack.setSpeed(-50) : rightTrack.setSpeed(-50);
break;
}
case PoweredUP.Consts.ButtonState.RELEASED: // Stop the track when the button is released
{
if (button !== "GREEN") {
vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 0);
}
device.portName === "LEFT" ? leftTrack.setPower(0) : rightTrack.setPower(0);
break;
}
case PoweredUP.Consts.ButtonState.STOP: // Move the head left or right when a red button is pressed
{
await vernie.setMotorAngle("D", 35, button === "LEFT" ? -20 : 20);
break;
}
case PoweredUP.Consts.ButtonState.PRESSED: // Fire when the green button is pressed
{
if (button === "GREEN") {
await vernie.setMotorAngle("D", 80, 20);
await vernie.setMotorAngle("D", 80, -20);
}
await head.rotateByDegrees(35, device.portName === "LEFT" ? -20 : 20);
break;
}
}
}
})
});
hub.on("button", async ({ event }) => {
console.log(event);
if (vernie) {
const head = await vernie.waitForDeviceAtPort("D");
if (event === PoweredUP.Consts.ButtonState.PRESSED) {
await head.rotateByDegrees(80, 20);
await head.rotateByDegrees(80, -20);
}
}
});
await remote.connect();
remote.setLEDColor(PoweredUP.Consts.Color.BLUE);
const led = await remote.waitForDeviceByType(PoweredUP.Consts.DeviceType.HUB_LED);
led.setColor(PoweredUP.Consts.Color.BLUE);
console.log(`Connected to Powered UP Remote (${remote.name})!`);
}

View File

@ -9,7 +9,7 @@
"build:node": "tslint -c tslint.json \"./src/**/*.ts\" && tsc",
"build:browser": "tslint -c tslint.json \"./src/**/*.ts\" && webpack --mode=production",
"build:all": "tslint -c tslint.json \"./src/**/*.ts\" && tsc && webpack --mode=production",
"docs": "jsdoc -d docs -c jsdoc.conf.json -t ./node_modules/ink-docstrap/template -R README.md dist/node/consts.js dist/node/poweredup-node.js dist/node/lpf2hub.js dist/node/wedo2smarthub.js dist/node/boostmovehub.js dist/node/puphub.js dist/node/pupremote.js dist/node/duplotrainbase.js dist/node/controlplushub.js dist/node/hub.js dist/node/consts.js",
"docs": "jsdoc -d docs -c jsdoc.conf.json -t ./node_modules/ink-docstrap/template -R README.md dist/node/**/*.js",
"all": "npm run build:all && npm run docs",
"prepublishOnly": "npm run build:node"
},
@ -22,14 +22,14 @@
},
"devDependencies": {
"@types/debug": "4.1.5",
"@types/node": "^13.1.5",
"@types/node": "^13.7.0",
"@types/web-bluetooth": "0.0.5",
"ink-docstrap": "^1.3.2",
"jsdoc": "^3.6.3",
"jsdoc-to-markdown": "^5.0.3",
"ts-loader": "^6.2.1",
"tslint": "^5.20.1",
"typescript": "^3.7.4",
"tslint": "^6.0.0",
"typescript": "^3.7.5",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
}

View File

@ -142,6 +142,17 @@ export enum ButtonState {
}
/**
* @typedef BrakingStyle
* @property {number} HOLD 127
* @property {number} BRAKE 128
*/
export enum BrakingStyle {
HOLD = 127,
BRAKE = 128
}
/**
* @typedef DuploTrainBaseSound
* @property {number} BRAKE 3

View File

@ -52,11 +52,11 @@ export class AbsoluteMotor extends TachoMotor {
}
let message;
if (angle instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
message.writeInt32LE(normalizeAngle(angle[0]), 4);
message.writeInt32LE(normalizeAngle(angle[1]), 8);
} else {
message = Buffer.from([0x81, this.portId, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
message.writeInt32LE(normalizeAngle(angle), 4);
}
this.send(message);
@ -66,116 +66,6 @@ export class AbsoluteMotor extends TachoMotor {
});
}
/**
* (Re)set the knowledge of the absolute position to the current angle.
* @method AbsoluteMotor#resetAngle
* @param {number} angle Position to set (degrees from 0).
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
*/
public resetAngle (angle: [number, number] | number) {
if (!this.isVirtualPort && angle instanceof Array) {
throw new Error("Only virtual ports can accept multiple positions");
}
if (this.isWeDo2SmartHub) {
throw new Error("Absolute positioning is not available on the WeDo 2.0 Smart Hub");
}
this.cancelEventTimer();
return new Promise((resolve) => {
this._busy = true;
let message;
if (angle instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
message.writeInt32LE(normalizeAngle(angle[0]), 4);
message.writeInt32LE(normalizeAngle(angle[1]), 8);
} else {
message = Buffer.from([0x81, this.portId, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
message.writeInt32LE(normalizeAngle(angle), 5);
}
this.send(message);
this._finished = () => {
return resolve();
};
});
}
public async calibrateServo () {
this.cancelEventTimer();
const oldMode = this.mode;
let currentAngle = 0;
const listener = ({ angle }: { angle: number }) => {
currentAngle = angle;
};
this.on("absolute", listener);
await this.resetAngle(0);
await this.stop();
this.gotoAngle(0, 50);
await this.hub.sleep(600);
await this.stop();
await this.hub.sleep(500);
const absPositionAt0 = currentAngle;
this.gotoAngle(-160, 60);
await this.hub.sleep(600);
await this.stop();
await this.hub.sleep(500);
const absPositionAtMin160 = currentAngle;
this.gotoAngle(160, 60);
await this.hub.sleep(600);
await this.stop();
await this.hub.sleep(500);
const absPositionAt160 = currentAngle;
const midPoint1 = normalizeAngle((absPositionAtMin160 + absPositionAt160) / 2);
const midPoint2 = normalizeAngle(midPoint1 + 180);
const baseAngle = (Math.abs(normalizeAngle(midPoint1 - absPositionAt0)) < Math.abs(normalizeAngle(midPoint2 - absPositionAt0))) ?
roundAngleToNearest90(midPoint1) :
roundAngleToNearest90(midPoint2);
const resetToAngle = normalizeAngle(currentAngle - baseAngle);
await this.resetAngle(0);
await this.stop();
this.gotoAngle(0, 40);
await this.hub.sleep(50);
await this.stop();
await this.resetAngle(resetToAngle);
this.gotoAngle(0, 40);
await this.hub.sleep(600);
await this.stop();
this.removeListener("absolute", listener);
if (oldMode !== undefined) {
this.subscribe(oldMode);
}
}
public async resetServo (angle: number) {
this.cancelEventTimer();
const oldMode = this.mode;
let currentAngle = 0;
const listener = ({ angle }: { angle: number }) => {
currentAngle = angle;
};
this.on("absolute", listener);
angle = Math.max(-180, Math.min(179, angle));
const resetToAngle = normalizeAngle(currentAngle - angle);
await this.resetAngle(0);
await this.stop();
this.gotoAngle(0, 40);
await this.hub.sleep(50);
await this.stop();
await this.resetAngle(resetToAngle);
this.gotoAngle(0, 40);
await this.hub.sleep(500);
const diff = Math.abs(normalizeAngle(currentAngle - angle));
if (diff > 5) {
await this.resetAngle(0);
await this.stop();
this.gotoAngle(0, 40);
await this.hub.sleep(50);
await this.stop();
}
this.removeListener("absolute", listener);
if (oldMode !== undefined) {
this.subscribe(oldMode);
}
}
}
export enum Mode {

View File

@ -69,7 +69,7 @@ export class BasicMotor extends Device {
*/
public brake () {
this.cancelEventTimer();
return this.setPower(127);
return this.setPower(Consts.BrakingStyle.BRAKE);
}

View File

@ -7,6 +7,8 @@ import { mapSpeed } from "../utils";
export class TachoMotor extends BasicMotor {
protected _brakeStyle: Consts.BrakingStyle = Consts.BrakingStyle.BRAKE;
constructor (hub: IDeviceInterface, portId: number, modeMap: {[event: string]: number} = {}, type: Consts.DeviceType = Consts.DeviceType.UNKNOWN) {
super(hub, portId, Object.assign({}, modeMap, ModeMap), type);
}
@ -27,6 +29,12 @@ export class TachoMotor extends BasicMotor {
}
}
public setBrakingStyle (style: Consts.BrakingStyle) {
this._brakeStyle = style;
}
/**
* Set the motor speed.
* @method TachoMotor#setSpeed
@ -49,16 +57,16 @@ export class TachoMotor extends BasicMotor {
let message;
if (time !== undefined) {
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0a, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x0a, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
} else {
message = Buffer.from([0x81, this.portId, 0x11, 0x09, 0x00, 0x00, mapSpeed(speed), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x09, 0x00, 0x00, mapSpeed(speed), 0x64, this._brakeStyle, 0x00]);
}
message.writeUInt16LE(time, 4);
} else {
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x08, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x08, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x00]);
} else {
message = Buffer.from([0x81, this.portId, 0x11, 0x07, mapSpeed(speed), 0x64, 0x03, 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x07, mapSpeed(speed), 0x64, 0x03, 0x64, this._brakeStyle, 0x00]);
}
}
this.send(message);
@ -90,9 +98,9 @@ export class TachoMotor extends BasicMotor {
}
let message;
if (speed instanceof Array) {
message = Buffer.from([0x81, this.portId, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), 0x64, this._brakeStyle, 0x03]);
} else {
message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, 0x7e, 0x00]);
message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), 0x64, this._brakeStyle, 0x03]);
}
message.writeUInt32LE(degrees, 4);
this.send(message);

View File

@ -47,65 +47,6 @@ export class TechnicMediumHub extends LPF2Hub {
}
// /**
// * Tell motor to goto an absolute position
// * @method ControlPlusHub#setAbsolutePosition
// * @param {string} port
// * @param {number} pos The position of the motor to go to
// * @param {number | Array.<number>} [speed=100] A value between 1 - 100 should be set (Direction does not apply when going to absolute position)
// * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
// */
// public setAbsolutePosition (port: string, pos: number, speed: number = 100) {
// const portObj = this._portLookup(port);
// if (!(
// portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
// portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR
// )) {
// throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
// }
// portObj.cancelEventTimer();
// return new Promise((resolve, reject) => {
// portObj.busy = true;
// let data = null;
// if (this._virtualPorts[portObj.id]) {
// data = Buffer.from([0x81, portObj.value, 0x11, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
// data.writeInt32LE(pos, 4);
// data.writeInt32LE(pos, 8);
// } else {
// // @ts-ignore: The type of speed is properly checked at the start
// data = Buffer.from([0x81, portObj.value, 0x11, 0x0d, 0x00, 0x00, 0x00, 0x00, this._mapSpeed(speed), 0x64, 0x7f, 0x03]);
// data.writeInt32LE(pos, 4);
// }
// this.send(data, Consts.BLECharacteristic.LPF2_ALL);
// portObj.finished = () => {
// return resolve();
// };
// });
// }
// /**
// * Reset the current motor position as absolute position zero
// * @method ControlPlusHub#resetAbsolutePosition
// * @param {string} port
// * @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
// */
// public resetAbsolutePosition (port: string) {
// const portObj = this._portLookup(port);
// if (!(
// portObj.type === Consts.DeviceType.CONTROL_PLUS_LARGE_MOTOR ||
// portObj.type === Consts.DeviceType.CONTROL_PLUS_XLARGE_MOTOR
// )) {
// throw new Error("Absolute positioning is only available when using a Control+ Medium Motor, or Control+ Large Motor");
// }
// return new Promise((resolve) => {
// const data = Buffer.from([0x81, portObj.value, 0x11, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00]);
// this.send(data, Consts.BLECharacteristic.LPF2_ALL);
// return resolve();
// });
// }
}
export const PortMap: {[portName: string]: number} = {