268 lines
11 KiB
HTML
268 lines
11 KiB
HTML
<!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 && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const 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">×</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>
|