node-poweredup/docs/PUPHub.html
2019-01-18 16:17:21 -08:00

4730 lines
54 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: PUPHub</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: PUPHub</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>PUPHub<span class="signature">()</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="PUPHub"><span class="type-signature"></span>new PUPHub<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
The PUPHub is emitted if the discovered device is a Powered UP Hub.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="puphub.js.html">puphub.js</a>, <a href="puphub.js.html#line15">line 15</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li><a href="LPF2Hub.html">LPF2Hub</a></li>
<li><a href="Hub.html">Hub</a></li>
</ul>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="batteryLevel"><span class="type-signature">(readonly) </span>batteryLevel<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>batteryLevel</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Battery level of the hub (Percentage between 0-100)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#batteryLevel">Hub#batteryLevel</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line66">line 66</a>
</li></ul></dd>
</dl>
<h4 class="name" id="current"><span class="type-signature">(readonly) </span>current<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>current</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Current usage of the hub (Amps)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#current">LPF2Hub#current</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line38">line 38</a>
</li></ul></dd>
</dl>
<h4 class="name" id="firmwareVersion"><span class="type-signature">(readonly) </span>firmwareVersion<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>firmwareVersion</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Firmware version of the hub</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#firmwareVersion">Hub#firmwareVersion</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line45">line 45</a>
</li></ul></dd>
</dl>
<h4 class="name" id="name"><span class="type-signature">(readonly) </span>name<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Name of the hub</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#name">Hub#name</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line38">line 38</a>
</li></ul></dd>
</dl>
<h4 class="name" id="rssi"><span class="type-signature">(readonly) </span>rssi<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>rssi</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Signal strength of the hub</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#rssi">Hub#rssi</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line59">line 59</a>
</li></ul></dd>
</dl>
<h4 class="name" id="uuid"><span class="type-signature">(readonly) </span>uuid<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>uuid</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">UUID of the hub</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#uuid">Hub#uuid</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line52">line 52</a>
</li></ul></dd>
</dl>
<h4 class="name" id="voltage"><span class="type-signature">(readonly) </span>voltage<span class="type-signature"></span></h4>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>voltage</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Voltage of the hub (Volts)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#voltage">LPF2Hub#voltage</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line31">line 31</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="connect"><span class="type-signature"></span>connect<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Connect to the Hub.
</div>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#connect">Hub#connect</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line69">line 69</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful connect.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="disconnect"><span class="type-signature"></span>disconnect<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Disconnect the Hub.
</div>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#disconnect">Hub#disconnect</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line118">line 118</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful disconnect.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="getHubType"><span class="type-signature"></span>getHubType<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#HubType">HubType</a>}</span></h4>
<div class="description">
Get the hub type.
</div>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#getHubType">Hub#getHubType</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line186">line 186</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#HubType">HubType</a></span>
</dd>
</dl>
<h4 class="name" id="getPortDeviceType"><span class="type-signature"></span>getPortDeviceType<span class="signature">(port)</span><span class="type-signature"> &rarr; {<a href="global.html#DeviceType">DeviceType</a>}</span></h4>
<div class="description">
Get the device type for a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#getPortDeviceType">Hub#getPortDeviceType</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line194">line 194</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="global.html#DeviceType">DeviceType</a></span>
</dd>
</dl>
<h4 class="name" id="hardStopMotor"><span class="type-signature"></span>hardStopMotor<span class="signature">(port)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Fully (hard) stop the motor on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="puphub.js.html">puphub.js</a>, <a href="puphub.js.html#line140">line 140</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful completion of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="rampMotorSpeed"><span class="type-signature"></span>rampMotorSpeed<span class="signature">(port, fromSpeed, toSpeed, time)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Ramp the motor speed on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>fromSpeed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.</td>
</tr>
<tr>
<td class="name"><code>toSpeed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.</td>
</tr>
<tr>
<td class="name"><code>time</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">How long the ramp should last (in milliseconds).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="puphub.js.html">puphub.js</a>, <a href="puphub.js.html#line120">line 120</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful completion of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setLEDColor"><span class="type-signature"></span>setLEDColor<span class="signature">(color)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Set the color of the LED on the Hub via a color value.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>color</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Color">Color</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#setLEDColor">LPF2Hub#setLEDColor</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line79">line 79</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful issuance of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setLEDRGB"><span class="type-signature"></span>setLEDRGB<span class="signature">(red, green, blue)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Set the color of the LED on the Hub via RGB values.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>red</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>green</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>blue</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#setLEDRGB">LPF2Hub#setLEDRGB</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line97">line 97</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful issuance of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setLightBrightness"><span class="type-signature"></span>setLightBrightness<span class="signature">(port, brightness, time<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Set the light brightness on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>brightness</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">Brightness value between 0-100 (0 is off)</td>
</tr>
<tr>
<td class="name"><code>time</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">How long to turn the light on (in milliseconds). Leave empty to turn the light on indefinitely.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="puphub.js.html">puphub.js</a>, <a href="puphub.js.html#line149">line 149</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful completion of command. If time is specified, this is once the light is turned off.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setMotorSpeed"><span class="type-signature"></span>setMotorSpeed<span class="signature">(port, speed, time<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Set the motor speed on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>speed</code></td>
<td class="type">
<span class="param-type">number</span>
|
<span class="param-type">Array.&lt;number></span>
</td>
<td class="attributes">
</td>
<td class="description last">For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0. If you are specifying port AB to control both motors, you can optionally supply a tuple of speeds.</td>
</tr>
<tr>
<td class="name"><code>time</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">How long to activate the motor for (in milliseconds). Leave empty to turn the motor on indefinitely.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="puphub.js.html">puphub.js</a>, <a href="puphub.js.html#line52">line 52</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful completion of command. If time is specified, this is once the motor is finished.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setName"><span class="type-signature"></span>setName<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Set the name of the Hub.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">New name of the hub (14 characters or less, ASCII only).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#setName">LPF2Hub#setName</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line59">line 59</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful issuance of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="sleep"><span class="type-signature"></span>sleep<span class="signature">(delay)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Sleep a given amount of time.
This is a helper method to make it easier to add delays into a chain of commands.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>delay</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">How long to sleep (in milliseconds).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#sleep">Hub#sleep</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line162">line 162</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved after the delay is finished.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="subscribe"><span class="type-signature"></span>subscribe<span class="signature">(port, mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Subscribe to sensor notifications on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The sensor mode to activate. If no mode is provided, the default for that sensor will be chosen.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#subscribe">Hub#subscribe</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line130">line 130</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful issuance of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="unsubscribe"><span class="type-signature"></span>unsubscribe<span class="signature">(port)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Unsubscribe to sensor notifications on a given port.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#unsubscribe">Hub#unsubscribe</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line148">line 148</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved upon successful issuance of command.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="wait"><span class="type-signature"></span>wait<span class="signature">(commands)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
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.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>commands</code></td>
<td class="type">
<span class="param-type">Array.&lt;Promise.&lt;any>></span>
</td>
<td class="description last">Array of executing commands.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#wait">Hub#wait</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line175">line 175</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolved after the commands are finished.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h3 class="subsection-title">Events</h3>
<h4 class="name" id="event:attach">attach</h4>
<div class="description">
Emits when a motor or sensor is attached to the Hub.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type"><a href="global.html#DeviceType">DeviceType</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#event:attach">Hub#event:attach</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line231">line 231</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:button">button</h4>
<div class="description">
Emits when a button is pressed.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>button</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>state</code></td>
<td class="type">
<span class="param-type"><a href="global.html#ButtonState">ButtonState</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line173">line 173</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:color">color</h4>
<div class="description">
Emits when a color sensor is activated.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>color</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Color">Color</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#event:color">LPF2Hub#event:color</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line273">line 273</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:colorAndDistance">colorAndDistance</h4>
<div class="description">
A combined color and distance event, emits when the sensor is activated.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>color</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Color">Color</a></span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>distance</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Distance, in millimeters.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#event:colorAndDistance">LPF2Hub#event:colorAndDistance</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line289">line 289</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:detach">detach</h4>
<div class="description">
Emits when an attached motor or sensor is detached from the Hub.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-overrides">Overrides:</dt>
<dd class="tag-overrides"><ul class="dummy"><li>
<a href="Hub.html#event:detach">Hub#event:detach</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html#line243">line 243</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:distance">distance</h4>
<div class="description">
Emits when a distance sensor is activated.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>distance</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Distance, in millimeters.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#event:distance">LPF2Hub#event:distance</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line263">line 263</a>
</li></ul></dd>
</dl>
<h4 class="name" id="event:tilt">tilt</h4>
<div class="description">
Emits when a tilt sensor is activated.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">If the event is fired from the Move Hub's in-built tilt sensor, the special port "TILT" is used.</td>
</tr>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a>
</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lpf2hub.js.html">lpf2hub.js</a>, <a href="lpf2hub.js.html#line306">line 306</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BoostMoveHub.html">BoostMoveHub</a></li><li><a href="DuploTrainBase.html">DuploTrainBase</a></li><li><a href="Hub.html">Hub</a></li><li><a href="LPF2Hub.html">LPF2Hub</a></li><li><a href="PoweredUP.html">PoweredUP</a></li><li><a href="PUPHub.html">PUPHub</a></li><li><a href="PUPRemote.html">PUPRemote</a></li><li><a href="WeDo2SmartHub.html">WeDo2SmartHub</a></li></ul><h3>Events</h3><ul><li><a href="BoostMoveHub.html#event:attach">attach</a></li><li><a href="BoostMoveHub.html#event:button">button</a></li><li><a href="BoostMoveHub.html#event:color">color</a></li><li><a href="BoostMoveHub.html#event:colorAndDistance">colorAndDistance</a></li><li><a href="BoostMoveHub.html#event:detach">detach</a></li><li><a href="BoostMoveHub.html#event:distance">distance</a></li><li><a href="BoostMoveHub.html#event:rotate">rotate</a></li><li><a href="BoostMoveHub.html#event:tilt">tilt</a></li><li><a href="DuploTrainBase.html#event:color">color</a></li><li><a href="DuploTrainBase.html#event:speed">speed</a></li><li><a href="Hub.html#event:attach">attach</a></li><li><a href="Hub.html#event:detach">detach</a></li><li><a href="LPF2Hub.html#event:attach">attach</a></li><li><a href="LPF2Hub.html#event:button">button</a></li><li><a href="LPF2Hub.html#event:color">color</a></li><li><a href="LPF2Hub.html#event:colorAndDistance">colorAndDistance</a></li><li><a href="LPF2Hub.html#event:detach">detach</a></li><li><a href="LPF2Hub.html#event:distance">distance</a></li><li><a href="LPF2Hub.html#event:rotate">rotate</a></li><li><a href="LPF2Hub.html#event:speed">speed</a></li><li><a href="LPF2Hub.html#event:tilt">tilt</a></li><li><a href="PoweredUP.html#event:discover">discover</a></li><li><a href="PUPHub.html#event:attach">attach</a></li><li><a href="PUPHub.html#event:button">button</a></li><li><a href="PUPHub.html#event:color">color</a></li><li><a href="PUPHub.html#event:colorAndDistance">colorAndDistance</a></li><li><a href="PUPHub.html#event:detach">detach</a></li><li><a href="PUPHub.html#event:distance">distance</a></li><li><a href="PUPHub.html#event:tilt">tilt</a></li><li><a href="PUPRemote.html#event:button">button</a></li><li><a href="PUPRemote.html#event:colorAndDistance">colorAndDistance</a></li><li><a href="WeDo2SmartHub.html#event:attach">attach</a></li><li><a href="WeDo2SmartHub.html#event:button">button</a></li><li><a href="WeDo2SmartHub.html#event:color">color</a></li><li><a href="WeDo2SmartHub.html#event:detach">detach</a></li><li><a href="WeDo2SmartHub.html#event:distance">distance</a></li><li><a href="WeDo2SmartHub.html#event:rotate">rotate</a></li><li><a href="WeDo2SmartHub.html#event:tilt">tilt</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jan 18 2019 16:16:36 GMT-0800 (Pacific Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>