aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-01-27 16:19:55 -0800
committerskullydazed <skullydazed@users.noreply.github.com>2019-02-10 15:37:12 -0800
commit24df54b80794144907db94c2cb5ceca928700e2d (patch)
treeb18b05f7c108c4db34b4796773aa4f93c6e39fe5
parentcc738e32dd02cbc6e10f3e229332390d3b886e4d (diff)
downloadqmk_firmware-24df54b80794144907db94c2cb5ceca928700e2d.tar.gz
qmk_firmware-24df54b80794144907db94c2cb5ceca928700e2d.zip
Add documentation for led matrix
-rw-r--r--docs/feature_led_matrix.md199
-rw-r--r--docs/feature_rgb_matrix.md4
-rw-r--r--docs/i2c_driver.md18
3 files changed, 51 insertions, 170 deletions
diff --git a/docs/feature_led_matrix.md b/docs/feature_led_matrix.md
index 5a62cc530..372407b90 100644
--- a/docs/feature_led_matrix.md
+++ b/docs/feature_led_matrix.md
@@ -1,14 +1,31 @@
1# RGB Matrix Lighting 1# LED Matrix Lighting
2
3This feature allows you to use LED matrices driven by external drivers. It hooks into the backlight system so you can use the same keycodes as backlighting to control it.
4
5If you want to use RGB LED's you should use the [RGB Matrix Subsystem](feature_rgb_matrix.md) instead.
2 6
3## Driver configuration 7## Driver configuration
4 8
5### IS31FL3731 9### IS31FL3731
6 10
7There is basic support for addressable RGB matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`: 11There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`:
8 12
9 LED_MATRIX_ENABLE = IS31FL3731 13 LED_MATRIX_ENABLE = IS31FL3731
14
15You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_<N>` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
10 16
11Configure the hardware via your `config.h`: 17| Variable | Description | Default |
18|----------|-------------|---------|
19| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages | 100 |
20| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
21| `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
22| `LED_DRIVER_LED_COUNT` | (Required) How many LED lights are present across all drivers | |
23| `LED_DRIVER_ADDR_1` | (Required) Address for the first LED driver | |
24| `LED_DRIVER_ADDR_2` | (Optional) Address for the second LED driver | |
25| `LED_DRIVER_ADDR_3` | (Optional) Address for the third LED driver | |
26| `LED_DRIVER_ADDR_4` | (Optional) Address for the fourth LED driver | |
27
28Here is an example using 2 drivers.
12 29
13 // This is a 7-bit address, that gets left-shifted and bit 0 30 // This is a 7-bit address, that gets left-shifted and bit 0
14 // set to 0 for write, 1 for read (as per I2C protocol) 31 // set to 0 for write, 1 for read (as per I2C protocol)
@@ -21,9 +38,9 @@ Configure the hardware via your `config.h`:
21 #define LED_DRIVER_ADDR_2 0b1110110 38 #define LED_DRIVER_ADDR_2 0b1110110
22 39
23 #define LED_DRIVER_COUNT 2 40 #define LED_DRIVER_COUNT 2
24 #define LED_DRIVER_1_LED_TOTAL 25 41 #define LED_DRIVER_1_LED_COUNT 25
25 #define LED_DRIVER_2_LED_TOTAL 24 42 #define LED_DRIVER_2_LED_COUNT 24
26 #define LED_DRIVER_LED_TOTAL LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL 43 #define LED_DRIVER_LED_COUNT LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL
27 44
28Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations. 45Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
29 46
@@ -32,175 +49,31 @@ Define these arrays listing all the LEDs in your `<keyboard>.c`:
32 const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 49 const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
33 /* Refer to IS31 manual for these locations 50 /* Refer to IS31 manual for these locations
34 * driver 51 * driver
35 * | R location 52 * | LED address
36 * | | G location 53 * | | */
37 * | | | B location 54 {0, C3_3},
38 * | | | | */
39 {0, C1_3, C2_3, C3_3},
40 .... 55 ....
41 } 56 }
42 57
43Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731.h`. The `driver` is the index of the driver you defined in your `config.h` (`0` or `1` right now). 58Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731-simple.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
44
45### IS31FL3733
46
47There is basic support for addressable RGB matrix lighting with the I2C IS31FL3733 RGB controller. To enable it, add this to your `rules.mk`:
48
49 RGB_MATRIX_ENABLE = IS31FL3733
50
51Configure the hardware via your `config.h`:
52
53 // This is a 7-bit address, that gets left-shifted and bit 0
54 // set to 0 for write, 1 for read (as per I2C protocol)
55 // The address will vary depending on your wiring:
56 // 00 <-> GND
57 // 01 <-> SCL
58 // 10 <-> SDA
59 // 11 <-> VCC
60 // ADDR1 represents A1:A0 of the 7-bit address.
61 // ADDR2 represents A3:A2 of the 7-bit address.
62 // The result is: 0b101(ADDR2)(ADDR1)
63 #define DRIVER_ADDR_1 0b1010000
64 #define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
65
66 #define DRIVER_COUNT 1
67 #define DRIVER_1_LED_TOTAL 64
68 #define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
69
70Currently only a single drivers is supported, but it would be trivial to support all 4 combinations. For now define `DRIVER_ADDR_2` as `DRIVER_ADDR_1`
71
72Define these arrays listing all the LEDs in your `<keyboard>.c`:
73
74 const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
75 /* Refer to IS31 manual for these locations
76 * driver
77 * | R location
78 * | | G location
79 * | | | B location
80 * | | | | */
81 {0, B_1, A_1, C_1},
82 ....
83 }
84
85Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](http://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` right now).
86
87From this point forward the configuration is the same for all the drivers.
88
89 const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
90 /* {row | col << 4}
91 * | {x=0..224, y=0..64}
92 * | | modifier
93 * | | | */
94 {{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
95 {{0|(1<<4)}, {20.36*1, 21.33*0}, 1},
96 ....
97 }
98
99The 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:
100
101 x = 224 / ( NUMBER_OF_ROWS - 1 ) * ROW_POSITION
102 y = 64 / (NUMBER_OF_COLS - 1 ) * COL_POSITION
103
104Where all variables are decimels/floats.
105
106`modifier` is a boolean, whether or not a certain key is considered a modifier (used in some effects).
107 59
108## Keycodes 60## Keycodes
109 61
110All RGB keycodes are currently shared with the RGBLIGHT system: 62All LED matrix keycodes are currently shared with the [backlight system](feature_backlight.md).
111 63
112 * `RGB_TOG` - toggle 64## LED Matrix Effects
113 * `RGB_MOD` - cycle through modes
114 * `RGB_HUI` - increase hue
115 * `RGB_HUD` - decrease hue
116 * `RGB_SAI` - increase saturation
117 * `RGB_SAD` - decrease saturation
118 * `RGB_VAI` - increase value
119 * `RGB_VAD` - decrease value
120 * `RGB_SPI` - increase speed effect (no EEPROM support)
121 * `RGB_SPD` - decrease speed effect (no EEPROM support)
122
123
124 * `RGB_MODE_*` keycodes will generally work, but are not currently mapped to the correct effects for the RGB Matrix system
125
126## RGB Matrix Effects
127
128These are the effects that are currently available:
129
130 enum rgb_matrix_effects {
131 RGB_MATRIX_SOLID_COLOR = 1,
132 RGB_MATRIX_ALPHAS_MODS,
133 RGB_MATRIX_DUAL_BEACON,
134 RGB_MATRIX_GRADIENT_UP_DOWN,
135 RGB_MATRIX_RAINDROPS,
136 RGB_MATRIX_CYCLE_ALL,
137 RGB_MATRIX_CYCLE_LEFT_RIGHT,
138 RGB_MATRIX_CYCLE_UP_DOWN,
139 RGB_MATRIX_RAINBOW_BEACON,
140 RGB_MATRIX_RAINBOW_PINWHEELS,
141 RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
142 RGB_MATRIX_JELLYBEAN_RAINDROPS,
143 RGB_MATRIX_DIGITAL_RAIN,
144 #ifdef RGB_MATRIX_KEYPRESSES
145 RGB_MATRIX_SOLID_REACTIVE,
146 RGB_MATRIX_SPLASH,
147 RGB_MATRIX_MULTISPLASH,
148 RGB_MATRIX_SOLID_SPLASH,
149 RGB_MATRIX_SOLID_MULTISPLASH,
150 #endif
151 RGB_MATRIX_EFFECT_MAX
152 };
153
154You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
155
156
157|Define |Description |
158|---------------------------------------------------|--------------------------------------------|
159|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
160|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
161|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
162|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
163|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
164|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
165|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
166|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
167|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
168|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|
169|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
170|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
171|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
172|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
173|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
174|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
175|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
176 65
66Currently no LED matrix effects have been created.
177 67
178## Custom layer effects 68## Custom layer effects
179 69
180Custom layer effects can be done by defining this in your `<keyboard>.c`: 70Custom layer effects can be done by defining this in your `<keyboard>.c`:
181 71
182 void rgb_matrix_indicators_kb(void) { 72 void led_matrix_indicators_kb(void) {
183 rgb_matrix_set_color(index, red, green, blue); 73 led_matrix_set_index_value(index, value);
184 } 74 }
185 75
186A similar function works in the keymap as `rgb_matrix_indicators_user`. 76A similar function works in the keymap as `led_matrix_indicators_user`.
187
188## Additional `config.h` Options
189
190 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot)
191 #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened)
192 #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
193 #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
194 #define RGB_MATRIX_SKIP_FRAMES 1 // number of frames to skip when displaying animations (0 is full effect) if not defined defaults to 1
195 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
196
197## EEPROM storage
198
199The EEPROM for it is currently shared with the RGBLIGHT system (it's generally assumed only one RGB would be used at a time), but could be configured to use its own 32bit address with:
200
201 #define EECONFIG_RGB_MATRIX (uint32_t *)16
202
203Where `16` is an unused index from `eeconfig.h`.
204 77
205## Suspended state 78## Suspended state
206 79
@@ -208,10 +81,10 @@ To use the suspend feature, add this to your `<keyboard>.c`:
208 81
209 void suspend_power_down_kb(void) 82 void suspend_power_down_kb(void)
210 { 83 {
211 rgb_matrix_set_suspend_state(true); 84 led_matrix_set_suspend_state(true);
212 } 85 }
213 86
214 void suspend_wakeup_init_kb(void) 87 void suspend_wakeup_init_kb(void)
215 { 88 {
216 rgb_matrix_set_suspend_state(false); 89 led_matrix_set_suspend_state(false);
217 } 90 }
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 0af1e4947..e955eb26f 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -1,5 +1,9 @@
1# RGB Matrix Lighting 1# RGB Matrix Lighting
2 2
3This feature allows you to use RGB LED matrices driven by external drivers. It hooks into the RGBLIGHT system so you can use the same keycodes as RGBLIGHT to control it.
4
5If you want to use single color LED's you should use the [LED Matrix Subsystem](feature_led_matrix.md) instead.
6
3## Driver configuration 7## Driver configuration
4 8
5### IS31FL3731 9### IS31FL3731
diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md
index ea24dc64f..18546fc62 100644
--- a/docs/i2c_driver.md
+++ b/docs/i2c_driver.md
@@ -33,8 +33,8 @@ The following defines can be used to configure the I2C master driver.
33 33
34|Variable |Description |Default| 34|Variable |Description |Default|
35|------------------|---------------------------------------------------|-------| 35|------------------|---------------------------------------------------|-------|
36|`#F_SCL` |Clock frequency in Hz |400KHz | 36|`F_SCL` |Clock frequency in Hz |400KHz |
37|`#Prescaler` |Divides master clock to aid in I2C clock selection |1 | 37|`Prescaler` |Divides master clock to aid in I2C clock selection |1 |
38 38
39AVRs usually have set GPIO which turn into I2C pins, therefore no further configuration is required. 39AVRs usually have set GPIO which turn into I2C pins, therefore no further configuration is required.
40 40
@@ -63,20 +63,24 @@ Lastly, we need to assign the correct GPIO pins depending on the I2C hardware dr
63 63
64By default the I2C1 hardware driver is assumed to be used. If another hardware driver is used, `#define I2C_DRIVER I2CDX` should be added to the `config.h` file with X being the number of hardware driver used. For example is I2C3 is enabled, the `config.h` file should contain `#define I2C_DRIVER I2CD3`. This aligns the QMK I2C driver with the Chibios I2C driver. 64By default the I2C1 hardware driver is assumed to be used. If another hardware driver is used, `#define I2C_DRIVER I2CDX` should be added to the `config.h` file with X being the number of hardware driver used. For example is I2C3 is enabled, the `config.h` file should contain `#define I2C_DRIVER I2CD3`. This aligns the QMK I2C driver with the Chibios I2C driver.
65 65
66STM32 MCUs allows a variety of pins to be configured as I2C pins depending on the hardware driver used. By default B6 and B7 are set to I2C. 66STM32 MCUs allows a variety of pins to be configured as I2C pins depending on the hardware driver used. By default B6 and B7 are set to I2C. You can use these defines to set your i2c pins:
67 67
68This can be changed by declaring the `i2c_init` function which intentionally has a weak attribute. Please consult the datasheet of your MCU for the available GPIO configurations. The following is an example initialization function: 68| Variable | Description | Default |
69|-------------|----------------------------------------------|---------|
70| `I2C1_BANK` | The bank of pins (`GPIOA`, `GPIOB`, `GPIOC`) | `GPIOB` |
71| `I2C1_SCL` | The pin number for the SCL pin (0-9) | `6` |
72| `I2C1_SDA` | The pin number for the SDA pin (0-9) | `7` |
73
74You can also overload the `void i2c_init(void)` function, which has a weak attribute. If you do this the configuration variables above will not be used. Please consult the datasheet of your MCU for the available GPIO configurations. The following is an example initialization function:
69 75
70```C 76```C
71void i2c_init(void) 77void i2c_init(void)
72{ 78{
73 setPinInput(B6); // Try releasing special pins for a short time 79 setPinInput(B6); // Try releasing special pins for a short time
74 setPinInput(B7); 80 setPinInput(B7);
75 chThdSleepMilliseconds(10); // Wait for the release to happen 81 wait_ms(10); // Wait for the release to happen
76 82
77 palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function 83 palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function
78 palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B7 to I2C function 84 palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B7 to I2C function
79} 85}
80``` 86```
81
82