aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_rgb_matrix.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_rgb_matrix.md')
-rw-r--r--docs/feature_rgb_matrix.md32
1 files changed, 18 insertions, 14 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 91ec77ace..5eb9d5536 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -124,21 +124,25 @@ Configure the hardware via your `config.h`:
124 124
125--- 125---
126 126
127From this point forward the configuration is the same for all the drivers. The struct rgb_led array tells the system for each led, what key electrical matrix it represents, what the physical position is on the board, and if the led is for a modifier key or not. Here is a brief example: 127From 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:
128 128
129```C 129```C
130rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { 130const led_config_t g_led_config = { {
131/* {row | col << 4} 131 // Key Matrix to LED Index
132 * | {x=0..224, y=0..64} 132 { 5, NO_LED, NO_LED, 0 },
133 * | | flags 133 { NO_LED, NO_LED, NO_LED, NO_LED },
134 * | | | */ 134 { 4, NO_LED, NO_LED, 1 },
135 {{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, 135 { 3, NO_LED, NO_LED, 2 }
136 {{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, 136}, {
137 .... 137 // LED Index to Physical Position
138} 138 { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
139}, {
140 // LED Index to Flag
141 1, 4, 4, 4, 4, 1
142} };
139``` 143```
140 144
141The first part, `{row | col << 4}`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `{x=0..224, y=0..64}` represents the LED's physical position on the keyboard. The `x` is between (inclusive) 0-224, and `y` is between (inclusive) 0-64 as the effects are based on this range. 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: 145The 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:
142 146
143```C 147```C
144x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION 148x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
@@ -147,7 +151,7 @@ y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
147 151
148Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout. 152Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.
149 153
150`flags` 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. 154`// 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.
151 155
152## Flags 156## Flags
153 157
@@ -155,8 +159,8 @@ Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based
155|------------------------------------|-------------------------------------------| 159|------------------------------------|-------------------------------------------|
156|`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.| 160|`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.|
157|`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.| 161|`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.|
158|`#define LED_FLAG_NONE 0x00` |If thes LED has no flags. | 162|`#define LED_FLAG_NONE 0x00` |If this LED has no flags. |
159|`#define LED_FLAG_ALL 0xFF` |If thes LED has all flags. | 163|`#define LED_FLAG_ALL 0xFF` |If this LED has all flags. |
160|`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. | 164|`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. |
161|`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. | 165|`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. |
162|`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. | 166|`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. |