qmk_firmware/assets/drivers_ws2812.md._cnUpPJK.js

16 lines
23 KiB
JavaScript
Raw Normal View History

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
const __pageData = JSON.parse('{"title":"WS2812 Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/ws2812.md","filePath":"drivers/ws2812.md"}');
const _sfc_main = { name: "drivers/ws2812.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="ws2812-driver" tabindex="-1">WS2812 Driver <a class="header-anchor" href="#ws2812-driver" aria-label="Permalink to &quot;WS2812 Driver {#ws2812-driver}&quot;"></a></h1><p>This driver provides support for WorldSemi addressable RGB(W) LEDs, and compatible equivalents:</p><ul><li>WS2811, WS2812, WS2812B, WS2812C, etc.</li><li>SK6812, SK6812MINI, SK6805</li></ul><p>These LEDs are often called &quot;addressable&quot; because instead of using a wire per color (and per LED), each LED contains a small microchip that understands a special protocol sent over a single wire. The LEDs can be chained together, and the remaining data is passed on to the next. In this way, you can easily control the color of many LEDs using a single GPIO.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to &quot;Usage {#usage}&quot;"></a></h2><p>In most cases, the WS2812 driver code is automatically included if you are using either the <a href="./../features/rgblight">RGBLight</a> or <a href="./../features/rgb_matrix">RGB Matrix</a> feature with the <code>ws2812</code> driver set, and you would use those APIs instead.</p><p>However, if you need to use the driver standalone, add the following to your <code>rules.mk</code>:</p><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">WS2812_DRIVER_REQUIRED = yes</span></span></code></pre></div><p>You can then call the WS2812 API by including <code>ws2812.h</code> in your code.</p><h2 id="basic-configuration" tabindex="-1">Basic Configuration <a class="header-anchor" href="#basic-configuration" aria-label="Permalink to &quot;Basic Configuration {#basic-configuration}&quot;"></a></h2><p>Add the following to your <code>config.h</code>:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>WS2812_DI_PIN</code></td><td><em>Not defined</em></td><td>The GPIO pin connected to the DI pin of the first LED in the chain</td></tr><tr><td><code>WS2812_LED_COUNT</code></td><td><em>Not defined</em></td><td>Number of LEDs in the WS2812 chain - automatically set when RGBLight or RGB Matrix is configured</td></tr><tr><td><code>WS2812_TIMING</code></td><td><code>1250</code></td><td>The total length of a bit (TH+TL) in nanoseconds</td></tr><tr><td><code>WS2812_T1H</code></td><td><code>900</code></td><td>The length of a &quot;1&quot; bit&#39;s high phase in nanoseconds</td></tr><tr><td><code>WS2812_T0H</code></td><td><code>350</code></td><td>The length of a &quot;0&quot; bit&#39;s high phase in nanoseconds</td></tr><tr><td><code>WS2812_TRST_US</code></td><td><code>280</code></td><td>The length of the reset phase in microseconds</td></tr><tr><td><code>WS2812_BYTE_ORDER</code></td><td><code>WS2812_BYTE_ORDER_GRB</code></td><td>The byte order of the RGB data</td></tr><tr><td><code>WS2812_RGBW</code></td><td><em>Not defined</em></td><td>Enables RGBW support (except <code>i2c</code> driver)</td></tr></tbody></table><h3 id="timing-adjustment" tabindex="-1">Timing Adjustment <a class="header-anchor" href="#timing-adjustment" aria-label="Permalink to &quot;Timing Adjustment {#timing-adjustment}&quot;"></a></h3><p>The WS2812 LED communication protocol works by encoding a &quot;1&quot; bit with a long high pulse (T<sub>1</sub>H), and a &quot;0&quot; bit with a shorter pulse (T<sub>0</sub>H). The total cycle length of a bit is the same. The &quot;reset&quot; pulse (T<sub>RST</sub>) latches the sent RGB data to all of the LEDs and denotes a completed &quot;frame&quot;.</p><p>Some WS2812 variants have slightly different timing parameter requirements, which can be accounted for if necessary using the above <code>#define</code>s in your <code>config.h</code>.</p><h3 id="byte-order" tabindex="-1">Byte Order <a class="header-anchor" href="#byte-order" aria-labe
const _hoisted_90 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_90);
}
const ws2812 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
ws2812 as default
};