aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2019-05-16 13:11:28 +0900
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-05-15 21:11:28 -0700
commit670a9b7f83dacf2b0e9fb42756935a77598c6677 (patch)
treee265e0b8f4dbc2df2e0eff45c474a3ce9423b122 /docs
parentacd3e79add2d47ab664b831936e5b6e71d3b8e15 (diff)
downloadqmk_firmware-670a9b7f83dacf2b0e9fb42756935a77598c6677.tar.gz
qmk_firmware-670a9b7f83dacf2b0e9fb42756935a77598c6677.zip
Add effect range to rgblight.c (#5856)
* add rgblight_set_effect_range() * implement effect range * Arrange the order of function list in rgblight.h . * update docs/feature_rgblight.md * fix RGBLIGHT_RAINBOW_SWIRL_RANGE default value * add example code about Utility Functions * add example code about direct operation functions * When RGBLIGHT_SPLIT is defined, the following function has no meaning and is invalidated. * rgblight_setrgb_master(r, g, b) * rgblight_setrgb_slave(r, g, b) * rgblight_sethsv_master(h, s, v) * rgblight_sethsv_slave(h, s, v) * add temporary test code for rgblight_set_effect_range * fix rgblight_effect_knight() bug * Test End. Revert "add temporary test code for rgblight_set_effect_range" This reverts commit 5680cddd012d68b2db75a532862a7fef250f8973.
Diffstat (limited to 'docs')
-rw-r--r--docs/feature_rgblight.md134
1 files changed, 96 insertions, 38 deletions
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md
index 1e0ce9147..be4ddfa72 100644
--- a/docs/feature_rgblight.md
+++ b/docs/feature_rgblight.md
@@ -129,7 +129,7 @@ The following options are used to tweak the various animations:
129|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLED_NUM` |The number of LEDs to have the "Knight" animation travel | 129|`RGBLIGHT_EFFECT_KNIGHT_LED_NUM` |`RGBLED_NUM` |The number of LEDs to have the "Knight" animation travel |
130|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation | 130|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation |
131|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by | 131|`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by |
132|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`360` |Range adjustment for the rainbow swirl effect to get different swirls | 132|`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls |
133|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | 133|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation |
134 134
135### Example Usage to Reduce Memory Footprint 135### Example Usage to Reduce Memory Footprint
@@ -176,44 +176,100 @@ const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
176 176
177If 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 [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include: 177If 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 [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include:
178 178
179|Function |Description | 179### Utility Functions
180|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| 180|Function |Description |
181|`rgblight_enable()` |Turn LEDs on, based on their previous state | 181|--------------------------------------------|-------------------------------------------------------------------|
182|`rgblight_enable_noeeprom()` |Turn LEDs on, based on their previous state (not written to EEPROM) | 182|`sethsv(hue, sat, val, ledbuf)` |Set ledbuf to the given HSV value |
183|`rgblight_disable()` |Turn LEDs off | 183|`sethsv_raw(hue, sat, val, ledbuf)` |Set ledbuf to the given HSV value without RGBLIGHT_LIMIT_VAL check |
184|`rgblight_disable_noeeprom()` |Turn LEDs off (not written to EEPROM) | 184|`setrgb(r, g, b, ledbuf)` |Set ledbuf to the given RGB value where `r`/`g`/`b` |
185|`rgblight_mode(x)` |Set the mode, if RGB animations are enabled | 185
186|`rgblight_mode_noeeprom(x)` |Set the mode, if RGB animations are enabled (not written to EEPROM) | 186### Low level Functions
187|`rgblight_setrgb(r, g, b)` |Set all LEDs to the given RGB value where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) | 187|Function |Description |
188|`rgblight_setrgb_at(r, g, b, led)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `led` is between 0 and `RGBLED_NUM` (not written to EEPROM) | 188|--------------------------------------------|-------------------------------------------|
189|`rgblight_set()` |Flash out led buffers to LEDs |
190|`rgblight_set_clipping_range(pos, num)` |Set clipping Range. see [Clipping Range](#clipping-range) |
191
192Example:
193```c
194sethsv(HSV_WHITE, (LED_TYPE *)&led[0]); // led 0
195sethsv(HSV_RED, (LED_TYPE *)&led[1]); // led 1
196sethsv(HSV_GREEN, (LED_TYPE *)&led[2]); // led 2
197rgblight_set(); // Utility functions do not call rgblight_set() automatically, so they need to be called explicitly.
198```
199
200### Effects and Animations Functions
201#### effect range setting
202|Function |Description |
203|--------------------------------------------|------------------|
204|`rgblight_set_effect_range(pos, num)` |Set Effects Range |
205
206#### direct operation
207|Function |Description |
208|--------------------------------------------|-------------|
209|`rgblight_setrgb_at(r, g, b, index)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `index` is between 0 and `RGBLED_NUM` (not written to EEPROM) |
210|`rgblight_sethsv_at(h, s, v, index)` |Set a single LED to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `index` is between 0 and `RGBLED_NUM` (not written to EEPROM) |
189|`rgblight_setrgb_range(r, g, b, start, end)`|Set a continuous range of LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)| 211|`rgblight_setrgb_range(r, g, b, start, end)`|Set a continuous range of LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)|
190|`rgblight_setrgb_master(r, g, b)` |Set the LEDs on the master side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) | 212|`rgblight_sethsv_range(h, s, v, start, end)`|Set a continuous range of LEDs to the given HSV value, where `h`/`s`/`v` are between 0 and 255, and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)|
191|`rgblight_setrgb_slave(r, g, b)` |Set the LEDs on the slave side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) | 213|`rgblight_setrgb(r, g, b)` |Set effect range LEDs to the given RGB value where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
192|`rgblight_sethsv(h, s, v)` |Set all LEDs to the given HSV value where `h` is between 0 and 360 and `s`/`v` are between 0 and 255 | 214|`rgblight_setrgb_master(r, g, b)` |Set the LEDs on the master side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
193|`rgblight_sethsv_noeeprom(h, s, v)` |Set all LEDs to the given HSV value where `h` is between 0 and 360 and `s`/`v` are between 0 and 255 (not written to EEPROM) | 215|`rgblight_setrgb_slave(r, g, b)` |Set the LEDs on the slave side to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
194|`rgblight_sethsv_at(h, s, v, led)` |Set a single LED to the given HSV value, where `h` is between 0 and 360, `s`/`v` are between 0 and 255, and `led` is between 0 and `RGBLED_NUM` (not written to EEPROM)| 216|`rgblight_sethsv_master(h, s, v)` |Set the LEDs on the master side to the given HSV value, where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
195|`rgblight_sethsv_range(h, s, v, start, end)`|Set a continuous range of LEDs to the given HSV value, where `h` is between 0 and 360, `s`/`v` are between 0 and 255, and `start`(included) and `stop`(excluded) are between 0 and `RGBLED_NUM` (not written to EEPROM)| 217|`rgblight_sethsv_slave(h, s, v)` |Set the LEDs on the slave side to the given HSV value, where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
196|`rgblight_sethsv_master(h, s, v)` |Set the LEDs on the master side to the given HSV value, where `h` is between 0 and 360, `s`/`v` are between 0 and 255 (not written to EEPROM) | 218
197|`rgblight_sethsv_slave(h, s, v)` |Set the LEDs on the slave side to the given HSV value, where `h` is between 0 and 360, `s`/`v` are between 0 and 255 (not written to EEPROM) | 219Example:
198|`rgblight_toggle()` |Toggle all LEDs between on and off | 220```c
199|`rgblight_toggle_noeeprom()` |Toggle all LEDs between on and off (not written to EEPROM) | 221rgblight_sethsv(HSV_WHITE, 0); // led 0
200|`rgblight_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations | 222rgblight_sethsv(HSV_RED, 1); // led 1
201|`rgblight_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) | 223rgblight_sethsv(HSV_GREEN, 2); // led 2
202|`rgblight_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations | 224// The above functions automatically calls rgblight_set(), so there is no need to call it explicitly.
203|`rgblight_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) | 225// Note that it is inefficient to call repeatedly.
204|`rgblight_increase_hue()` |Increase the hue for all LEDs. This wraps around at maximum hue | 226```
205|`rgblight_increase_hue_noeeprom()` |Increase the hue for all LEDs. This wraps around at maximum hue (not written to EEPROM) | 227
206|`rgblight_decrease_hue()` |Decrease the hue for all LEDs. This wraps around at minimum hue | 228#### effect mode change
207|`rgblight_decrease_hue_noeeprom()` |Decrease the hue for all LEDs. This wraps around at minimum hue (not written to EEPROM) | 229|Function |Description |
208|`rgblight_increase_sat()` |Increase the saturation for all LEDs. This wraps around at maximum saturation | 230|--------------------------------------------|-------------|
209|`rgblight_increase_sat_noeeprom()` |Increase the saturation for all LEDs. This wraps around at maximum saturation (not written to EEPROM) | 231|`rgblight_mode(x)` |Set the mode, if RGB animations are enabled |
210|`rgblight_decrease_sat()` |Decrease the saturation for all LEDs. This wraps around at minimum saturation | 232|`rgblight_mode_noeeprom(x)` |Set the mode, if RGB animations are enabled (not written to EEPROM) |
211|`rgblight_decrease_sat_noeeprom()` |Decrease the saturation for all LEDs. This wraps around at minimum saturation (not written to EEPROM) | 233|`rgblight_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations |
212|`rgblight_increase_val()` |Increase the value for all LEDs. This wraps around at maximum value | 234|`rgblight_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) |
213|`rgblight_increase_val_noeeprom()` |Increase the value for all LEDs. This wraps around at maximum value (not written to EEPROM) | 235|`rgblight_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations |
214|`rgblight_decrease_val()` |Decrease the value for all LEDs. This wraps around at minimum value | 236|`rgblight_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) |
215|`rgblight_decrease_val_noeeprom()` |Decrease the value for all LEDs. This wraps around at minimum value (not written to EEPROM) | 237
216|`rgblight_set_clipping_range(pos, num)` |Set clipping Range | 238#### effects mode disable/enable
239|Function |Description |
240|--------------------------------------------|-------------|
241|`rgblight_toggle()` |Toggle effect range LEDs between on and off |
242|`rgblight_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
243|`rgblight_enable()` |Turn effect range LEDs on, based on their previous state |
244|`rgblight_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
245|`rgblight_disable()` |Turn effect range LEDs off |
246|`rgblight_disable_noeeprom()` |Turn effect range LEDs off (not written to EEPROM) |
247
248#### hue, sat, val change
249|Function |Description |
250|--------------------------------------------|-------------|
251|`rgblight_increase_hue()` |Increase the hue for effect range LEDs. This wraps around at maximum hue |
252|`rgblight_increase_hue_noeeprom()` |Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM) |
253|`rgblight_decrease_hue()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue |
254|`rgblight_decrease_hue_noeeprom()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM) |
255|`rgblight_increase_sat()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation |
256|`rgblight_increase_sat_noeeprom()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation (not written to EEPROM) |
257|`rgblight_decrease_sat()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation |
258|`rgblight_decrease_sat_noeeprom()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation (not written to EEPROM) |
259|`rgblight_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
260|`rgblight_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
261|`rgblight_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
262|`rgblight_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
263|`rgblight_sethsv(h, s, v)` |Set effect range LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 |
264|`rgblight_sethsv_noeeprom(h, s, v)` |Set effect range LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
265
266#### query
267|Function |Description |
268|-----------------------|-----------------|
269|`rgblight_get_mode()` |Get current mode |
270|`rgblight_get_hue()` |Get current hue |
271|`rgblight_get_sat()` |Get current sat |
272|`rgblight_get_val()` |Get current val |
217 273
218## Colors 274## Colors
219 275
@@ -324,4 +380,6 @@ In addition to setting the Clipping Range, you can use `RGBLIGHT_LED_MAP` togeth
324``` 380```
325<img src="https://user-images.githubusercontent.com/2170248/55743747-119e4c00-5a6e-11e9-91e5-013203ffae8a.JPG" alt="clip mapped" width="70%"/> 381<img src="https://user-images.githubusercontent.com/2170248/55743747-119e4c00-5a6e-11e9-91e5-013203ffae8a.JPG" alt="clip mapped" width="70%"/>
326 382
383## Hardware Modification
384
327If 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. 385If 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.