1
0
Fork 0
mirror of https://github.com/kou029w/megabit.git synced 2025-01-31 06:08:03 +00:00
megabit/index.html
2021-07-24 15:25:02 +00:00

278 lines
No EOL
14 KiB
HTML

<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>megabit</title>
<meta name="description" content="Documentation for megabit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">megabit</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<h1>megabit</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<a href="#megabit" id="megabit" style="color: inherit; text-decoration: none;">
<h1>Megabit</h1>
</a>
<p>Connect real things with Node.js</p>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<a href="#gpio-example" id="gpio-example" style="color: inherit; text-decoration: none;">
<h3>GPIO Example</h3>
</a>
<pre><code class="language-js"><span style="color: #0000FF">const</span><span style="color: #000000"> { </span><span style="color: #0070C1">gpio</span><span style="color: #000000"> } = </span><span style="color: #795E26">require</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;megabit&quot;</span><span style="color: #000000">);</span>
<span style="color: #0000FF">const</span><span style="color: #000000"> </span><span style="color: #0070C1">sleep</span><span style="color: #000000"> = </span><span style="color: #795E26">require</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;util&quot;</span><span style="color: #000000">).</span><span style="color: #795E26">promisify</span><span style="color: #000000">(</span><span style="color: #001080">setTimeout</span><span style="color: #000000">);</span>
<span style="color: #0000FF">async</span><span style="color: #000000"> </span><span style="color: #0000FF">function</span><span style="color: #000000"> </span><span style="color: #795E26">blink</span><span style="color: #000000">() {</span>
<span style="color: #000000"> </span><span style="color: #AF00DB">for</span><span style="color: #000000"> (;;) {</span>
<span style="color: #000000"> </span><span style="color: #AF00DB">await</span><span style="color: #000000"> </span><span style="color: #795E26">gpio</span><span style="color: #000000">(</span><span style="color: #098658">26</span><span style="color: #000000">).</span><span style="color: #795E26">write</span><span style="color: #000000">(</span><span style="color: #098658">1</span><span style="color: #000000">);</span>
<span style="color: #000000"> </span><span style="color: #AF00DB">await</span><span style="color: #000000"> </span><span style="color: #795E26">sleep</span><span style="color: #000000">(</span><span style="color: #098658">1000</span><span style="color: #000000">);</span>
<span style="color: #000000"> </span><span style="color: #AF00DB">await</span><span style="color: #000000"> </span><span style="color: #795E26">gpio</span><span style="color: #000000">(</span><span style="color: #098658">26</span><span style="color: #000000">).</span><span style="color: #795E26">write</span><span style="color: #000000">(</span><span style="color: #098658">0</span><span style="color: #000000">);</span>
<span style="color: #000000"> </span><span style="color: #AF00DB">await</span><span style="color: #000000"> </span><span style="color: #795E26">sleep</span><span style="color: #000000">(</span><span style="color: #098658">1000</span><span style="color: #000000">);</span>
<span style="color: #000000"> }</span>
<span style="color: #000000">}</span>
<span style="color: #795E26">blink</span><span style="color: #000000">();</span>
</code></pre>
<a href="#i2c-example" id="i2c-example" style="color: inherit; text-decoration: none;">
<h3>I<sup>2</sup>C Example</h3>
</a>
<pre><code class="language-js"><span style="color: #0000FF">const</span><span style="color: #000000"> { </span><span style="color: #0070C1">sht30</span><span style="color: #000000"> } = </span><span style="color: #795E26">require</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;megabit&quot;</span><span style="color: #000000">);</span>
<span style="color: #0000FF">async</span><span style="color: #000000"> </span><span style="color: #0000FF">function</span><span style="color: #000000"> </span><span style="color: #795E26">measure</span><span style="color: #000000">() {</span>
<span style="color: #000000"> </span><span style="color: #0000FF">const</span><span style="color: #000000"> { </span><span style="color: #0070C1">humidity</span><span style="color: #000000">, </span><span style="color: #0070C1">temperature</span><span style="color: #000000"> } = </span><span style="color: #AF00DB">await</span><span style="color: #000000"> </span><span style="color: #795E26">sht30</span><span style="color: #000000">().</span><span style="color: #795E26">read</span><span style="color: #000000">();</span>
<span style="color: #000000"> </span><span style="color: #001080">console</span><span style="color: #000000">.</span><span style="color: #795E26">log</span><span style="color: #000000">(</span><span style="color: #A31515">`Humidity: </span><span style="color: #0000FF">${</span><span style="color: #001080">humidity</span><span style="color: #000000FF">.</span><span style="color: #795E26">toFixed</span><span style="color: #000000FF">(</span><span style="color: #098658">2</span><span style="color: #000000FF">)</span><span style="color: #0000FF">}</span><span style="color: #A31515"> %`</span><span style="color: #000000">);</span>
<span style="color: #000000"> </span><span style="color: #001080">console</span><span style="color: #000000">.</span><span style="color: #795E26">log</span><span style="color: #000000">(</span><span style="color: #A31515">`Temperature: </span><span style="color: #0000FF">${</span><span style="color: #001080">temperature</span><span style="color: #000000FF">.</span><span style="color: #795E26">toFixed</span><span style="color: #000000FF">(</span><span style="color: #098658">2</span><span style="color: #000000FF">)</span><span style="color: #0000FF">}</span><span style="color: #A31515"> ℃`</span><span style="color: #000000">);</span>
<span style="color: #000000">}</span>
<span style="color: #795E26">measure</span><span style="color: #000000">();</span>
</code></pre>
<a href="#documents" id="documents" style="color: inherit; text-decoration: none;">
<h2>Documents</h2>
</a>
<p><a href="https://kou029w.github.io/megabit/">Megabit API Documentation</a></p>
<a href="#devices" id="devices" style="color: inherit; text-decoration: none;">
<h2>Devices</h2>
</a>
<table>
<thead>
<tr>
<th>Device</th>
<th>Description</th>
<th>API</th>
</tr>
</thead>
<tbody><tr>
<td>ADS1015</td>
<td>12-bit Precision Analog to Digital Converter</td>
<td><a href="https://kou029w.github.io/megabit/modules/ads1015.html">ads1015</a></td>
</tr>
<tr>
<td>ADT7410</td>
<td>High Accuracy Digital Temperature Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/adt7410.html">adt7410</a></td>
</tr>
<tr>
<td>ADXL345</td>
<td>3-axis Accelerometer</td>
<td><a href="https://kou029w.github.io/megabit/modules/adxl345.html">adxl345</a></td>
</tr>
<tr>
<td>GP2Y0E03</td>
<td>4-50 cm Distance Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/gp2y0e03.html">gp2y0e03</a></td>
</tr>
<tr>
<td>MPR121</td>
<td>Proximity Capacitive Touch Sensor Controller</td>
<td><a href="https://kou029w.github.io/megabit/modules/mpr121.html">mpr121</a></td>
</tr>
<tr>
<td>PAJ7620</td>
<td>Gesture Recognition Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/paj7620.html">paj7620</a></td>
</tr>
<tr>
<td>PCA9685</td>
<td>16-Channel 12-Bit PWM/Servo Driver</td>
<td><a href="https://kou029w.github.io/megabit/modules/pca9685.html">pca9685</a></td>
</tr>
<tr>
<td>S11059</td>
<td>Color Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/s11059.html">s11059</a></td>
</tr>
<tr>
<td>SHT30</td>
<td>Humidity and Temperature Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/sht30.html">sht30</a></td>
</tr>
<tr>
<td>SSD1306</td>
<td>128x64 Dot Matrix OLED</td>
<td><a href="https://kou029w.github.io/megabit/modules/ssd1306.html">ssd1306</a></td>
</tr>
<tr>
<td>SSD1308</td>
<td>128x64 Dot Matrix OLED</td>
<td><a href="https://kou029w.github.io/megabit/modules/ssd1308.html">ssd1308</a></td>
</tr>
<tr>
<td>TSL2561</td>
<td>Ambient Light Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/tsl2561.html">tsl2561</a></td>
</tr>
<tr>
<td>VEML6070</td>
<td>UV(A) Light Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/veml6070.html">veml6070</a></td>
</tr>
<tr>
<td>VL53L0X</td>
<td>Time of Flight Distance Sensor</td>
<td><a href="https://kou029w.github.io/megabit/modules/vl53l0x.html">vl53l0x</a></td>
</tr>
</tbody></table>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="modules.html">Modules</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/Device.html">Device</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/ads1015.html">ads1015</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/adt7410.html">adt7410</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/adxl345.html">adxl345</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/gp2y0e03.html">gp2y0e03</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/gpio.html">gpio</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/i2c.html">i2c</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/index.html">index</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/mpr121.html">mpr121</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/paj7620.html">paj7620</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/pca9685.html">pca9685</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/s11059.html">s11059</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/sht30.html">sht30</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/ssd1306.html">ssd1306</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/ssd1308.html">ssd1308</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/tsl2561.html">tsl2561</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/veml6070.html">veml6070</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/vl53l0x.html">vl53l0x</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
</body>
</html>