Skip to content

Commit

Permalink
Merge pull request #32 from zsa/per_key_matrix_effects_part_1
Browse files Browse the repository at this point in the history
Update to RGB Matrix LED structure
  • Loading branch information
fdidron authored May 20, 2019
2 parents 689303e + 0554bce commit 5cb5e04
Show file tree
Hide file tree
Showing 53 changed files with 849 additions and 807 deletions.
2 changes: 1 addition & 1 deletion keyboards/ergodox_ez/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_COUNT 2
#define DRIVER_1_LED_TOTAL 24
#define DRIVER_2_LED_TOTAL 24
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)

// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF
/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */
Expand Down
99 changes: 35 additions & 64 deletions keyboards/ergodox_ez/ergodox_ez.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,68 +269,39 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
};


const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {

/*{row | col << 4}
| {x=0..224, y=0..64}
| | modifier
| | | */
{{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 0}, // LED 1 on right > Key 6
{{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 0}, // LED 2 > Key 7
{{10|(0<<4)}, {17.2*10, 12.8*0}, 0}, // LED 3 > Key 8
{{11|(0<<4)}, {17.2*11, 12.8*0}, 0}, // LED 4 > Key 9
{{12|(0<<4)}, {17.2*12, 12.8*0}, 0}, // LED 5 > Key 0

{{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 0}, // LED 6
{{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 0}, // LED 7
{{10|(1<<4)}, {17.2*10, 12.8*1}, 0}, // LED 8
{{11|(1<<4)}, {17.2*11, 12.8*1}, 0}, // LED 9
{{12|(1<<4)}, {17.2*12, 12.8*1}, 0}, // LED 10

{{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 0}, // LED 11
{{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 0}, // LED 12
{{10|(2<<4)}, {17.2*10, 12.8*2}, 0}, // LED 13
{{11|(2<<4)}, {17.2*11, 12.8*2}, 0}, // LED 14
{{12|(2<<4)}, {17.2*12, 12.8*2}, 0}, // LED 15

{{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 0}, // LED 16
{{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 0}, // LED 17
{{10|(3<<4)}, {17.2*10, 12.8*3}, 0}, // LED 18
{{11|(3<<4)}, {17.2*11, 12.8*3}, 0}, // LED 19
{{12|(3<<4)}, {17.2*12, 12.8*3}, 0}, // LED 20

{{ 9|(4<<4)}, {17.2* 9, 12.8*4}, 1}, // LED 21
{{10|(4<<4)}, {17.2*10, 12.8*4}, 1}, // LED 22
{{11|(4<<4)}, {17.2*11, 12.8*4}, 1}, // LED 23
{{12|(4<<4)}, {17.2*12, 12.8*4}, 1}, // LED 24

{{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 0}, // LED 1 on left > Key 5
{{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 0}, // LED 2 > Key 4
{{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 0}, // LED 3 > Key 3
{{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 0}, // LED 4 > Key 2
{{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 0}, // LED 5 > Key 1

{{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 0}, // LED 6
{{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 0}, // LED 7
{{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 0}, // LED 8
{{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 0}, // LED 9
{{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 0}, // LED 10

{{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 0}, // LED 11
{{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 0}, // LED 12
{{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 0}, // LED 13
{{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 0}, // LED 14
{{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 0}, // LED 15

{{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 0}, // LED 16
{{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 0}, // LED 17
{{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 0}, // LED 18
{{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 0}, // LED 19
{{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 0}, // LED 20

{{ 4|(4<<4)}, {17.2* 4, 12.8*4}, 1}, // LED 21
{{ 3|(4<<4)}, {17.2* 3, 12.8*4}, 1}, // LED 22
{{ 2|(4<<4)}, {17.2* 2, 12.8*4}, 1}, // LED 23
{{ 1|(4<<4)}, {17.2* 1, 12.8*4}, 1}, // LED 24 > Key Hack
};
led_config_t g_led_config = { {
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
{ 28, 33, 38, 43, 47, NO_LED },
{ 27, 32, 37, 42, 46, NO_LED },
{ 26, 31, 36, 41, 45, NO_LED },
{ 25, 30, 35, 40, 44, NO_LED },
{ 24, 29, 34, 39, NO_LED, NO_LED },
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
{ 0, 5, 10, 15, NO_LED, NO_LED },
{ 1, 6, 11, 16, 20, NO_LED },
{ 2, 7, 12, 17, 21, NO_LED },
{ 3, 8, 13, 18, 22, NO_LED },
{ 4, 9, 14, 19, 23, NO_LED },
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }
}, {
{ 137, 0 }, { 154, 0 }, { 172, 0 }, { 189, 0 }, { 206, 0 }, { 137, 12 },
{ 154, 12 }, { 172, 12 }, { 189, 12 }, { 206, 12 }, { 137, 25 }, { 154, 25 },
{ 172, 25 }, { 189, 25 }, { 206, 25 }, { 137, 38 }, { 154, 38 }, { 172, 38 },
{ 189, 38 }, { 206, 38 }, { 154, 51 }, { 172, 51 }, { 189, 51 }, { 206, 51 },
{ 86, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 86, 12 },
{ 68, 12 }, { 51, 12 }, { 34, 12 }, { 17, 12 }, { 86, 25 }, { 68, 25 },
{ 51, 25 }, { 34, 25 }, { 17, 25 }, { 86, 38 }, { 68, 38 }, { 51, 38 },
{ 34, 38 }, { 17, 38 }, { 68, 51 }, { 51, 51 }, { 34, 51 }, { 17, 51 }
}, {
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4,
4, 4, 1, 1, 1, 1
} };

#endif
2 changes: 2 additions & 0 deletions keyboards/ergodox_ez/keymaps/glow/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ RGBLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes # enable later

SRC += ../default/keymap.c

LINK_TIME_OPTIMIZATION_ENABLE = yes
6 changes: 6 additions & 0 deletions keyboards/ergodox_ez/keymaps/reactive/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#pragma once

#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS

#define DISABLE_RGB_MATRIX_DIGITAL_RAIN
#define DISABLE_RGB_MATRIX_ALPHAS_MODS
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
#define DISABLE_RGB_MATRIX_SPLASH
#define DISABLE_RGB_MATRIX_SOLID_SPLASH
3 changes: 3 additions & 0 deletions keyboards/ergodox_ez/keymaps/reactive/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ RGBLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes # enable later

SRC += ../default/keymap.c

LINK_TIME_OPTIMIZATION_ENABLE = yes
COMMAND_ENABLE = no
1 change: 1 addition & 0 deletions keyboards/planck/ez/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@
#define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL

#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
78 changes: 21 additions & 57 deletions keyboards/planck/ez/ez.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,27 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {

};

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}, 0},
{{0|(2<<4)}, {20.36*2, 21.33*0}, 0},
{{0|(3<<4)}, {20.36*3, 21.33*0}, 0},
{{0|(4<<4)}, {20.36*4, 21.33*0}, 0},
{{0|(5<<4)}, {20.36*5, 21.33*0}, 0},
{{4|(0<<4)}, {20.36*6, 21.33*0}, 0},
{{4|(1<<4)}, {20.36*7, 21.33*0}, 0},
{{4|(2<<4)}, {20.36*8, 21.33*0}, 0},
{{4|(3<<4)}, {20.36*9, 21.33*0}, 0},
{{4|(4<<4)}, {20.36*10,21.33*0}, 0},
{{4|(5<<4)}, {20.36*11,21.33*0}, 1},

{{1|(0<<4)}, {20.36*0, 21.33*1}, 1},
{{1|(1<<4)}, {20.36*1, 21.33*1}, 0},
{{1|(2<<4)}, {20.36*2, 21.33*1}, 0},
{{1|(3<<4)}, {20.36*3, 21.33*1}, 0},
{{1|(4<<4)}, {20.36*4, 21.33*1}, 0},
{{1|(5<<4)}, {20.36*5, 21.33*1}, 0},
{{5|(0<<4)}, {20.36*6, 21.33*1}, 0},
{{5|(1<<4)}, {20.36*7, 21.33*1}, 0},
{{5|(2<<4)}, {20.36*8, 21.33*1}, 0},
{{5|(3<<4)}, {20.36*9, 21.33*1}, 0},
{{5|(4<<4)}, {20.36*10,21.33*1}, 0},
{{5|(5<<4)}, {20.36*11,21.33*1}, 1},

{{2|(0<<4)}, {20.36*0, 21.33*2}, 1},
{{2|(1<<4)}, {20.36*1, 21.33*2}, 0},
{{2|(2<<4)}, {20.36*2, 21.33*2}, 0},
{{2|(3<<4)}, {20.36*3, 21.33*2}, 0},
{{2|(4<<4)}, {20.36*4, 21.33*2}, 0},
{{2|(5<<4)}, {20.36*5, 21.33*2}, 0},
{{6|(0<<4)}, {20.36*6, 21.33*2}, 0},
{{6|(1<<4)}, {20.36*7, 21.33*2}, 0},
{{6|(2<<4)}, {20.36*8, 21.33*2}, 0},
{{6|(3<<4)}, {20.36*9, 21.33*2}, 0},
{{6|(4<<4)}, {20.36*10,21.33*2}, 0},
{{6|(5<<4)}, {20.36*11,21.33*2}, 1},

{{3|(0<<4)}, {20.36*0, 21.33*3}, 1},
{{3|(1<<4)}, {20.36*1, 21.33*3}, 1},
{{3|(2<<4)}, {20.36*2, 21.33*3}, 1},
{{7|(3<<4)}, {20.36*3, 21.33*3}, 1},
{{7|(4<<4)}, {20.36*4, 21.33*3}, 1},
{{7|(5<<4)}, {20.36*5.5,21.33*3}, 0},
{{7|(0<<4)}, {20.36*7, 21.33*3}, 1},
{{7|(1<<4)}, {20.36*8, 21.33*3}, 1},
{{7|(2<<4)}, {20.36*9, 21.33*3}, 1},
{{3|(3<<4)}, {20.36*10,21.33*3}, 1},
{{3|(4<<4)}, {20.36*11,21.33*3}, 1}
};
led_config_t g_led_config = { {
{ 0, 1, 2, 3, 4, 5 },
{ 12, 13, 14, 15, 16, 17 },
{ 24, 25, 26, 27, 28, 29 },
{ 36, 37, 38, 45, 46, NO_LED },
{ 6, 7, 8, 9, 10, 11 },
{ 18, 19, 20, 21, 22, 23 },
{ 30, 31, 32, 33, 34, 35 },
{ 42, 43, 44, 39, 40, 41 }
}, {
{ 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 },
{ 0, 21 }, { 20, 21 }, { 40, 21 }, { 61, 21 }, { 81, 21 }, { 101, 21 }, { 122, 21 }, { 142, 21 }, { 162, 21 }, { 183, 21 }, { 203, 21 }, { 223, 21 },
{ 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 },
{ 0, 63 }, { 20, 63 }, { 40, 63 }, { 61, 63 }, { 81, 63 }, { 111, 63 }, { 142, 63 }, { 162, 63 }, { 183, 63 }, { 203, 63 }, { 223, 63 }
}, {
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1
} };


void matrix_init_kb(void) {
matrix_init_user();
Expand Down
25 changes: 25 additions & 0 deletions lib/lib8tion/trig8.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,30 @@ LIB8STATIC uint8_t cos8( uint8_t theta)
return sin8( theta + 64);
}

/// Fast 16-bit approximation of atan2(x).
/// @returns atan2, value between 0 and 255
LIB8STATIC uint8_t atan2_8(int16_t dy, int16_t dx)
{
if (dy == 0)
{
if (dx >= 0)
return 0;
else
return 128;
}

int16_t abs_y = dy > 0 ? dy : -dy;
int8_t a;

if (dx >= 0)
a = 32 - (32 * (dx - abs_y) / (dx + abs_y));
else
a = 96 - (32 * (dx + abs_y) / (abs_y - dx));

if (dy < 0)
return -a; // negate if in quad III or IV
return a;
}

///@}
#endif
4 changes: 4 additions & 0 deletions quantum/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ RGB hsv_to_rgb( HSV hsv )

if ( hsv.s == 0 )
{
#ifdef USE_CIE1931_CURVE
rgb.r = rgb.g = rgb.b = pgm_read_byte( &CIE1931_CURVE[hsv.v] );
#else
rgb.r = hsv.v;
rgb.g = hsv.v;
rgb.b = hsv.v;
#endif
return rgb;
}

Expand Down
2 changes: 1 addition & 1 deletion quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef HAPTIC_ENABLE
process_haptic(keycode, record) &&
#endif //HAPTIC_ENABLE
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
#if defined(RGB_MATRIX_ENABLE)
process_rgb_matrix(keycode, record) &&
#endif
process_record_kb(keycode, record) &&
Expand Down
Loading

0 comments on commit 5cb5e04

Please sign in to comment.