mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-02-27 01:56:43 +00:00
17 lines
81 KiB
JavaScript
17 lines
81 KiB
JavaScript
import { _ as _imports_0 } from "./chunks/color-wheel.DIUCmfNZ.js";
|
||
import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js";
|
||
const __pageData = JSON.parse('{"title":"RGB Lighting","description":"","frontmatter":{},"headers":[],"relativePath":"features/rgblight.md","filePath":"features/rgblight.md"}');
|
||
const _sfc_main = { name: "features/rgblight.md" };
|
||
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="rgb-lighting" tabindex="-1">RGB Lighting <a class="header-anchor" href="#rgb-lighting" aria-label="Permalink to "RGB Lighting""></a></h1><p>QMK has the ability to control RGB LEDs attached to your keyboard. This is commonly called <em>underglow</em>, due to the LEDs often being mounted on the bottom of the keyboard, producing a nice diffused effect when combined with a translucent case.</p><p><img src="https://raw.githubusercontent.com/qmk/qmk_firmware/3774a7fcdab5544fc787f4c200be05fcd417e31f/keyboards/planck/keymaps/yang/planck-with-rgb-underglow.jpg" alt="Planck with RGB Underglow"></p><p>Some keyboards come with RGB LEDs preinstalled. Others must have them installed after the fact. See the <a href="#hardware-modification">Hardware Modification</a> section for information on adding RGB lighting to your keyboard.</p><p>Currently QMK supports the following addressable LEDs:</p><ul><li>WS2811, WS2812, WS2812B, WS2812C, etc.</li><li>SK6812, SK6812MINI, SK6805</li><li>APA102</li></ul><p>These LEDs are called "addressable" because instead of using a wire per color, each LED contains a small microchip that understands a special protocol sent over a single wire. The chip passes on the remaining data to the next LED, allowing them to be chained together. In this way, you can easily control the color of the individual LEDs.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage""></a></h2><p>On keyboards with onboard RGB LEDs, it is usually enabled by default. If it is not working for you, check that your <code>rules.mk</code> includes the following:</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;">RGBLIGHT_ENABLE = yes</span></span></code></pre></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>There are additional configuration options for ARM controllers that offer increased performance over the default WS2812 bitbang driver. Please see <a href="./../drivers/ws2812">WS2812 Driver</a> for more information.</p></div><p>For APA102 LEDs, 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;">RGBLIGHT_ENABLE = yes</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">RGBLIGHT_DRIVER = apa102</span></span></code></pre></div><p>At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your <code>config.h</code>. For APA102 LEDs, you must also define the clock pin. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these.</p><table><thead><tr><th>Define</th><th>Description</th></tr></thead><tbody><tr><td><code>WS2812_DI_PIN</code></td><td>The pin connected to the data pin of the LEDs (WS2812)</td></tr><tr><td><code>APA102_DI_PIN</code></td><td>The pin connected to the data pin of the LEDs (APA102)</td></tr><tr><td><code>APA102_CI_PIN</code></td><td>The pin connected to the clock pin of the LEDs (APA102)</td></tr><tr><td><code>RGBLIGHT_LED_COUNT</code></td><td>The number of LEDs connected</td></tr><tr><td><code>RGBLED_SPLIT</code></td><td>(Optional) For split keyboards, the number of LEDs connected on each half</td></tr></tbody></table><p>Then you should be able to use the keycodes below to change the RGB lighting to your liking.</p><h3 id="color-selection" tabindex="-1">Color Selection <a class="header-anchor" href="#color-selection" aria-label="Permalink to "Color Selection""></a></h3><p>QMK uses <a href="https://en.wikipedia.org/wiki/HSL_and_HSV" target="_blank" rel="noreferrer">Hue, Saturation, and Value</a> to select colors rather than RGB. The color wheel below demonstrates how this works.</p><img src="' + _imports_0 + '" alt="HSV Color Wheel" width="250"><p>Changing the <strong>Hue</strong> cycles around the circle.<br> Changing the <strong>Saturation</strong> moves between the inner and outer sections of the wheel, affecting the intensity of the color.<br> Changing the <strong>Value</strong> sets the overall brightness.<br></p><p><img src="https://i.imgur.com/vkYVo66.jpg" alt="QMK Color Wheel with HSV Values"></p><h2 id="keycodes" tabindex="-1">Keycodes <a class="header-anchor" href="#keycodes" aria-label="Permalink to "Keycodes""></a></h2><table><thead><tr><th>Key</th><th>Aliases</th><th>Description</th></tr></thead><tbody><tr><td><code>RGB_TOG</code></td><td></td><td>Toggle RGB lighting on or off</td></tr><tr><td><code>RGB_MODE_FORWARD</code></td><td><code>RGB_MOD</code></td><td>Cycle through modes, reverse direction when Shift is held</td></tr><tr><td><code>RGB_MODE_REVERSE</code></td><td><code>RGB_RMOD</code></td><td>Cycle through modes in reverse, forward direction when Shift is held</td></tr><tr><td><code>RGB_HUI</code></td><td></td><td>Increase hue, decrease hue when Shift is held</td></tr><tr><td><code>RGB_HUD</code></td><td></td><td>Decrease hue, increase hue when Shift is held</td></tr><tr><td><code>RGB_SAI</code></td><td></td><td>Increase saturation, decrease saturation when Shift is held</td></tr><tr><td><code>RGB_SAD</code></td><td></td><td>Decrease saturation, increase saturation when Shift is held</td></tr><tr><td><code>RGB_VAI</code></td><td></td><td>Increase value (brightness), decrease value when Shift is held</td></tr><tr><td><code>RGB_VAD</code></td><td></td><td>Decrease value (brightness), increase value when Shift is held</td></tr><tr><td><code>RGB_MODE_PLAIN</code></td><td><code>RGB_M_P </code></td><td>Static (no animation) mode</td></tr><tr><td><code>RGB_MODE_BREATHE</code></td><td><code>RGB_M_B</code></td><td>Breathing animation mode</td></tr><tr><td><code>RGB_MODE_RAINBOW</code></td><td><code>RGB_M_R</code></td><td>Rainbow animation mode</td></tr><tr><td><code>RGB_MODE_SWIRL</code></td><td><code>RGB_M_SW</code></td><td>Swirl animation mode</td></tr><tr><td><code>RGB_MODE_SNAKE</code></td><td><code>RGB_M_SN</code></td><td>Snake animation mode</td></tr><tr><td><code>RGB_MODE_KNIGHT</code></td><td><code>RGB_M_K</code></td><td>"Knight Rider" animation mode</td></tr><tr><td><code>RGB_MODE_XMAS</code></td><td><code>RGB_M_X</code></td><td>Christmas animation mode</td></tr><tr><td><code>RGB_MODE_GRADIENT</code></td><td><code>RGB_M_G</code></td><td>Static gradient animation mode</td></tr><tr><td><code>RGB_MODE_RGBTEST</code></td><td><code>RGB_M_T</code></td><td>Red, Green, Blue test animation mode</td></tr><tr><td><code>RGB_MODE_TWINKLE</code></td><td><code>RGB_M_TW</code></td><td>Twinkle animation mode</td></tr></tbody></table><div class="tip custom-block"><p class="custom-block-title">TIP</p><p><code>RGB_*</code> keycodes cannot be used with functions like <code>tap_code16(RGB_HUI)</code> as they're not USB HID keycodes. If you wish to replicate similar behaviour in custom code within your firmware (e.g. inside <code>encoder_update_user()</code> or <code>process_record_user()</code>), the equivalent <a href="#functions">RGB functions</a> should be used instead.</p></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>By default, if you have both the RGB Light and the <a href="./rgb_matrix">RGB Matrix</a> feature enabled, these keycodes will work for both features, at the same time. You can disable the keycode functionality by defining the <code>*_DISABLE_KEYCODES</code> option for the specific feature.</p></div><h2 id="configuration" tabindex="-1">Configuration <a class="header-anchor" href="#configuration" aria-label="Permalink to "Configuration""></a></h2><p>Your RGB lighting can be configured by placing these <code>#define</code>s in your <code>config.h</code>:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>RGBLIGHT_HUE_STEP</code></td><td><code>8</code></td><td>The number of steps to cycle through the hue by</td></tr><tr><td><code>RGBLIGHT_SAT_STEP</code></td><td><code>17</code></td><td>The number of steps to increment the saturation by</td></tr><tr><td><code>RGBLIGHT_VAL_STEP</code></td><td><code>17</code></td><td>The number of steps to increment the brightness by</td></tr><tr><td><code>RGBLIGHT_LIMIT_VAL</code></td><td><code>255</code></td><td>The maximum brightness level</td></tr><tr><td><code>RGBLIGHT_SLEEP</code></td><td><em>Not defined</em></td><td>If defined, the RGB lighting will be switched off when the host goes to sleep</td></tr><tr><td><code>RGBLIGHT_SPLIT</code></td><td><em>Not defined</em></td><td>If defined, synchronization functionality for split keyboards is added</td></tr><tr><td><code>RGBLIGHT_DISABLE_KEYCODES</code></td><td><em>Not defined</em></td><td>If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature</td></tr><tr><td><code>RGBLIGHT_DEFAULT_MODE</code></td><td><code>RGBLIGHT_MODE_STATIC_LIGHT</code></td><td>The default mode to use upon clearing the EEPROM</td></tr><tr><td><code>RGBLIGHT_DEFAULT_HUE</code></td><td><code>0</code> (red)</td><td>The default hue to use upon clearing the EEPROM</td></tr><tr><td><code>RGBLIGHT_DEFAULT_SAT</code></td><td><code>UINT8_MAX</code> (255)</td><td>The default saturation to use upon clearing the EEPROM</td></tr><tr><td><code>RGBLIGHT_DEFAULT_VAL</code></td><td><code>RGBLIGHT_LIMIT_VAL</code></td><td>The default value (brightness) to use upon clearing the EEPROM</td></tr><tr><td><code>RGBLIGHT_DEFAULT_SPD</code></td><td><code>0</code></td><td>The default speed to use upon clearing the EEPROM</td></tr><tr><td><code>RGBLIGHT_DEFAULT_ON</code></td><td><code>true</code></td><td>Enable RGB lighting upon clearing the EEPROM</td></tr></tbody></table><h2 id="effects-and-animations" tabindex="-1">Effects and Animations <a class="header-anchor" href="#effects-and-animations" aria-label="Permalink to "Effects and Animations""></a></h2><p>Not only can this lighting be whatever color you want, if <code>RGBLIGHT_EFFECT_xxxx</code> is defined, you also have a number of animation modes at your disposal:</p><table><thead><tr><th>Mode number symbol</th><th>Additional number</th><th>Description</th></tr></thead><tbody><tr><td><code>RGBLIGHT_MODE_STATIC_LIGHT</code></td><td><em>None</em></td><td>Solid color (this mode is always enabled)</td></tr><tr><td><code>RGBLIGHT_MODE_BREATHING</code></td><td>0,1,2,3</td><td>Solid color breathing</td></tr><tr><td><code>RGBLIGHT_MODE_RAINBOW_MOOD</code></td><td>0,1,2</td><td>Cycling rainbow</td></tr><tr><td><code>RGBLIGHT_MODE_RAINBOW_SWIRL</code></td><td>0,1,2,3,4,5</td><td>Swirling rainbow</td></tr><tr><td><code>RGBLIGHT_MODE_SNAKE</code></td><td>0,1,2,3,4,5</td><td>Snake</td></tr><tr><td><code>RGBLIGHT_MODE_KNIGHT</code></td><td>0,1,2</td><td>Knight</td></tr><tr><td><code>RGBLIGHT_MODE_CHRISTMAS</code></td><td><em>None</em></td><td>Christmas</td></tr><tr><td><code>RGBLIGHT_MODE_STATIC_GRADIENT</code></td><td>0,1,..,9</td><td>Static gradient</td></tr><tr><td><code>RGBLIGHT_MODE_RGB_TEST</code></td><td><em>None</em></td><td>RGB Test</td></tr><tr><td><code>RGBLIGHT_MODE_ALTERNATING</code></td><td><em>None</em></td><td>Alternating</td></tr><tr><td><code>RGBLIGHT_MODE_TWINKLE</code></td><td>0,1,2,3,4,5</td><td>Twinkle</td></tr></tbody></table><p>Check out <a href="https://youtube.com/watch?v=VKrpPAHlisY" target="_blank" rel="noreferrer">this video</a> for a demonstration.</p><p>Note: For versions older than 0.6.117, The mode numbers were written directly. In <code>quantum/rgblight/rgblight.h</code> there is a contrast table between the old mode number and the current symbol.</p><h3 id="effect-and-animation-toggles" tabindex="-1">Effect and Animation Toggles <a class="header-anchor" href="#effect-and-animation-toggles" aria-label="Permalink to "Effect and Animation Toggles""></a></h3><p>Use these defines to add or remove animations from the firmware. When you are running low on flash space, it can be helpful to disable animations you are not using.</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>RGBLIGHT_ANIMATIONS</code></td><td><em>Not defined</em></td><td>Enable all additional animation modes. (deprecated)</td></tr><tr><td><code>RGBLIGHT_EFFECT_ALTERNATING</code></td><td><em>Not defined</em></td><td>Enable alternating animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_BREATHING</code></td><td><em>Not defined</em></td><td>Enable breathing animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_CHRISTMAS</code></td><td><em>Not defined</em></td><td>Enable christmas animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_KNIGHT</code></td><td><em>Not defined</em></td><td>Enable knight animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_RAINBOW_MOOD</code></td><td><em>Not defined</em></td><td>Enable rainbow mood animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_RAINBOW_SWIRL</code></td><td><em>Not defined</em></td><td>Enable rainbow swirl animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_RGB_TEST</code></td><td><em>Not defined</em></td><td>Enable RGB test animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_SNAKE</code></td><td><em>Not defined</em></td><td>Enable snake animation mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_STATIC_GRADIENT</code></td><td><em>Not defined</em></td><td>Enable static gradient mode.</td></tr><tr><td><code>RGBLIGHT_EFFECT_TWINKLE</code></td><td><em>Not defined</em></td><td>Enable twinkle animation mode.</td></tr></tbody></table><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p><code>RGBLIGHT_ANIMATIONS</code> is being deprecated and animation modes should be explicitly defined.</p></div><h3 id="effect-and-animation-settings" tabindex="-1">Effect and Animation Settings <a class="header-anchor" href="#effect-and-animation-settings" aria-label="Permalink to "Effect and Animation Settings""></a></h3><p>The following options are used to tweak the various animations:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>RGBLIGHT_EFFECT_BREATHE_CENTER</code></td><td><em>Not defined</em></td><td>If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7</td></tr><tr><td><code>RGBLIGHT_EFFECT_BREATHE_MAX</code></td><td><code>255</code></td><td>The maximum brightness for the breathing mode. Valid values are 1 to 255</td></tr><tr><td><code>RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL</code></td><td><code>40</code></td><td>How long (in milliseconds) to wait between animation steps for the "Christmas" animation</td></tr><tr><td><code>RGBLIGHT_EFFECT_CHRISTMAS_STEP</code></td><td><code>2</code></td><td>The number of LEDs to group the red/green colors by for the "Christmas" animation</td></tr><tr><td><code>RGBLIGHT_EFFECT_KNIGHT_LED_NUM</code></td><td><code>RGBLIGHT_LED_COUNT</code></td><td>The number of LEDs to have the "Knight" animation travel</td></tr><tr><td><code>RGBLIGHT_EFFECT_KNIGHT_LENGTH</code></td><td><code>3</code></td><td>The number of LEDs to light up for the "Knight" animation</td></tr><tr><td><code>RGBLIGHT_EFFECT_KNIGHT_OFFSET</code></td><td><code>0</code></td><td>The number of LEDs to start the "Knight" animation from the start of the strip by</td></tr><tr><td><code>RGBLIGHT_RAINBOW_SWIRL_RANGE</code></td><td><code>255</code></td><td>Range adjustment for the rainbow swirl effect to get different swirls</td></tr><tr><td><code>RGBLIGHT_EFFECT_SNAKE_LENGTH</code></td><td><code>4</code></td><td>The number of LEDs to light up for the "Snake" animation</td></tr><tr><td><code>RGBLIGHT_EFFECT_TWINKLE_LIFE</code></td><td><code>200</code></td><td>Adjusts how quickly each LED brightens and dims when twinkling (in animation steps)</td></tr><tr><td><code>RGBLIGHT_EFFECT_TWINKLE_PROBABILITY</code></td><td><code>1/127</code></td><td>Adjusts how likely each LED is to twinkle (on each animation step)</td></tr></tbody></table><h3 id="example-usage-to-reduce-memory-footprint" tabindex="-1">Example Usage to Reduce Memory Footprint <a class="header-anchor" href="#example-usage-to-reduce-memory-footprint" aria-label="Permalink to "Example Usage to Reduce Memory Footprint""></a></h3><ol><li>Use <code>#undef</code> to selectively disable animations. The following would disable two animations and save about 4KiB:</li></ol><div class="language-diff vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">diff</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> #undef RGBLIGHT_LED_COUNT</span></span>\n<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">+#undef RGBLIGHT_EFFECT_STATIC_GRADIENT</span></span>\n<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">+#undef RGBLIGHT_EFFECT_RAINBOW_SWIRL</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> #define RGBLIGHT_LED_COUNT 12</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> #define RGBLIGHT_HUE_STEP 8</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> #define RGBLIGHT_SAT_STEP 8</span></span></code></pre></div><h3 id="animation-speed" tabindex="-1">Animation Speed <a class="header-anchor" href="#animation-speed" aria-label="Permalink to "Animation Speed""></a></h3><p>You can also modify the speeds that the different modes animate at:</p><p>Here is a quick demo on Youtube (with NPKC KC60) (<a href="https://www.youtube.com/watch?v=VKrpPAHlisY" target="_blank" rel="noreferrer">https://www.youtube.com/watch?v=VKrpPAHlisY</a>).</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Solid color breathing" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_BREATHING_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">30</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Cycling rainbow" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_RAINBOW_MOOD_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">120</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">60</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">30</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Swirling rainbow" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_RAINBOW_SWIRL_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">100</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Snake" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_SNAKE_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">100</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Knight" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_KNIGHT_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">127</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">63</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">31</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// How long (in milliseconds) to wait between animation steps for each of the "Twinkle" animations</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_TWINKLE_INTERVALS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">25</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// These control which hues are selected for each of the "Static gradient" modes</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> uint8_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> RGBLED_GRADIENT_RANGES</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">255</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">170</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">127</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">85</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">64</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">};</span></span></code></pre></div><h2 id="lighting-layers" tabindex="-1">Lighting Layers <a class="header-anchor" href="#lighting-layers" aria-label="Permalink to "Lighting Layers""></a></h2><div class="tip custom-block"><p class="custom-block-title">TIP</p><p><strong>Note:</strong> Lighting Layers is an RGB Light feature, it will not work for RGB Matrix. See <a href="./rgb_matrix#indicators">RGB Matrix Indicators</a> for details on how to do so.</p></div><p>By including <code>#define RGBLIGHT_LAYERS</code> in your <code>config.h</code> file you can enable lighting layers. These make it easy to use your underglow LEDs as status indicators to show which keyboard layer is currently active, or the state of caps lock, all without disrupting any animations. <a href="https://youtu.be/uLGE1epbmdY" target="_blank" rel="noreferrer">Here's a video</a> showing an example of what you can do.</p><h3 id="defining-lighting-layers" tabindex="-1">Defining Lighting Layers <a class="header-anchor" href="#defining-lighting-layers" aria-label="Permalink to "Defining Lighting Layers {#defining-lighting-layers}""></a></h3><p>By default, 8 layers are possible. This can be expanded to as many as 32 by overriding the definition of <code>RGBLIGHT_MAX_LAYERS</code> in <code>config.h</code> (e.g. <code>#define RGBLIGHT_MAX_LAYERS 32</code>). Please note, if you use a split keyboard, you will need to flash both sides of the split after changing this. Also, increasing the maximum will increase the firmware size, and will slow sync on split keyboards.</p><p>To define a layer, we modify <code>keymap.c</code> to list the LED ranges and the colors we want to overlay on them using an array of <code>rgblight_segment_t</code> using the <code>RGBLIGHT_LAYER_SEGMENTS</code> macro. We can define multiple layers and enable/disable them independently:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Light LEDs 6 to 9 and 12 to 15 red when caps lock is active. Hard to ignore!</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM my_capslock_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_RED},</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Light 4 LEDs, starting with LED 6</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">12</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_RED}</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Light 4 LEDs, starting with LED 12</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Light LEDs 9 & 10 in cyan when keyboard layer 1 is active</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM my_layer1_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">9</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_CYAN}</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Light LEDs 11 & 12 in purple when keyboard layer 2 is active</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM my_layer2_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">11</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_PURPLE}</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Light LEDs 13 & 14 in green when keyboard layer 3 is active</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM my_layer3_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">13</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_GREEN}</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// etc..</span></span></code></pre></div><p>We combine these layers into an array using the <code>RGBLIGHT_LAYERS_LIST</code> macro, and assign it to the <code>rgblight_layers</code> variable during keyboard setup. Note that you can only define up to 8 lighting layers. Any extra layers will be ignored. Since the different lighting layers overlap, the order matters in the array, with later layers taking precedence:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Now define the array of layers. Later layers take precedence</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM my_rgb_layers</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYERS_LIST</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_capslock_layer,</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_layer1_layer,</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Overrides caps lock layer</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_layer2_layer,</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Overrides other layers</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_layer3_layer</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Overrides other layers</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> keyboard_post_init_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Enable the LED layers</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> rgblight_layers </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> my_rgb_layers;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>Note: For split keyboards with two controllers, both sides need to be flashed when updating the contents of rgblight_layers.</p><h3 id="enabling-lighting-layers" tabindex="-1">Enabling and disabling lighting layers <a class="header-anchor" href="#enabling-lighting-layers" aria-label="Permalink to "Enabling and disabling lighting layers {#enabling-lighting-layers}""></a></h3><p>Everything above just configured the definition of each lighting layer. We can now enable and disable the lighting layers whenever the state of the keyboard changes:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> led_update_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">led_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> led_state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_set_layer_state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, led_state.caps_lock);</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">layer_state_t</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> default_layer_state_set_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">layer_state_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_set_layer_state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">layer_state_cmp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(state, _DVORAK));</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> state;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">layer_state_t</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> layer_state_set_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">layer_state_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_set_layer_state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">layer_state_cmp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(state, _FN));</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_set_layer_state</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">layer_state_cmp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(state, _ADJUST));</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> state;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h3 id="lighting-layer-blink" tabindex="-1">Lighting layer blink <a class="header-anchor" href="#lighting-layer-blink" aria-label="Permalink to "Lighting layer blink {#lighting-layer-blink}""></a></h3><p>By including <code>#define RGBLIGHT_LAYER_BLINK</code> in your <code>config.h</code> file you can turn a lighting layer on for a specified duration. Once the specified number of milliseconds has elapsed the layer will be turned off. This is useful, e.g., if you want to acknowledge some action (e.g. toggling some setting):</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM _yes_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">( {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">9</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_GREEN} );</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM _no_layer</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYER_SEGMENTS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">( {</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">9</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, HSV_RED} );</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">const</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> rgblight_segment_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> const</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PROGMEM _rgb_layers</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LAYERS_LIST</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">( _yes_layer, _no_layer );</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> keyboard_post_init_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> rgblight_layers </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _rgb_layers;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Note we user post_process_record_user because we want the state</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// after the flag has been flipped...</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> post_process_record_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> QK_DEBUG_TOGGLE:</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_blink_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(debug_enable </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> :</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">500</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> NK_TOGG:</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> NK_ON:</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> NK_OFF:</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_blink_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(keymap_config.nkro </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> :</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">500</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>You can also use <code>rgblight_blink_layer_repeat</code> to specify the amount of times the layer is supposed to blink. Using the layers from above,</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> post_process_record_user</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint16_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> keycode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">keyrecord_t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">record</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> switch</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (keycode) {</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> QK_DEBUG_TOGGLE:</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> rgblight_blink_layer_repeat</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(debug_enable </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> :</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">200</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>would turn the layer 0 (or 1) on and off again three times when <code>DB_TOGG</code> is pressed.</p><p>Blinking accumulates layers so if multiple layers are set blinking at the same time they will all blink for the duration and repeat times of the last layer to be blinked. To stop these other layers from blinking use <code>rgblight_unblink_layer</code> or <code>rgblight_unblink_all_but_layer</code>:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_blink_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">500</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_unblink_all_but_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_unblink_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_blink_layer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">500</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>Lighting layers on split keyboards will require layer state synced to the slave half (e.g. <code>#define SPLIT_LAYER_STATE_ENABLE</code>). See <a href="./split_keyboard#data-sync-options">data sync options</a> for more details.</p></div><h3 id="overriding-rgb-lighting-on-off-status" tabindex="-1">Overriding RGB Lighting on/off status <a class="header-anchor" href="#overriding-rgb-lighting-on-off-status" aria-label="Permalink to "Overriding RGB Lighting on/off status""></a></h3><p>Normally lighting layers are not shown when RGB Lighting is disabled (e.g. with <code>RGB_TOG</code> keycode). If you would like lighting layers to work even when the RGB Lighting is otherwise off, add <code>#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF</code> to your <code>config.h</code>.</p><h3 id="retain-brightness" tabindex="-1">Retain brightness <a class="header-anchor" href="#retain-brightness" aria-label="Permalink to "Retain brightness""></a></h3><p>Usually lighting layers apply their configured brightness once activated. If you would like lighting layers to retain the currently used brightness (as returned by <code>rgblight_get_val()</code>), add <code>#define RGBLIGHT_LAYERS_RETAIN_VAL</code> to your <code>config.h</code>.</p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to "Functions""></a></h2><p>If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See <a href="https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight/rgblight.h" target="_blank" rel="noreferrer"><code>rgblight.h</code></a> for the full list, but the most commonly used functions include:</p><h3 id="low-level-functions" tabindex="-1">Low level Functions <a class="header-anchor" href="#low-level-functions" aria-label="Permalink to "Low level Functions""></a></h3><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_set()</code></td><td>Flush out led buffers to LEDs</td></tr><tr><td><code>rgblight_set_clipping_range(pos, num)</code></td><td>Set clipping Range. see <a href="#clipping-range">Clipping Range</a></td></tr></tbody></table><h3 id="effects-and-animations-functions" tabindex="-1">Effects and Animations Functions <a class="header-anchor" href="#effects-and-animations-functions" aria-label="Permalink to "Effects and Animations Functions""></a></h3><h4 id="effect-range-setting" tabindex="-1">effect range setting <a class="header-anchor" href="#effect-range-setting" aria-label="Permalink to "effect range setting""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_set_effect_range(pos, num)</code></td><td>Set Effects Range</td></tr></tbody></table><h4 id="direct-operation" tabindex="-1">direct operation <a class="header-anchor" href="#direct-operation" aria-label="Permalink to "direct operation""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_setrgb_at(r, g, b, index)</code></td><td>Set a single LED to the given RGB value, where <code>r</code>/<code>g</code>/<code>b</code> are between 0 and 255 and <code>index</code> is between 0 and <code>RGBLIGHT_LED_COUNT</code> (not written to EEPROM)</td></tr><tr><td><code>rgblight_sethsv_at(h, s, v, index)</code></td><td>Set a single LED to the given HSV value, where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255, and <code>index</code> is between 0 and <code>RGBLIGHT_LED_COUNT</code> (not written to EEPROM)</td></tr><tr><td><code>rgblight_setrgb_range(r, g, b, start, end)</code></td><td>Set a continuous range of LEDs to the given RGB value, where <code>r</code>/<code>g</code>/<code>b</code> are between 0 and 255 and <code>start</code>(included) and <code>stop</code>(excluded) are between 0 and <code>RGBLIGHT_LED_COUNT</code> (not written to EEPROM)</td></tr><tr><td><code>rgblight_sethsv_range(h, s, v, start, end)</code></td><td>Set a continuous range of LEDs to the given HSV value, where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255, and <code>start</code>(included) and <code>stop</code>(excluded) are between 0 and <code>RGBLIGHT_LED_COUNT</code> (not written to EEPROM)</td></tr><tr><td><code>rgblight_setrgb(r, g, b)</code></td><td>Set effect range LEDs to the given RGB value where <code>r</code>/<code>g</code>/<code>b</code> are between 0 and 255 (not written to EEPROM)</td></tr><tr><td><code>rgblight_setrgb_master(r, g, b)</code></td><td>Set the LEDs on the master side to the given RGB value, where <code>r</code>/<code>g</code>/<code>b</code> are between 0 and 255 (not written to EEPROM)</td></tr><tr><td><code>rgblight_setrgb_slave(r, g, b)</code></td><td>Set the LEDs on the slave side to the given RGB value, where <code>r</code>/<code>g</code>/<code>b</code> are between 0 and 255 (not written to EEPROM)</td></tr><tr><td><code>rgblight_sethsv_master(h, s, v)</code></td><td>Set the LEDs on the master side to the given HSV value, where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255 (not written to EEPROM)</td></tr><tr><td><code>rgblight_sethsv_slave(h, s, v)</code></td><td>Set the LEDs on the slave side to the given HSV value, where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255 (not written to EEPROM)</td></tr></tbody></table><p>Example:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_sethsv_at</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(HSV_WHITE, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // led 0</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_sethsv_at</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(HSV_RED, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // led 1</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_sethsv_at</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(HSV_GREEN, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // led 2</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// The above functions automatically calls rgblight_set(), so there is no need to call it explicitly.</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Note that it is inefficient to call repeatedly.</span></span></code></pre></div><h4 id="effect-mode-change" tabindex="-1">effect mode change <a class="header-anchor" href="#effect-mode-change" aria-label="Permalink to "effect mode change""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_mode(x)</code></td><td>Set the mode, if RGB animations are enabled</td></tr><tr><td><code>rgblight_mode_noeeprom(x)</code></td><td>Set the mode, if RGB animations are enabled (not written to EEPROM)</td></tr><tr><td><code>rgblight_step()</code></td><td>Change the mode to the next RGB animation in the list of enabled RGB animations</td></tr><tr><td><code>rgblight_step_noeeprom()</code></td><td>Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM)</td></tr><tr><td><code>rgblight_step_reverse()</code></td><td>Change the mode to the previous RGB animation in the list of enabled RGB animations</td></tr><tr><td><code>rgblight_step_reverse_noeeprom()</code></td><td>Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM)</td></tr><tr><td><code>rgblight_reload_from_eeprom()</code></td><td>Reload the effect configuration (enabled, mode and color) from EEPROM</td></tr></tbody></table><h4 id="effects-mode-disable-enable" tabindex="-1">effects mode disable/enable <a class="header-anchor" href="#effects-mode-disable-enable" aria-label="Permalink to "effects mode disable/enable""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_toggle()</code></td><td>Toggle effect range LEDs between on and off</td></tr><tr><td><code>rgblight_toggle_noeeprom()</code></td><td>Toggle effect range LEDs between on and off (not written to EEPROM)</td></tr><tr><td><code>rgblight_enable()</code></td><td>Turn effect range LEDs on, based on their previous state</td></tr><tr><td><code>rgblight_enable_noeeprom()</code></td><td>Turn effect range LEDs on, based on their previous state (not written to EEPROM)</td></tr><tr><td><code>rgblight_disable()</code></td><td>Turn effect range LEDs off</td></tr><tr><td><code>rgblight_disable_noeeprom()</code></td><td>Turn effect range LEDs off (not written to EEPROM)</td></tr></tbody></table><h4 id="hue-sat-val-change" tabindex="-1">hue, sat, val change <a class="header-anchor" href="#hue-sat-val-change" aria-label="Permalink to "hue, sat, val change""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_increase_hue()</code></td><td>Increase the hue for effect range LEDs. This wraps around at maximum hue</td></tr><tr><td><code>rgblight_increase_hue_noeeprom()</code></td><td>Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM)</td></tr><tr><td><code>rgblight_decrease_hue()</code></td><td>Decrease the hue for effect range LEDs. This wraps around at minimum hue</td></tr><tr><td><code>rgblight_decrease_hue_noeeprom()</code></td><td>Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM)</td></tr><tr><td><code>rgblight_increase_sat()</code></td><td>Increase the saturation for effect range LEDs. This stops at maximum saturation</td></tr><tr><td><code>rgblight_increase_sat_noeeprom()</code></td><td>Increase the saturation for effect range LEDs. This stops at maximum saturation (not written to EEPROM)</td></tr><tr><td><code>rgblight_decrease_sat()</code></td><td>Decrease the saturation for effect range LEDs. This stops at minimum saturation</td></tr><tr><td><code>rgblight_decrease_sat_noeeprom()</code></td><td>Decrease the saturation for effect range LEDs. This stops at minimum saturation (not written to EEPROM)</td></tr><tr><td><code>rgblight_increase_val()</code></td><td>Increase the value for effect range LEDs. This stops at maximum value</td></tr><tr><td><code>rgblight_increase_val_noeeprom()</code></td><td>Increase the value for effect range LEDs. This stops at maximum value (not written to EEPROM)</td></tr><tr><td><code>rgblight_decrease_val()</code></td><td>Decrease the value for effect range LEDs. This stops at minimum value</td></tr><tr><td><code>rgblight_decrease_val_noeeprom()</code></td><td>Decrease the value for effect range LEDs. This stops at minimum value (not written to EEPROM)</td></tr><tr><td><code>rgblight_sethsv(h, s, v)</code></td><td>Set effect range LEDs to the given HSV value where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255</td></tr><tr><td><code>rgblight_sethsv_noeeprom(h, s, v)</code></td><td>Set effect range LEDs to the given HSV value where <code>h</code>/<code>s</code>/<code>v</code> are between 0 and 255 (not written to EEPROM)</td></tr></tbody></table><h4 id="speed-functions" tabindex="-1">Speed functions <a class="header-anchor" href="#speed-functions" aria-label="Permalink to "Speed functions""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_increase_speed()</code></td><td>Increases the animation speed</td></tr><tr><td><code>rgblight_increase_speed_noeeprom()</code></td><td>Increases the animation speed (not written to EEPROM)</td></tr><tr><td><code>rgblight_decrease_speed()</code></td><td>Decreases the animation speed</td></tr><tr><td><code>rgblight_decrease_speed_noeeprom()</code></td><td>Decreases the animation speed (not written to EEPROM)</td></tr><tr><td><code>rgblight_set_speed()</code></td><td>Sets the speed. Value is between 0 and 255</td></tr><tr><td><code>rgblight_set_speed_noeeprom()</code></td><td>Sets the speed. Value is between 0 and 255 (not written to EEPROM)</td></tr></tbody></table><h4 id="layer-functions" tabindex="-1">layer functions <a class="header-anchor" href="#layer-functions" aria-label="Permalink to "layer functions""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_get_layer_state(i)</code></td><td>Returns <code>true</code> if lighting layer <code>i</code> is enabled</td></tr><tr><td><code>rgblight_set_layer_state(i, is_on)</code></td><td>Enable or disable lighting layer <code>i</code> based on value of <code>bool is_on</code></td></tr></tbody></table><h4 id="query" tabindex="-1">query <a class="header-anchor" href="#query" aria-label="Permalink to "query""></a></h4><table><thead><tr><th>Function</th><th>Description</th></tr></thead><tbody><tr><td><code>rgblight_is_enabled()</code></td><td>Gets current on/off status</td></tr><tr><td><code>rgblight_get_mode()</code></td><td>Gets current mode</td></tr><tr><td><code>rgblight_get_hue()</code></td><td>Gets current hue</td></tr><tr><td><code>rgblight_get_sat()</code></td><td>Gets current sat</td></tr><tr><td><code>rgblight_get_val()</code></td><td>Gets current val</td></tr><tr><td><code>rgblight_get_speed()</code></td><td>Gets current speed</td></tr></tbody></table><h2 id="colors" tabindex="-1">Colors <a class="header-anchor" href="#colors" aria-label="Permalink to "Colors""></a></h2><p>These are shorthands to popular colors. The <code>RGB</code> ones can be passed to the <code>setrgb</code> functions, while the <code>HSV</code> ones to the <code>sethsv</code> functions.</p><table><thead><tr><th>RGB</th><th>HSV</th></tr></thead><tbody><tr><td><code>RGB_AZURE</code></td><td><code>HSV_AZURE</code></td></tr><tr><td><code>RGB_BLACK</code>/<code>RGB_OFF</code></td><td><code>HSV_BLACK</code>/<code>HSV_OFF</code></td></tr><tr><td><code>RGB_BLUE</code></td><td><code>HSV_BLUE</code></td></tr><tr><td><code>RGB_CHARTREUSE</code></td><td><code>HSV_CHARTREUSE</code></td></tr><tr><td><code>RGB_CORAL</code></td><td><code>HSV_CORAL</code></td></tr><tr><td><code>RGB_CYAN</code></td><td><code>HSV_CYAN</code></td></tr><tr><td><code>RGB_GOLD</code></td><td><code>HSV_GOLD</code></td></tr><tr><td><code>RGB_GOLDENROD</code></td><td><code>HSV_GOLDENROD</code></td></tr><tr><td><code>RGB_GREEN</code></td><td><code>HSV_GREEN</code></td></tr><tr><td><code>RGB_MAGENTA</code></td><td><code>HSV_MAGENTA</code></td></tr><tr><td><code>RGB_ORANGE</code></td><td><code>HSV_ORANGE</code></td></tr><tr><td><code>RGB_PINK</code></td><td><code>HSV_PINK</code></td></tr><tr><td><code>RGB_PURPLE</code></td><td><code>HSV_PURPLE</code></td></tr><tr><td><code>RGB_RED</code></td><td><code>HSV_RED</code></td></tr><tr><td><code>RGB_SPRINGGREEN</code></td><td><code>HSV_SPRINGGREEN</code></td></tr><tr><td><code>RGB_TEAL</code></td><td><code>HSV_TEAL</code></td></tr><tr><td><code>RGB_TURQUOISE</code></td><td><code>HSV_TURQUOISE</code></td></tr><tr><td><code>RGB_WHITE</code></td><td><code>HSV_WHITE</code></td></tr><tr><td><code>RGB_YELLOW</code></td><td><code>HSV_YELLOW</code></td></tr></tbody></table><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_setrgb</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(RGB_ORANGE);</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_sethsv_noeeprom</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(HSV_GREEN);</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_setrgb_at</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(RGB_GOLD, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_sethsv_range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(HSV_WHITE, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><p>These are defined in <a href="https://github.com/qmk/qmk_firmware/blob/master/quantum/color.h" target="_blank" rel="noreferrer"><code>color.h</code></a>. Feel free to add to this list!</p><h2 id="changing-the-order-of-the-leds" tabindex="-1">Changing the order of the LEDs <a class="header-anchor" href="#changing-the-order-of-the-leds" aria-label="Permalink to "Changing the order of the LEDs""></a></h2><p>If you want to make the logical order of LEDs different from the electrical connection order, you can do this by defining the <code>RGBLIGHT_LED_MAP</code> macro in your <code>config.h</code>.</p><p>Normally, the contents of the LED buffer are output to the LEDs in the same order. <img src="https://user-images.githubusercontent.com/2170248/55743718-01866c80-5a6e-11e9-8134-25419928327a.JPG" alt="simple dicrect" width="50%"></p><p>By defining <code>RGBLIGHT_LED_MAP</code> as in the example below, you can specify the LED with addressing in reverse order of the electrical connection order.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// config.h</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LED_COUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 4</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LED_MAP</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span></code></pre></div><img src="https://user-images.githubusercontent.com/2170248/55743725-08ad7a80-5a6e-11e9-83ed-126a2b0209fc.JPG" alt="simple mapped" width="50%"><h2 id="clipping-range" tabindex="-1">Clipping Range <a class="header-anchor" href="#clipping-range" aria-label="Permalink to "Clipping Range""></a></h2><p>Using the <code>rgblight_set_clipping_range()</code> function, you can prepare more buffers than the actual number of LEDs, and output some of the buffers to the LEDs. This is useful if you want the split keyboard to treat left and right LEDs as logically contiguous.</p><p>You can set the Clipping Range by executing the following code.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// some source</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_set_clipping_range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><img src="https://user-images.githubusercontent.com/2170248/55743785-2bd82a00-5a6e-11e9-9d4b-1b4ffaf4932b.JPG" alt="clip direct" width="70%"><p>In addition to setting the Clipping Range, you can use <code>RGBLIGHT_LED_MAP</code> together.</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// config.h</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LED_COUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 8</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> RGBLIGHT_LED_MAP</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">7</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// some source</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rgblight_set_clipping_range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><img src="https://user-images.githubusercontent.com/2170248/55743747-119e4c00-5a6e-11e9-91e5-013203ffae8a.JPG" alt="clip mapped" width="70%"><h2 id="hardware-modification" tabindex="-1">Hardware Modification <a class="header-anchor" href="#hardware-modification" aria-label="Permalink to "Hardware Modification""></a></h2><p>If your keyboard lacks onboard underglow LEDs, you may often be able to solder on an RGB LED strip yourself. You will need to find an unused pin to wire to the data pin of your LED strip. Some keyboards may break out unused pins from the MCU to make soldering easier. The other two pins, VCC and GND, must also be connected to the appropriate power pins.</p><h2 id="velocikey" tabindex="-1">Velocikey <a class="header-anchor" href="#velocikey" aria-label="Permalink to "Velocikey""></a></h2><p>Velocikey is a feature that lets you control the speed of lighting effects (like the Rainbow Swirl effect) with the speed of your typing. The faster you type, the faster the lights will go!</p><h3 id="usage-1" tabindex="-1">Usage <a class="header-anchor" href="#usage-1" aria-label="Permalink to "Usage""></a></h3><p>For Velocikey to take effect, there are two steps. First, when compiling your keyboard, you'll need to set <code>VELOCIKEY_ENABLE=yes</code> in <code>rules.mk</code>, e.g.:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>MOUSEKEY_ENABLE = no</span></span>\n<span class="line"><span>STENO_ENABLE = no</span></span>\n<span class="line"><span>EXTRAKEY_ENABLE = yes</span></span>\n<span class="line"><span>VELOCIKEY_ENABLE = yes</span></span></code></pre></div><p>Then, while using your keyboard, you need to also turn it on with the <code>VK_TOGG</code> keycode, which toggles the feature on and off.</p><p>The following light effects will all be controlled by Velocikey when it is enabled:</p><ul><li>RGB Breathing</li><li>RGB Rainbow Mood</li><li>RGB Rainbow Swirl</li><li>RGB Snake</li><li>RGB Knight</li></ul><p>Support for LED breathing effects is planned but not available yet.</p><p>As long as Velocikey is enabled, it will control the speed regardless of any other speed setting that your RGB lights are currently on.</p><h3 id="configuration-1" tabindex="-1">Configuration <a class="header-anchor" href="#configuration-1" aria-label="Permalink to "Configuration""></a></h3><p>Velocikey doesn't currently support any configuration via keyboard settings. If you want to adjust something like the speed increase or decay rate, you would need to edit <code>velocikey.c</code> and adjust the values there to achieve the kinds of speeds that you like.</p>', 130);
|
||
const _hoisted_131 = [
|
||
_hoisted_1
|
||
];
|
||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
return openBlock(), createElementBlock("div", null, _hoisted_131);
|
||
}
|
||
const rgblight = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||
export {
|
||
__pageData,
|
||
rgblight as default
|
||
};
|