summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorWilliam Chang <william@factual.com>2019-05-09 21:16:15 -0700
committerWilliam Chang <william@factual.com>2019-05-09 21:16:15 -0700
commit9ce186860e78d5afe350636cb7445e18c2577f33 (patch)
treeb7f5dded777a950e63c4dd967260744336bfaa6b /docs
parent57a6ea11df685d84a1ea07953e88f224ce2b24f7 (diff)
parent4b2d3288d013b1a71ea25402224c4a8225a099e9 (diff)
Merge branch 'qmk-master'
Diffstat (limited to 'docs')
-rw-r--r--docs/_summary.md4
-rw-r--r--docs/config_options.md2
-rw-r--r--docs/feature_backlight.md52
-rw-r--r--docs/feature_macros.md2
-rw-r--r--docs/feature_rgb_matrix.md196
-rw-r--r--docs/feature_rgblight.md39
-rw-r--r--docs/feature_space_cadet.md59
-rw-r--r--docs/feature_space_cadet_shift.md37
-rw-r--r--docs/feature_space_cadet_shift_enter.md31
-rw-r--r--docs/feature_unicode.md83
-rw-r--r--docs/features.md2
-rw-r--r--docs/hand_wire.md12
-rw-r--r--docs/hardware_avr.md28
-rw-r--r--docs/keycodes.md16
-rw-r--r--docs/newbs_testing_debugging.md60
-rw-r--r--docs/porting_your_keyboard_to_qmk_(arm_and_other_chibios_cpus).md24
-rw-r--r--docs/zh-cn/README.md32
-rw-r--r--docs/zh-cn/_summary.md106
-rw-r--r--docs/zh-cn/getting_started_introduction.md54
-rw-r--r--docs/zh-cn/newbs_best_practices.md163
-rw-r--r--docs/zh-cn/newbs_building_firmware.md81
-rw-r--r--docs/zh-cn/newbs_flashing.md307
-rw-r--r--docs/zh-cn/newbs_getting_started.md102
-rw-r--r--docs/zh-cn/newbs_learn_more_resources.md15
-rw-r--r--docs/zh-cn/newbs_testing_debugging.md43
25 files changed, 1369 insertions, 181 deletions
diff --git a/docs/_summary.md b/docs/_summary.md
index c9d6c2bb14..043943f1d8 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -63,13 +63,13 @@
* [LED Matrix](feature_led_matrix.md)
* [Macros](feature_macros.md)
* [Mouse Keys](feature_mouse_keys.md)
+ * [OLED Driver](feature_oled_driver)
* [One Shot Keys](feature_advanced_keycodes.md#one-shot-keys)
* [Pointing Device](feature_pointing_device.md)
* [PS/2 Mouse](feature_ps2_mouse.md)
* [RGB Lighting](feature_rgblight.md)
* [RGB Matrix](feature_rgb_matrix.md)
- * [Space Cadet Shift](feature_space_cadet_shift.md)
- * [Space Cadet Shift Enter](feature_space_cadet_shift_enter.md)
+ * [Space Cadet](feature_space_cadet.md)
* [Stenography](feature_stenography.md)
* [Swap Hands](feature_swap_hands.md)
* [Tap Dance](feature_tap_dance.md)
diff --git a/docs/config_options.md b/docs/config_options.md
index 8f229a2cb8..3ef00394db 100644
--- a/docs/config_options.md
+++ b/docs/config_options.md
@@ -330,6 +330,8 @@ Use these to enable or disable building certain features. The more you have enab
* Forces the keyboard to wait for a USB connection to be established before it starts up
* `NO_USB_STARTUP_CHECK`
* Disables usb suspend check after keyboard startup. Usually the keyboard waits for the host to wake it up before any tasks are performed. This is useful for split keyboards as one half will not get a wakeup call but must send commands to the master.
+* `LINK_TIME_OPTIMIZATION_ENABLE`
+ = Enables Link Time Optimization (`LTO`) when compiling the keyboard. This makes the process take longer, but can significantly reduce the compiled size (and since the firmware is small, the added time is not noticable). However, this will automatically disable the old Macros and Functions features automatically, as these break when `LTO` is enabled. It does this by automatically defining `NO_ACTION_MACRO` and `NO_ACTION_FUNCTION`
## USB Endpoint Limitations
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md
index c7a1f131ed..048d75390d 100644
--- a/docs/feature_backlight.md
+++ b/docs/feature_backlight.md
@@ -30,7 +30,31 @@ You should then be able to use the keycodes below to change the backlight level.
This feature is distinct from both the [RGB underglow](feature_rgblight.md) and [RGB matrix](feature_rgb_matrix.md) features as it usually allows for only a single colour per switch, though you can obviously use multiple different coloured LEDs on a keyboard.
-Hardware PWM is only supported on certain pins of the MCU, so if the backlighting is not connected to one of them, a software implementation will be used, and backlight breathing will not be available. Currently the supported pins are `B5`, `B6`, `B7`, and `C6`.
+Hardware PWM is only supported on certain pins of the MCU, so if the backlighting is not connected to one of them, a software PWM implementation triggered by hardware timer interrupts will be used.
+
+Hardware PWM is supported according to the following table:
+
+| Backlight Pin | Hardware timer |
+|---------------|----------------|
+|`B5` | Timer 1 |
+|`B6` | Timer 1 |
+|`B7` | Timer 1 |
+|`C6` | Timer 3 |
+| other | Software PWM |
+
+The [audio feature](feature_audio.md) also uses hardware timers. Please refer to the following table to know what hardware timer the software PWM will use depending on the audio configuration:
+
+| Audio Pin(s) | Audio Timer | Software PWM Timer |
+|--------------|-------------|--------------------|
+| `C4` | Timer 3 | Timer 1 |
+| `C5` | Timer 3 | Timer 1 |
+| `C6` | Timer 3 | Timer 1 |
+| `B5` | Timer 1 | Timer 3 |
+| `B6` | Timer 1 | Timer 3 |
+| `B7` | Timer 1 | Timer 3 |
+| `Bx` & `Cx` | Timer 1 & 3 | None |
+
+When all timers are in use for [audio](feature_audio.md), the backlight software PWM will not use a hardware timer, but instead will be triggered during the matrix scan. In this case the backlight doesn't support breathing and might show lighting artifacts (for instance flickering), because the PWM computation might not be called with enough timing precision.
## Configuration
@@ -39,11 +63,26 @@ To change the behaviour of the backlighting, `#define` these in your `config.h`:
|Define |Default |Description |
|---------------------|-------------|-------------------------------------------------------------------------------------------------------------|
|`BACKLIGHT_PIN` |`B7` |The pin that controls the LEDs. Unless you are designing your own keyboard, you shouldn't need to change this|
+|`BACKLIGHT_PINS` |*Not defined*|experimental: see below for more information|
|`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 15 excluding off) |
|`BACKLIGHT_CAPS_LOCK`|*Not defined*|Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
-|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if hardware PWM is used |
+|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if supported |
|`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds |
+## Multiple backlight pins
+
+Most keyboards have only one backlight pin which control all backlight LEDs (especially if the backlight is connected to an hardware PWM pin).
+In software PWM, it is possible to define multiple backlight pins. All those pins will be turned on and off at the same time during the PWM duty cycle.
+This feature allows to set for instance the Caps Lock LED (or any other controllable LED) brightness at the same level as the other LEDs of the backlight. This is useful if you have mapped LCTRL in place of Caps Lock and you need the Caps Lock LED to be part of the backlight instead of being activated when Caps Lock is on.
+
+To activate multiple backlight pins, you need to add something like this to your user `config.h`:
+
+~~~c
+#define BACKLIGHT_LED_COUNT 2
+#undef BACKLIGHT_PIN
+#define BACKLIGHT_PINS { F5, B2 }
+~~~
+
## Hardware PWM Implementation
When using the supported pins for backlighting, QMK will use a hardware timer configured to output a PWM signal. This timer will count up to `ICRx` (by default `0xFFFF`) before resetting to 0.
@@ -53,6 +92,15 @@ In this way `OCRxx` essentially controls the duty cycle of the LEDs, and thus th
The breathing effect is achieved by registering an interrupt handler for `TIMER1_OVF_vect` that is called whenever the counter resets, roughly 244 times per second.
In this handler, the value of an incrementing counter is mapped onto a precomputed brightness curve. To turn off breathing, the interrupt handler is simply disabled, and the brightness reset to the level stored in EEPROM.
+## Software PWM Implementation
+
+When `BACKLIGHT_PIN` is not set to a hardware backlight pin, QMK will use a hardware timer configured to trigger software interrupts. This time will count up to `ICRx` (by default `0xFFFF`) before resetting to 0.
+When resetting to 0, the CPU will fire an OVF (overflow) interrupt that will turn the LEDs on, starting the duty cycle.
+The desired brightness is calculated and stored in the `OCRxx` register. When the counter reaches this value, the CPU will fire a Compare Output match interrupt, which will turn the LEDs off.
+In this way `OCRxx` essentially controls the duty cycle of the LEDs, and thus the brightness, where `0x0000` is completely off and `0xFFFF` is completely on.
+
+The breathing effect is the same as in the hardware PWM implementation.
+
## Backlight Functions
|Function |Description |
diff --git a/docs/feature_macros.md b/docs/feature_macros.md
index fe45016e3b..d81c3c6559 100644
--- a/docs/feature_macros.md
+++ b/docs/feature_macros.md
@@ -230,7 +230,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
void matrix_scan_user(void) { # The very important timer.
if (is_alt_tab_active) {
if (timer_elapsed(alt_tab_timer) > 1000) {
- unregister_code16(LALT(KC_TAB));
+ unregister_code(KC_LALT);
is_alt_tab_active = false;
}
}
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 05c1ebba81..1e43414676 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -124,30 +124,46 @@ Configure the hardware via your `config.h`:
---
-From this point forward the configuration is the same for all the drivers.
+From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example:
```C
-const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
-/* {row | col << 4}
- * | {x=0..224, y=0..64}
- * | | modifier
- * | | | */
- {{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
- {{0|(1<<4)}, {20.36*1, 21.33*0}, 1},
- ....
-}
+const led_config_t g_led_config = { {
+ // Key Matrix to LED Index
+ { 5, NO_LED, NO_LED, 0 },
+ { NO_LED, NO_LED, NO_LED, NO_LED },
+ { 4, NO_LED, NO_LED, 1 },
+ { 3, NO_LED, NO_LED, 2 }
+}, {
+ // LED Index to Physical Position
+ { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
+}, {
+ // LED Index to Flag
+ 1, 4, 4, 4, 4, 1
+} };
```
-The format for the matrix position used in this array is `{row | (col << 4)}`. The `x` is between (inclusive) 0-224, and `y` is between (inclusive) 0-64. The easiest way to calculate these positions is:
+The first part, `// Key Matrix to LED Index`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `// LED Index to Physical Position` represents the LED's physical position on the keyboard. The first value, `x`, is between 0-224 (inclusive), and the second value, `y`, is between 0-64 (inclusive). This range is due to effect that calculate the center or halves for their animations. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents x, y coordinate 0, 0 and the bottom right of your keyboard represents 224, 64. Using this as a basis, you can use the following formula to calculate the physical position:
```C
-x = 224 / ( NUMBER_OF_COLS - 1 ) * ROW_POSITION
-y = 64 / (NUMBER_OF_ROWS - 1 ) * COL_POSITION
+x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
+y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
```
-Where all variables are decimels/floats.
+Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.
+
+`// LED Index to Flag` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type.
-`modifier` is a boolean, whether or not a certain key is considered a modifier (used in some effects).
+## Flags
+
+|Define |Description |
+|------------------------------------|-------------------------------------------|
+|`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.|
+|`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.|
+|`#define LED_FLAG_NONE 0x00` |If this LED has no flags. |
+|`#define LED_FLAG_ALL 0xFF` |If this LED has all flags. |
+|`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. |
+|`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. |
+|`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. |
## Keycodes
@@ -177,7 +193,7 @@ enum rgb_matrix_effects {
RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes
RGB_MATRIX_BREATHING, // Single hue brightness cycling animation
RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient
- RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
+ RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right
RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
@@ -185,10 +201,19 @@ enum rgb_matrix_effects {
RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard
RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue
RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation
+#if define(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
+ RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM!
RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation
+#endif
#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out
RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue
+ RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
+ RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
+ RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
+ RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
+ RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
+ RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out
RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out
RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out
@@ -197,44 +222,123 @@ enum rgb_matrix_effects {
RGB_MATRIX_EFFECT_MAX
};
```
-
+
You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
-|Define |Description |
-|---------------------------------------------------|--------------------------------------------|
-|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
-|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
-|`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` |
-|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
-|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
-|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
-|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|
-|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
-|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
-|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
-|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
-|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
-|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
-|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
-|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLEE`|
-|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
-|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
-|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
-|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
-
-
-## Custom layer effects
-
-Custom layer effects can be done by defining this in your `<keyboard>.c`:
+|Define |Description |
+|-------------------------------------------------------|-----------------------------------------------|
+|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
+|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
+|`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` |
+|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
+|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
+|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
+|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |
+|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
+|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
+|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
+|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
+|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
+|`#define DISABLE_RGB_MATRIX_TYPING_HEATMAP` |Disables `RGB_MATRIX_TYPING_HEATMAP` |
+|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`|
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` |
+|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
+|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
+|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
+|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
+|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
+
+
+## Custom RGB Matrix Effects
+
+By setting `RGB_MATRIX_CUSTOM_USER` (and/or `RGB_MATRIX_CUSTOM_KB`) in `rule.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files.
+
+To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this:
+
+`rgb_matrix_user.inc` should go in the root of the keymap directory.
+`rgb_matrix_kb.inc` should go in the root of the keyboard directory.
```C
-void rgb_matrix_indicators_kb(void) {
- rgb_matrix_set_color(index, red, green, blue);
+// !!! DO NOT ADD #pragma once !!! //
+
+// Step 1.
+// Declare custom effects using the RGB_MATRIX_EFFECT macro
+// (note the lack of semicolon after the macro!)
+RGB_MATRIX_EFFECT(my_cool_effect)
+RGB_MATRIX_EFFECT(my_cool_effect2)
+
+// Step 2.
+// Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// e.g: A simple effect, self-contained within a single method
+static bool my_cool_effect(effect_params_t* params) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ rgb_matrix_set_color(i, 0xff, 0xff, 0x00);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+// e.g: A more complex effect, relying on external methods and state, with
+// dedicated init and run methods
+static uint8_t some_global_state;
+static void my_cool_effect2_complex_init(effect_params_t* params) {
+ some_global_state = 1;
+}
+static bool my_cool_effect2_complex_run(effect_params_t* params) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff);
+ }
+
+ return led_max < DRIVER_LED_TOTAL;
+}
+static bool my_cool_effect2(effect_params_t* params) {
+ if (params->init) my_cool_effect2_complex_init(params);
+ return my_cool_effect2_complex_run(params);
}
+
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
```
-A similar function works in the keymap as `rgb_matrix_indicators_user`.
+For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/`
+
+
+## Colors
+
+These are shorthands to popular colors. The `RGB` ones can be passed to the `setrgb` functions, while the `HSV` ones to the `sethsv` functions.
+
+|RGB |HSV |
+|-------------------|-------------------|
+|`RGB_WHITE` |`HSV_WHITE` |
+|`RGB_RED` |`HSV_RED` |
+|`RGB_CORAL` |`HSV_CORAL` |
+|`RGB_ORANGE` |`HSV_ORANGE` |
+|`RGB_GOLDENROD` |`HSV_GOLDENROD` |
+|`RGB_GOLD` |`HSV_GOLD` |
+|`RGB_YELLOW` |`HSV_YELLOW` |
+|`RGB_CHARTREUSE` |`HSV_CHARTREUSE` |
+|`RGB_GREEN` |`HSV_GREEN` |
+|`RGB_SPRINGGREEN` |`HSV_SPRINGGREEN` |
+|`RGB_TURQUOISE` |`HSV_TURQUOISE` |
+|`RGB_TEAL` |`HSV_TEAL` |
+|`RGB_CYAN` |`HSV_CYAN` |
+|`RGB_AZURE` |`HSV_AZURE` |
+|`RGB_BLUE` |`HSV_BLUE` |
+|`RGB_PURPLE` |`HSV_PURPLE` |
+|`RGB_MAGENTA` |`HSV_MAGENTA` |
+|`RGB_PINK` |`HSV_PINK` |
+
+These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h). Feel free to add to this list!
+
## Additional `config.h` Options
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md
index 97a9959946..4572f45b26 100644
--- a/docs/feature_rgblight.md
+++ b/docs/feature_rgblight.md
@@ -114,7 +114,7 @@ The following options can be used to tweak the various animations:
|`RGBLIGHT_EFFECT_RGB_TEST` |*Not defined*|If defined, enable RGB test animation mode. |
|`RGBLIGHT_EFFECT_ALTERNATING` |*Not defined*|If defined, enable alternating animation mode. |
|`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables all additional animation modes |
-|`RGBLIGHT_EFFECT_BREATHE_CENTER` |`1.85` |Used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 |
+|`RGBLIGHT_EFFECT_BREATHE_CENTER` |*Not defined*|If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 |
|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 |
|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation |
|`RGBLIGHT_EFFECT_KNIGHT_LENGTH` |`3` |The number of LEDs to light up for the "Knight" animation |
@@ -145,7 +145,7 @@ const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
// These control which hues are selected for each of the "Static gradient" modes
-const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
+const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
```
## Functions
@@ -191,7 +191,40 @@ If you need to change your RGB lighting in code, for example in a macro to chang
|`rgblight_decrease_val_noeeprom()` |Decrease the value for all LEDs. This wraps around at minimum value (not written to EEPROM) |
|`rgblight_set_clipping_range(pos, num)` |Set clipping Range |
-Additionally, [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h) defines several predefined shortcuts for various colors. Feel free to add to this list!
+## Colors
+
+These are shorthands to popular colors. The `RGB` ones can be passed to the `setrgb` functions, while the `HSV` ones to the `sethsv` functions.
+
+|RGB |HSV |
+|-------------------|-------------------|
+|`RGB_WHITE` |`HSV_WHITE` |
+|`RGB_RED` |`HSV_RED` |
+|`RGB_CORAL` |`HSV_CORAL` |
+|`RGB_ORANGE` |`HSV_ORANGE` |
+|`RGB_GOLDENROD` |`HSV_GOLDENROD` |
+|`RGB_GOLD` |`HSV_GOLD` |
+|`RGB_YELLOW` |`HSV_YELLOW` |
+|`RGB_CHARTREUSE` |`HSV_CHARTREUSE` |
+|`RGB_GREEN` |`HSV_GREEN` |
+|`RGB_SPRINGGREEN` |`HSV_SPRINGGREEN` |
+|`RGB_TURQUOISE` |`HSV_TURQUOISE` |
+|`RGB_TEAL` |`HSV_TEAL` |
+|`RGB_CYAN` |`HSV_CYAN` |
+|`RGB_AZURE` |`HSV_AZURE` |
+|`RGB_BLUE` |`HSV_BLUE` |
+|`RGB_PURPLE` |`HSV_PURPLE` |
+|`RGB_MAGENTA` |`HSV_MAGENTA` |
+|`RGB_PINK` |`HSV_PINK` |
+
+```c
+rgblight_setrgb(RGB_ORANGE);
+rgblight_sethsv_noeeprom(HSV_GREEN);
+rgblight_setrgb_at(RGB_GOLD, 3);
+rgblight_sethsv_range(HSV_WHITE, 0, 6);
+```
+
+These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h). Feel free to add to this list!
+
## Changing the order of the LEDs
diff --git a/docs/feature_space_cadet.md b/docs/feature_space_cadet.md
new file mode 100644
index 0000000000..5c375c5184
--- /dev/null
+++ b/docs/feature_space_cadet.md
@@ -0,0 +1,59 @@
+# Space Cadet: The Future, Built In
+
+Steve Losh described the [Space Cadet Shift](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) quite well. Essentially, when you tap Left Shift on its own, you get an opening parenthesis; tap Right Shift on its own and you get the closing one. When held, the Shift keys function as normal. Yes, it's as cool as it sounds, and now even cooler supporting Control and Alt as well!
+
+## Usage
+
+Firstly, in your keymap, do one of the following:
+- Replace the Left Shift key with `KC_LSPO` (Left Shift, Parenthesis Open), and Right Shift with `KC_RSPC` (Right Shift, Parenthesis Close).
+- Replace the Left Control key with `KC_LCPO` (Left Control, Parenthesis Open), and Right Control with `KC_RCPC` (Right Control, Parenthesis Close).
+- Replace the Left Alt key with `KC_LAPO` (Left Alt, Parenthesis Open), and Right Alt with `KC_RAPC` (Right Alt, Parenthesis Close).
+- Replace any Shift key in your keymap with `KC_SFTENT` (Right Shift, Enter).
+
+## Keycodes
+
+|Keycode |Description |
+|-----------|-------------------------------------------|
+|`KC_LSPO` |Left Shift when held, `(` when tapped |
+|`KC_RSPC` |Right Shift when held, `)` when tapped |
+|`KC_LCPO` |Left Control when held, `(` when tapped |
+|`KC_RCPC` |Right Control when held, `)` when tapped |
+|`KC_LAPO` |Left Alt when held, `(` when tapped |
+|`KC_RAPC` |Right Alt when held, `)` when tapped |
+|`KC_SFTENT`|Right Shift when held, `Enter` when tapped |
+
+## Caveats
+
+Space Cadet's functionality can conflict with the default Command functionality when both Shift keys are held at the same time. See the [Command feature](feature_command.md) for info on how to change it, or make sure that Command is disabled in your `rules.mk` with:
+
+```make
+COMMAND_ENABLE = no
+```
+
+## Configuration
+
+By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`. In addition, you can redefine the modifier to send on tap, or even send no modifier at all. The new configuration defines bundle all options up into a single define of 3 key codes in this order: the `Modifier` when held or when used with other keys, the `Tap Modifer` sent when tapped (no modifier if `KC_TRNS`), finally the `Keycode` sent when tapped. Now keep in mind, mods from other keys will still apply to the `Keycode` if say `KC_RSFT` is held while tapping `KC_LSPO` key with `KC_TRNS` as the `Tap Modifer`.
+
+|Define |Default |Description |
+|----------------|-------------------------------|---------------------------------------------------------------------------------|
+|`LSPO_KEYS` |`KC_LSFT, LSPO_MOD, LSPO_KEY` |Send `KC_LSFT` when held, the mod and key defined by `LSPO_MOD` and `LSPO_KEY`. |
+|`RSPC_KEYS` |`KC_RSFT, RSPC_MOD, RSPC_KEY` |Send `KC_RSFT` when held, the mod and key defined by `RSPC_MOD` and `RSPC_KEY`. |
+|`LCPO_KEYS` |`KC_LCTL, KC_LCTL, KC_9` |Send `KC_LCTL` when held, the mod `KC_LCTL` with the key `KC_9` when tapped. |
+|`RCPC_KEYS` |`KC_RCTL, KC_RCTL, KC_0` |Send `KC_RCTL` when held, the mod `KC_RCTL` with the key `KC_0` when tapped. |
+|`LAPO_KEYS` |`KC_LALT, KC_LALT, KC_9` |Send `KC_LALT` when held, the mod `KC_LALT` with the key `KC_9` when tapped. |
+|`RAPC_KEYS` |`KC_RALT, KC_RALT, KC_0` |Send `KC_RALT` when held, the mod `KC_RALT` with the key `KC_0` when tapped. |
+|`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |Send `KC_RSFT` when held, no mod with the key `SFTENT_KEY` when tapped. |
+
+
+## Obsolete Configuration
+
+These defines are used in the above defines internally to support backwards compatibility, so you may continue to use them, however the above defines open up a larger range of flexibility than before. As an example, say you want to not send any modifier when you tap just `KC_LSPO`, with the old defines you had an all or nothing choice of using the `DISABLE_SPACE_CADET_MODIFIER` define. Now you can define that key as: `#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`. This tells the system to set Left Shift if held or used with other keys, then on tap send no modifier (transparent) with the `KC_9`.
+
+|Define |Default |Description |
+|------------------------------|-------------|------------------------------------------------------------------|
+|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped |
+|`RSPC_KEY` |`KC_0` |The keycode to send when Right Shift is tapped |
+|`LSPO_MOD` |`KC_LSFT` |The modifier to apply to `LSPO_KEY` |
+|`RSPC_MOD` |`KC_RSFT` |The modifier to apply to `RSPC_KEY` |
+|`SFTENT_KEY` |`KC_ENT` |The keycode to send when the Shift key is tapped |
+|`DISABLE_SPACE_CADET_MODIFIER`|*Not defined*|If defined, prevent the Space Cadet from applying a modifier |
diff --git a/docs/feature_space_cadet_shift.md b/docs/feature_space_cadet_shift.md
deleted file mode 100644
index 427d2a5812..0000000000
--- a/docs/feature_space_cadet_shift.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Space Cadet Shift: The Future, Built In
-
-Steve Losh described the [Space Cadet Shift](http://stevelosh.com/blog/2012/10/a-modern-space-cadet/) quite well. Essentially, when you tap Left Shift on its own, you get an opening parenthesis; tap Right Shift on its own and you get the closing one. When held, the Shift keys function as normal. Yes, it's as cool as it sounds.
-
-## Usage
-
-Replace the Left Shift key in your keymap with `KC_LSPO` (Left Shift, Parenthesis Open), and Right Shift with `KC_RSPC` (Right Shift, Parenthesis Close).
-
-## Keycodes
-
-|Keycode |Description |
-|---------|--------------------------------------|
-|`KC_LSPO`|Left Shift when held, `(` when tapped |
-|`KC_RSPC`|Right Shift when held, `)` when tapped|
-
-## Caveats
-
-Space Cadet's functionality can conflict with the default Command functionality when both Shift keys are held at the same time. Make sure that Command is disabled in your `rules.mk` with:
-
-```make
-COMMAND_ENABLE = no
-```
-
-## Configuration
-
-By default Space Cadet assumes a US ANSI layout, but if your layout uses different keys for parentheses, you can redefine them in your `config.h`.
-You can also disable the rollover, allowing you to use the opposite Shift key to cancel the Space Cadet state in the event of an erroneous press, instead of emitting a pair of parentheses when the keys are released.
-Also, by default, the Space Cadet applies modifiers LSPO_MOD and RSPC_MOD to keys defined by LSPO_KEY and RSPC_KEY. You can override this behavior by redefining those variables in your `config.h`. You can also prevent the Space Cadet to apply a modifier by defining DISABLE_SPACE_CADET_MODIFIER in your `config.h`.
-
-|Define |Default |Description |
-|------------------------------|-------------|--------------------------------------------------------------------------------|
-|`LSPO_KEY` |`KC_9` |The keycode to send when Left Shift is tapped |
-|`RSPC_KEY` |`KC_0