diff options
Diffstat (limited to 'docs/feature_led_matrix.md')
-rw-r--r-- | docs/feature_led_matrix.md | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/docs/feature_led_matrix.md b/docs/feature_led_matrix.md index 563fa149a2..b468507424 100644 --- a/docs/feature_led_matrix.md +++ b/docs/feature_led_matrix.md @@ -22,7 +22,7 @@ You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_<N> | `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 | | `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 | | `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | | -| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | | +| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | | | `LED_DRIVER_ADDR_1` | (Required) Address for the first LED driver | | | `LED_DRIVER_ADDR_2` | (Optional) Address for the second LED driver | | | `LED_DRIVER_ADDR_3` | (Optional) Address for the third LED driver | | @@ -44,17 +44,17 @@ Here is an example using 2 drivers. #define LED_DRIVER_COUNT 2 #define LED_DRIVER_1_LED_TOTAL 25 #define LED_DRIVER_2_LED_TOTAL 24 -#define DRIVER_LED_TOTAL (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL) +#define LED_MATRIX_LED_COUNT (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL) ``` -!> Note the parentheses, this is so when `LED_DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`. +!> Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`. For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31_leds`. Define these arrays listing all the LEDs in your `<keyboard>.c`: ```c -const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = { +const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | LED address @@ -95,7 +95,7 @@ Configure the hardware via your `config.h`: | `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 | | `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 | | `DRIVER_COUNT` | (Required) How many LED driver IC's are present | | -| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | | +| `LED_MATRIX_LED_COUNT` | (Required) How many LED lights are present across all drivers | | | `DRIVER_ADDR_1` | (Optional) Address for the first LED driver | | | `DRIVER_ADDR_<N>` | (Required) Address for the additional LED drivers | | | `ISSI_SSR_<N>` | (Optional) Configuration for the Spread Spectrum Register | | @@ -130,16 +130,16 @@ Here is an example using 2 drivers. #define DRIVER_COUNT 2 #define DRIVER_1_LED_TOTAL 66 #define DRIVER_2_LED_TOTAL 42 -#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) +#define LED_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) ``` -!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`. +!> Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`. Currently only 4 drivers are supported, but it would be trivial to support for more. Note that using a combination of different drivers is not supported. All drivers must be of the same model. Define these arrays listing all the LEDs in your `<keyboard>.c`: ```c -const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = { +const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT] = { /* Refer to IS31 manual for these locations * driver * | LED address @@ -199,7 +199,7 @@ x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION ``` -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. +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. As mentioned earlier, the center of the keyboard by default is expected to be `{ 112, 32 }`, but this can be changed if you want to more accurately calculate the LED's physical `{ x, y }` positions. Keyboard designers can implement `#define LED_MATRIX_CENTER { 112, 32 }` in their config.h file with the new center point of the keyboard, or where they want it to be allowing more possibilities for the `{ x, y }` values. Do note that the maximum value for x or y is 255, and the recommended maximum is 224 as this gives animations runoff room before they reset. @@ -221,14 +221,14 @@ As mentioned earlier, the center of the keyboard by default is expected to be `{ All LED matrix keycodes are currently shared with the [Backlight feature](feature_backlight.md). -|Key |Description | -|---------|-----------------------------| -|`BL_TOGG`|Toggle LED Matrix on or off | -|`BL_STEP`|Cycle through modes | -|`BL_ON` |Turn on LED Matrix | -|`BL_OFF` |Turn off LED Matrix | -|`BL_INC` |Increase the brightness level| -|`BL_DEC` |Decrease the brightness level| +| Key | Aliases | Description | +|-------------------------|-----------|-------------------------------| +| `QK_BACKLIGHT_TOGGLE` | `BL_TOGG` | Toggle LED Matrix on or off | +| `QK_BACKLIGHT_STEP` | `BL_STEP` | Cycle through modes | +| `QK_BACKLIGHT_ON` | `BL_ON` | Turn on LED Matrix | +| `QK_BACKLIGHT_OFF` | `BL_OFF` | Turn off LED Matrix | +| `QK_BACKLIGHT_UP` | `BL_UP` | Increase the brightness level | +| `QK_BACKLIGHT_DOWN` | `BL_DOWN` | Decrease the brightness level | ## LED Matrix Effects :id=led-matrix-effects @@ -364,10 +364,9 @@ For inspiration and examples, check out the built-in effects under `quantum/led_ #define LED_MATRIX_KEYPRESSES // reacts to keypresses #define LED_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) #define LED_MATRIX_FRAMEBUFFER_EFFECTS // enable framebuffer effects -#define LED_DISABLE_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off -#define LED_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects +#define LED_MATRIX_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off #define LED_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended -#define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness) +#define LED_MATRIX_LED_PROCESS_LIMIT (LED_MATRIX_LED_COUNT + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness) #define LED_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) #define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs #define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID // Sets the default mode, if none has been set @@ -391,7 +390,7 @@ Where `28` is an unused index from `eeconfig.h`. |Function |Description | |--------------------------------------------|-------------| |`led_matrix_set_value_all(v)` |Set all of the LEDs to the given value, where `v` is between 0 and 255 (not written to EEPROM) | -|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) | +|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `LED_MATRIX_LED_COUNT` (not written to EEPROM) | ### Disable/Enable Effects :id=disable-enable-effects |Function |Description | @@ -440,10 +439,14 @@ Where `28` is an unused index from `eeconfig.h`. ### Indicators :id=indicators -If you want to set custom indicators, such as an LED for Caps Lock, or layer indication, you can use the `led_matrix_indicators_kb` or `led_matrix_indicators_user` function for that: +If you want to set custom indicators, such as an LED for Caps Lock, or layer indication, you can use the `led_matrix_indicators_kb` or `led_matrix_indicators_user` function for that: ```c -void led_matrix_indicators_kb(void) { +bool led_matrix_indicators_kb(void) { + if (!led_matrix_indicators_user()) { + return false; + } led_matrix_set_value(index, value); + return true; } ``` @@ -452,5 +455,6 @@ In addition, there are the advanced indicator functions. These are aimed at tho ```c void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { LED_MATRIX_INDICATOR_SET_VALUE(index, value); + return false; } ``` |