mirror of
https://github.com/chirimen-oh/node-web-i2c.git
synced 2025-01-18 16:08:06 +00:00
6d341aaaf7
Ref. #45 Co-authored-by: akihiko kigure <akihiko.kigure@lifewood-m1.local>
17 lines
No EOL
7.5 KiB
HTML
17 lines
No EOL
7.5 KiB
HTML
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>node-web-i2c</title><meta name="description" content="Documentation for node-web-i2c"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></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">node-web-i2c</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>node-web-i2c</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="#node-web-i2c" id="node-web-i2c" style="color: inherit; text-decoration: none;">
|
|
<h1>node-web-i2c</h1>
|
|
</a>
|
|
<p>I2C access with Node.js</p>
|
|
|
|
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
|
|
<h2>Usage</h2>
|
|
</a>
|
|
<pre><code class="language-js"><span class="hl-0">const</span><span class="hl-1"> { </span><span class="hl-2">requestI2CAccess</span><span class="hl-1"> } = </span><span class="hl-3">require</span><span class="hl-1">(</span><span class="hl-4">"node-web-i2c"</span><span class="hl-1">);</span><br/><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">ADT7410</span><span class="hl-1"> = </span><span class="hl-3">require</span><span class="hl-1">(</span><span class="hl-4">"@chirimen/adt7410"</span><span class="hl-1">);</span><br/><br/><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">ADT7410_ADDR</span><span class="hl-1"> = </span><span class="hl-5">0x48</span><span class="hl-1">;</span><br/><br/><span class="hl-0">async</span><span class="hl-1"> </span><span class="hl-0">function</span><span class="hl-1"> </span><span class="hl-3">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">i2cAccess</span><span class="hl-1"> = </span><span class="hl-6">await</span><span class="hl-1"> </span><span class="hl-3">requestI2CAccess</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">port</span><span class="hl-1"> = </span><span class="hl-7">i2cAccess</span><span class="hl-1">.</span><span class="hl-7">ports</span><span class="hl-1">.</span><span class="hl-3">get</span><span class="hl-1">(</span><span class="hl-5">1</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">adt7410</span><span class="hl-1"> = </span><span class="hl-0">new</span><span class="hl-1"> </span><span class="hl-3">ADT7410</span><span class="hl-1">(</span><span class="hl-7">port</span><span class="hl-1">, </span><span class="hl-2">ADT7410_ADDR</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-6">await</span><span class="hl-1"> </span><span class="hl-7">adt7410</span><span class="hl-1">.</span><span class="hl-3">init</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">temperature</span><span class="hl-1"> = </span><span class="hl-6">await</span><span class="hl-1"> </span><span class="hl-7">adt7410</span><span class="hl-1">.</span><span class="hl-3">read</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-7">console</span><span class="hl-1">.</span><span class="hl-3">log</span><span class="hl-1">(</span><span class="hl-4">`Temperature: </span><span class="hl-0">${</span><span class="hl-7">temperature</span><span class="hl-0">}</span><span class="hl-4"> ℃`</span><span class="hl-1">);</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-3">main</span><span class="hl-1">();</span>
|
|
</code></pre>
|
|
|
|
<a href="#document" id="document" style="color: inherit; text-decoration: none;">
|
|
<h2>Document</h2>
|
|
</a>
|
|
<p><a href="http://browserobo.github.io/WebI2C">Web I2C API</a></p>
|
|
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-class"><a href="classes/I2CAccess.html" class="tsd-kind-icon">I2CAccess</a></li><li class="tsd-kind-class"><a href="classes/I2CPort.html" class="tsd-kind-icon">I2CPort</a></li><li class="tsd-kind-class"><a href="classes/I2CPortMap.html" class="tsd-kind-icon">I2CPort<wbr/>Map</a></li><li class="tsd-kind-class"><a href="classes/OperationError.html" class="tsd-kind-icon">Operation<wbr/>Error</a></li><li class="tsd-kind-interface"><a href="interfaces/I2CSlaveDevice.html" class="tsd-kind-icon">I2CSlave<wbr/>Device</a></li><li class="tsd-kind-function"><a href="modules.html#requestI2CAccess" class="tsd-kind-icon">request<wbr/>I2CAccess</a></li></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-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></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/main.js"></script></body></html> |