@theopenweb/js-sensor
Version:
JavaScript sensor library for native input sensors.
130 lines (116 loc) • 5.11 kB
HTML
<html>
<head>
<meta charset="utf-8">
<base data-ice="baseUrl">
<title data-ice="title">Home | js-sensor</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
<script src="script/prettify/prettify.js"></script>
<script src="script/manual.js"></script>
<meta name="description" content="JavaScript sensor library for native input sensors."><meta property="twitter:card" content="summary"><meta property="twitter:title" content="js-sensor"><meta property="twitter:description" content="JavaScript sensor library for native input sensors."></head>
<body class="layout-container" data-ice="rootContainer">
<header>
<a href="./">Home</a>
<a href="identifiers.html">Reference</a>
<a href="source.html">Source</a>
<a href="test.html" data-ice="testLink">Test</a>
<div class="search-box">
<span>
<img src="./image/search.png">
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
</span>
<ul class="search-result"></ul>
</div>
</header>
<nav class="navigation" data-ice="nav"><div>
<ul>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/class/browser-sensor-watcher.js~BrowserSensorWatcher.html">BrowserSensorWatcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/class/js-sensor.js~JsSensor.html">JsSensor</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/class/sensor-handler.js~SensorHandler.html">SensorHandler</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SensorHandler">SensorHandler</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-BrowserSensorWatcher">BrowserSensorWatcher</a></span></span></li>
</ul>
</div>
</nav>
<div class="content" data-ice="content"><div data-ice="index" class="github-markdown"><h1 id="js-sensor">JS Sensor</h1><p> Sensor watcher of JavaScript sensor events.
This module is designed to have only basic functionality.
Any more complex functionality should be achieved through extending this module.</p>
<h2 id="environment">Environment</h2><p> Should work and be extensible using any new JavaScript environment(node, browser).
Default event listeners provided via browser-sensor-watcher.
Possible to use own via extension.</p>
<h2 id="installation">Installation</h2><ol>
<li>Install node(including npm)</li>
<li><p>"npm install" in base directory</p>
<h2 id="usage">Usage</h2><p>The full api can be checked from the documentation. See "Documentation" below.</p>
<p>Basic usage can be seen below:</p>
<pre><code><code class="source-code prettyprint">const jsSensor = new require('js-sensor');
//Get sensor list
console.log('names:' jsSensor.getMappedSensorNames());
//Update/extend
jsSensor.updateSensorListeners((sensorListenerMap)=>{
sensorListenerMap['myListener'] = {
start: (options)=>{
const data = '...HANDLE HERE';
options.events.data(data);
},
stop: ()=>{
//STOP
},
check: ()=>{
//CHECK FOR AVAILABILITY
return true;
}
};
return sensorListenerMap;
});
//Get
jsSensor.get('deviceMotion')
.then((data)=>{
console.log('get', data);
});
//Watch
jsSensor.watch('deviceOrientation',
{
events: {
data: (data)=>{
console.log('watch', data);
}
}
});
//Stop
jsSensor.stop('deviceOrientation);
//WatchAll
jsSensor.watchAll();
//...wait a while
//StopAll
jsSensor.stopAll()</code>
</code></pre><h2 id="events">Events</h2></li>
<li>watchPosition</li>
<li>getUserMedia</li>
<li>deviceOrientation</li>
<li>deviceLight</li>
<li>deviceProximity</li>
<li>deviceMotion</li>
<li><p>test</p>
<h2 id="tests">Tests</h2><p>Run <code>npm run test</code></p>
<h2 id="reports">Reports</h2></li>
<li>Built when running tests.</li>
<li><p>Eslint</p>
<h2 id="documentation">Documentation</h2></li>
<li>Esdoc(./docs/)</li>
</ol>
</div>
</div>
<footer class="footer">
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.0.4)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>
<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>