Skip to content

Commit

Permalink
Updated rgb_led struct field modifier to flags (qmk#5619)
Browse files Browse the repository at this point in the history
Updated effects to test led flags
Updated massdrop to use new flags field for led toggle
  • Loading branch information
XScorpion2 authored and foosinn committed May 6, 2019
1 parent afd25a0 commit 20c1650
Show file tree
Hide file tree
Showing 57 changed files with 1,173 additions and 1,028 deletions.
20 changes: 16 additions & 4 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ Configure the hardware via your `config.h`:
From 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:
```C
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/* {row | col << 4}
* | {x=0..224, y=0..64}
* | | modifier
* | | flags
* | | | */
{{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
{{0|(1<<4)}, {20.36*1, 21.33*0}, 1},
{{0|(1<<4)}, {20.36*1, 21.33*0}, 4},
....
}
```
Expand All @@ -147,7 +147,19 @@ 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.

`modifier` is a boolean, whether or not a certain key is considered a modifier (used in some effects).
`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.

## 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 thes LED has no flags. |
|`#define LED_FLAG_ALL 0xFF` |If thes 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

Expand Down
14 changes: 7 additions & 7 deletions keyboards/boston_meetup/2019/2019.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
#ifdef RGB_MATRIX_ENABLE
#include "rgblight.h"

const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/*{row | col << 4}
| {x=0..224, y=0..64}
| | modifier
| | | */
{{1|(3<<4)}, {188, 16}, 0},
{{3|(3<<4)}, {187, 48}, 0},
{{4|(2<<4)}, {149, 64}, 0},
{{4|(1<<4)}, {112, 64}, 0},
{{3|(0<<4)}, {37, 48}, 0},
{{1|(0<<4)}, {38, 16}, 0}
{{1|(3<<4)}, {188, 16}, 4},
{{3|(3<<4)}, {187, 48}, 4},
{{4|(2<<4)}, {149, 64}, 4},
{{4|(1<<4)}, {112, 64}, 4},
{{3|(0<<4)}, {37, 48}, 4},
{{1|(0<<4)}, {38, 16}, 4}
};
#endif

Expand Down
88 changes: 44 additions & 44 deletions keyboards/crkbd/rev1/rev1.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,70 +56,70 @@ void led_set_kb(uint8_t usb_led) {
* | | | modifier
* | | | */
#define RGB_MATRIX_LEFT_LEDS \
{ { 0xFF }, { 85, 16 }, 0 }, /* 1 */ \
{ { 0xFF }, { 50, 13 }, 0 }, /* 2 */ \
{ { 0xFF }, { 16, 20 }, 0 }, /* 3 */ \
{ { 0xFF }, { 16, 38 }, 0 }, /* 4 */ \
{ { 0xFF }, { 50, 48 }, 0 }, /* 5 */ \
{ { 0xFF }, { 85, 52 }, 0 }, /* 6 */ \
{ { 0xFF }, { 85, 16 }, 2 }, /* 1 */ \
{ { 0xFF }, { 50, 13 }, 2 }, /* 2 */ \
{ { 0xFF }, { 16, 20 }, 2 }, /* 3 */ \
{ { 0xFF }, { 16, 38 }, 2 }, /* 4 */ \
{ { 0xFF }, { 50, 48 }, 2 }, /* 5 */ \
{ { 0xFF }, { 85, 52 }, 2 }, /* 6 */ \
{ { 3 | ( 5 << 4 ) }, { 95, 63 }, 1 }, /* 7 */ \
{ { 2 | ( 5 << 4 ) }, { 85, 39 }, 0 }, /* 8 */ \
{ { 1 | ( 5 << 4 ) }, { 85, 21 }, 0 }, /* 9 */ \
{ { 0 | ( 5 << 4 ) }, { 85, 4 }, 0 }, /* 10 */ \
{ { 0 | ( 4 << 4 ) }, { 68, 02 }, 0 }, /* 11 */ \
{ { 1 | ( 4 << 4 ) }, { 68, 19 }, 0 }, /* 12 */ \
{ { 2 | ( 4 << 4 ) }, { 68, 37 }, 0 }, /* 13 */ \
{ { 2 | ( 5 << 4 ) }, { 85, 39 }, 4 }, /* 8 */ \
{ { 1 | ( 5 << 4 ) }, { 85, 21 }, 4 }, /* 9 */ \
{ { 0 | ( 5 << 4 ) }, { 85, 4 }, 4 }, /* 10 */ \
{ { 0 | ( 4 << 4 ) }, { 68, 02 }, 4 }, /* 11 */ \
{ { 1 | ( 4 << 4 ) }, { 68, 19 }, 4 }, /* 12 */ \
{ { 2 | ( 4 << 4 ) }, { 68, 37 }, 4 }, /* 13 */ \
{ { 3 | ( 4 << 4 ) }, { 80, 58 }, 1 }, /* 14 */ \
{ { 3 | ( 3 << 4 ) }, { 60, 55 }, 1 }, /* 15 */ \
{ { 2 | ( 3 << 4 ) }, { 50, 35 }, 0 }, /* 16 */ \
{ { 1 | ( 3 << 4 ) }, { 50, 13 }, 0 }, /* 17 */ \
{ { 0 | ( 3 << 4 ) }, { 50, 0 }, 0 }, /* 18 */ \
{ { 0 | ( 2 << 4 ) }, { 33, 3 }, 0 }, /* 19 */ \
{ { 1 | ( 2 << 4 ) }, { 33, 20 }, 0 }, /* 20 */ \
{ { 2 | ( 2 << 4 ) }, { 33, 37 }, 0 }, /* 21 */ \
{ { 2 | ( 1 << 4 ) }, { 16, 42 }, 0 }, /* 22 */ \
{ { 1 | ( 1 << 4 ) }, { 16, 24 }, 0 }, /* 23 */ \
{ { 0 | ( 1 << 4 ) }, { 16, 7 }, 0 }, /* 24 */ \
{ { 2 | ( 3 << 4 ) }, { 50, 35 }, 4 }, /* 16 */ \
{ { 1 | ( 3 << 4 ) }, { 50, 13 }, 4 }, /* 17 */ \
{ { 0 | ( 3 << 4 ) }, { 50, 0 }, 4 }, /* 18 */ \
{ { 0 | ( 2 << 4 ) }, { 33, 3 }, 4 }, /* 19 */ \
{ { 1 | ( 2 << 4 ) }, { 33, 20 }, 4 }, /* 20 */ \
{ { 2 | ( 2 << 4 ) }, { 33, 37 }, 4 }, /* 21 */ \
{ { 2 | ( 1 << 4 ) }, { 16, 42 }, 4 }, /* 22 */ \
{ { 1 | ( 1 << 4 ) }, { 16, 24 }, 4 }, /* 23 */ \
{ { 0 | ( 1 << 4 ) }, { 16, 7 }, 4 }, /* 24 */ \
{ { 0 | ( 0 << 4 ) }, { 0, 7 }, 1 }, /* 25 */ \
{ { 1 | ( 0 << 4 ) }, { 0, 24 }, 1 }, /* 26 */ \
{ { 2 | ( 0 << 4 ) }, { 0, 41 }, 1 }, /* 27 */

#define RGB_MATRIX_RIGHT_LEDS \
{ { 0xFF }, { 139, 16 }, 0 }, /* 1 */ \
{ { 0xFF }, { 174, 13 }, 0 }, /* 2 */ \
{ { 0xFF }, { 208, 20 }, 0 }, /* 3 */ \
{ { 0xFF }, { 208, 38 }, 0 }, /* 4 */ \
{ { 0xFF }, { 174, 48 }, 0 }, /* 5 */ \
{ { 0xFF }, { 139, 52 }, 0 }, /* 6 */ \
{ { 0xFF }, { 139, 16 }, 2 }, /* 1 */ \
{ { 0xFF }, { 174, 13 }, 2 }, /* 2 */ \
{ { 0xFF }, { 208, 20 }, 2 }, /* 3 */ \
{ { 0xFF }, { 208, 38 }, 2 }, /* 4 */ \
{ { 0xFF }, { 174, 48 }, 2 }, /* 5 */ \
{ { 0xFF }, { 139, 52 }, 2 }, /* 6 */ \
{ { 7 | ( 5 << 4 ) }, { 129, 63 }, 1 }, /* 7 */ \
{ { 6 | ( 5 << 4 ) }, { 139, 39 }, 0 }, /* 8 */ \
{ { 5 | ( 5 << 4 ) }, { 139, 21 }, 0 }, /* 9 */ \
{ { 4 | ( 5 << 4 ) }, { 139, 4 }, 0 }, /* 10 */ \
{ { 4 | ( 4 << 4 ) }, { 156, 02 }, 0 }, /* 11 */ \
{ { 5 | ( 4 << 4 ) }, { 156, 19 }, 0 }, /* 12 */ \
{ { 6 | ( 4 << 4 ) }, { 156, 37 }, 0 }, /* 13 */ \
{ { 6 | ( 5 << 4 ) }, { 139, 39 }, 4 }, /* 8 */ \
{ { 5 | ( 5 << 4 ) }, { 139, 21 }, 4 }, /* 9 */ \
{ { 4 | ( 5 << 4 ) }, { 139, 4 }, 4 }, /* 10 */ \
{ { 4 | ( 4 << 4 ) }, { 156, 02 }, 4 }, /* 11 */ \
{ { 5 | ( 4 << 4 ) }, { 156, 19 }, 4 }, /* 12 */ \
{ { 6 | ( 4 << 4 ) }, { 156, 37 }, 4 }, /* 13 */ \
{ { 7 | ( 4 << 4 ) }, { 144, 58 }, 1 }, /* 14 */ \
{ { 7 | ( 3 << 4 ) }, { 164, 55 }, 1 }, /* 15 */ \
{ { 6 | ( 3 << 4 ) }, { 174, 35 }, 0 }, /* 16 */ \
{ { 5 | ( 3 << 4 ) }, { 174, 13 }, 0 }, /* 17 */ \
{ { 4 | ( 3 << 4 ) }, { 174, 0 }, 0 }, /* 18 */ \
{ { 4 | ( 2 << 4 ) }, { 191, 3 }, 0 }, /* 19 */ \
{ { 5 | ( 2 << 4 ) }, { 191, 20 }, 0 }, /* 20 */ \
{ { 6 | ( 2 << 4 ) }, { 191, 37 }, 0 }, /* 21 */ \
{ { 6 | ( 1 << 4 ) }, { 208, 42 }, 0 }, /* 22 */ \
{ { 5 | ( 1 << 4 ) }, { 208, 24 }, 0 }, /* 23 */ \
{ { 4 | ( 1 << 4 ) }, { 208, 7 }, 0 }, /* 24 */ \
{ { 6 | ( 3 << 4 ) }, { 174, 35 }, 4 }, /* 16 */ \
{ { 5 | ( 3 << 4 ) }, { 174, 13 }, 4 }, /* 17 */ \
{ { 4 | ( 3 << 4 ) }, { 174, 0 }, 4 }, /* 18 */ \
{ { 4 | ( 2 << 4 ) }, { 191, 3 }, 4 }, /* 19 */ \
{ { 5 | ( 2 << 4 ) }, { 191, 20 }, 4 }, /* 20 */ \
{ { 6 | ( 2 << 4 ) }, { 191, 37 }, 4 }, /* 21 */ \
{ { 6 | ( 1 << 4 ) }, { 208, 42 }, 4 }, /* 22 */ \
{ { 5 | ( 1 << 4 ) }, { 208, 24 }, 4 }, /* 23 */ \
{ { 4 | ( 1 << 4 ) }, { 208, 7 }, 4 }, /* 24 */ \
{ { 4 | ( 0 << 4 ) }, { 224, 7 }, 1 }, /* 25 */ \
{ { 5 | ( 0 << 4 ) }, { 224, 24 }, 1 }, /* 26 */ \
{ { 6 | ( 0 << 4 ) }, { 224, 41 }, 1 }, /* 27 */

#ifdef RGB_MATRIX_SPLIT_RIGHT
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
RGB_MATRIX_RIGHT_LEDS
RGB_MATRIX_LEFT_LEDS
};
#else
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
RGB_MATRIX_LEFT_LEDS
RGB_MATRIX_RIGHT_LEDS
};
Expand Down
100 changes: 50 additions & 50 deletions keyboards/doro67/rgb/rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,73 +52,73 @@ void led_set_kb(uint8_t usb_led) {
led_set_user(usb_led);
}

const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
{{0|(0<<4)}, {15*0, 0}, 0}, // Esc
{{0|(1<<4)}, {15*1, 0}, 0}, // 1
{{0|(2<<4)}, {15*2, 0}, 0}, // 2
{{0|(3<<4)}, {15*3, 0}, 0}, // 3
{{0|(4<<4)}, {15*4, 0}, 0}, // 4
{{0|(5<<4)}, {15*5, 0}, 0}, // 5
{{0|(6<<4)}, {15*6, 0}, 0}, // 6
{{0|(7<<4)}, {15*7, 0}, 0}, // 7
{{0|(8<<4)}, {15*8, 0}, 0}, // 8
{{0|(9<<4)}, {15*9, 0}, 0}, // 9
{{0|(10<<4)}, {15*10, 0}, 0}, // 0
{{0|(11<<4)}, {15*11, 0}, 0}, // -
{{0|(12<<4)}, {15*12, 0}, 0}, // =
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
{{0|(0<<4)}, {15*0, 0}, 4}, // Esc
{{0|(1<<4)}, {15*1, 0}, 4}, // 1
{{0|(2<<4)}, {15*2, 0}, 4}, // 2
{{0|(3<<4)}, {15*3, 0}, 4}, // 3
{{0|(4<<4)}, {15*4, 0}, 4}, // 4
{{0|(5<<4)}, {15*5, 0}, 4}, // 5
{{0|(6<<4)}, {15*6, 0}, 4}, // 6
{{0|(7<<4)}, {15*7, 0}, 4}, // 7
{{0|(8<<4)}, {15*8, 0}, 4}, // 8
{{0|(9<<4)}, {15*9, 0}, 4}, // 9
{{0|(10<<4)}, {15*10, 0}, 4}, // 0
{{0|(11<<4)}, {15*11, 0}, 4}, // -
{{0|(12<<4)}, {15*12, 0}, 4}, // =
{{0|(13<<4)}, {15*13.5, 0}, 1}, // Backspace
{{0|(14<<4)}, {15*15, 0}, 1}, // Ins

{{1|(0<<4)}, {15*0.5, 16}, 1}, // Tab
{{1|(1<<4)}, {15*1.5, 16}, 0}, // Q
{{1|(2<<4)}, {15*2.5, 16}, 0}, // W
{{1|(3<<4)}, {15*3.5, 16}, 0}, // E
{{1|(4<<4)}, {15*4.5, 16}, 0}, // R
{{1|(5<<4)}, {15*5.5, 16}, 0}, // T
{{1|(6<<4)}, {15*6.5, 16}, 0}, // Y
{{1|(7<<4)}, {15*7.5, 16}, 0}, // U
{{1|(8<<4)}, {15*8.5, 16}, 0}, // I
{{1|(9<<4)}, {15*9.5, 16}, 0}, // O
{{1|(10<<4)}, {15*10.5, 16}, 0}, // P
{{1|(11<<4)}, {15*11.5, 16}, 0}, // [
{{1|(12<<4)}, {15*12.5, 16}, 0}, // ]
{{1|(13<<4)}, {15*13.75, 16}, 1}, //
{{1|(1<<4)}, {15*1.5, 16}, 4}, // Q
{{1|(2<<4)}, {15*2.5, 16}, 4}, // W
{{1|(3<<4)}, {15*3.5, 16}, 4}, // E
{{1|(4<<4)}, {15*4.5, 16}, 4}, // R
{{1|(5<<4)}, {15*5.5, 16}, 4}, // T
{{1|(6<<4)}, {15*6.5, 16}, 4}, // Y
{{1|(7<<4)}, {15*7.5, 16}, 4}, // U
{{1|(8<<4)}, {15*8.5, 16}, 4}, // I
{{1|(9<<4)}, {15*9.5, 16}, 4}, // O
{{1|(10<<4)}, {15*10.5, 16}, 4}, // P
{{1|(11<<4)}, {15*11.5, 16}, 4}, // [
{{1|(12<<4)}, {15*12.5, 16}, 4}, // ]
{{1|(13<<4)}, {15*13.75, 16}, 1}, //
{{1|(14<<4)}, {15*15, 16}, 1}, // Del

{{2|(0<<4)}, {15*0.75, 32}, 1}, // Capslock
{{2|(1<<4)}, {15*1.75, 32}, 0}, // A
{{2|(2<<4)}, {15*2.75, 32}, 0}, // S
{{2|(3<<4)}, {15*3.75, 32}, 0}, // D
{{2|(4<<4)}, {15*4.75, 32}, 0}, // F
{{2|(5<<4)}, {15*5.75, 32}, 0}, // G
{{2|(6<<4)}, {15*6.75, 32}, 0}, // H
{{2|(7<<4)}, {15*7.75, 32}, 0}, // J
{{2|(8<<4)}, {15*8.75, 32}, 0}, // K
{{2|(9<<4)}, {15*9.75, 32}, 0}, // L
{{2|(10<<4)}, {15*10.75, 32}, 0}, // ;
{{2|(11<<4)}, {15*11.75, 32}, 0}, // '
{{2|(1<<4)}, {15*1.75, 32}, 4}, // A
{{2|(2<<4)}, {15*2.75, 32}, 4}, // S
{{2|(3<<4)}, {15*3.75, 32}, 4}, // D
{{2|(4<<4)}, {15*4.75, 32}, 4}, // F
{{2|(5<<4)}, {15*5.75, 32}, 4}, // G
{{2|(6<<4)}, {15*6.75, 32}, 4}, // H
{{2|(7<<4)}, {15*7.75, 32}, 4}, // J
{{2|(8<<4)}, {15*8.75, 32}, 4}, // K
{{2|(9<<4)}, {15*9.75, 32}, 4}, // L
{{2|(10<<4)}, {15*10.75, 32}, 4}, // ;
{{2|(11<<4)}, {15*11.75, 32}, 4}, // '
{{2|(13<<4)}, {15*13.25, 32}, 1}, // Enter
{{2|(14<<4)}, {15*15, 32}, 1}, // Pgup

{{3|(0<<4)}, {15*1.25, 48}, 1}, // LShift
{{3|(2<<4)}, {15*2, 48}, 0}, // Z
{{3|(3<<4)}, {15*3, 48}, 0}, // X
{{3|(4<<4)}, {15*4, 48}, 0}, // C
{{3|(5<<4)}, {15*5, 48}, 0}, // V
{{3|(6<<4)}, {15*6, 48}, 0}, // B
{{3|(7<<4)}, {15*7, 48}, 0}, // N
{{3|(8<<4)}, {15*8, 48}, 0}, // M
{{3|(9<<4)}, {15*9, 48}, 0}, // ,
{{3|(10<<4)}, {15*10, 48}, 0}, // .
{{3|(11<<4)}, {15*11, 48}, 0}, // /
{{3|(2<<4)}, {15*2, 48}, 4}, // Z
{{3|(3<<4)}, {15*3, 48}, 4}, // X
{{3|(4<<4)}, {15*4, 48}, 4}, // C
{{3|(5<<4)}, {15*5, 48}, 4}, // V
{{3|(6<<4)}, {15*6, 48}, 4}, // B
{{3|(7<<4)}, {15*7, 48}, 4}, // N
{{3|(8<<4)}, {15*8, 48}, 4}, // M
{{3|(9<<4)}, {15*9, 48}, 4}, // ,
{{3|(10<<4)}, {15*10, 48}, 4}, // .
{{3|(11<<4)}, {15*11, 48}, 4}, // /
{{3|(12<<4)}, {15*12.75, 48}, 1}, // Shift
{{3|(13<<4)}, {15*14, 48}, 1}, // Up
{{3|(14<<4)}, {15*15, 48}, 1}, // Pgdn

{{4|(0<<4)}, {15*0.25, 64}, 1}, // Ctrl
{{4|(1<<4)}, {15*1.5, 64}, 1}, // GUI
{{4|(2<<4)}, {15*2.25, 64}, 1}, // Alt
{{4|(3<<4)}, {15*6.75, 64}, 0}, // Space
{{4|(3<<4)}, {15*6.75, 64}, 4}, // Space
{{4|(9<<4)}, {15*9, 64}, 1}, // RAlt
{{4|(10<<4)}, {15*10.25, 64}, 1}, // FN
{{4|(12<<4)}, {15*13, 64}, 1}, // Left
Expand Down
Loading

0 comments on commit 20c1650

Please sign in to comment.