Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/ws2812 matrix driver #5418

Merged
merged 2 commits into from
Apr 15, 2019

Conversation

XScorpion2
Copy link
Contributor

@XScorpion2 XScorpion2 commented Mar 16, 2019

Added rgb matrix led driver for ws2812 addressable LEDs.

Description

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Copy link
Contributor

@yanfali yanfali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick scan it looks good. How can I test ? What flags do I need to set to try it out?

@yanfali
Copy link
Contributor

yanfali commented Mar 16, 2019

I guess this needs documentation since I don't know how to turn it on

@XScorpion2
Copy link
Contributor Author

@yanfali in your rules.mk file you set the rgb matrix to use this driver via:
RGB_MATRIX_ENABLE = WS2812
Then follow the normal rules for rgb matrix and ws2812 led defines to connect pins and what not correctly. The gist is that a board using rgblight can switch to rgb matrix easily by defining the g_rgb_leds and then turning off rgblight and turning on rgb matrix. Will add some more details to rgb matrix docs here shortly.

@yanfali
Copy link
Contributor

yanfali commented Mar 17, 2019

So I'm trying to test this feature, but I have no idea how to structure g_rgb_leds. Can you provide some examples of what this is supposed to look like for a RGB strip where everything ie basically in a single row?

@yanfali
Copy link
Contributor

yanfali commented Mar 18, 2019

OK, I got some info, tested this on an XD84 by replacing rgblight with rgbmatrix.

Compiling: tmk_core/common/action_util.c                                                            [OK]
diff --git a/keyboards/xd84/keymaps/yanfali/config.h b/keyboards/xd84/keymaps/yanfali/config.h
index f8e5c7396..61e5d67e4 100644
--- a/keyboards/xd84/keymaps/yanfali/config.h
+++ b/keyboards/xd84/keymaps/yanfali/config.h
@@ -1,2 +1,3 @@
 #undef RGBLED_NUM
 #define RGBLED_NUM 20
+#define DRIVER_LED_TOTAL RGBLED_NUM
diff --git a/keyboards/xd84/keymaps/yanfali/keymap.c b/keyboards/xd84/keymaps/yanfali/keymap.c
index bccc31365..763e1530d 100644
--- a/keyboards/xd84/keymaps/yanfali/keymap.c
+++ b/keyboards/xd84/keymaps/yanfali/keymap.c
@@ -36,3 +36,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 /* └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ */
   )
 };
+
+#ifdef RGB_MATRIX_ENABLE
+  const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
+    // Left Hand Mapped Left to Right
+    { {  0xFF }, {   0,  0 }, 0},
+    { {  0xFF }, {   0,  1 }, 0},
+    { {  0xFF }, {   0,  2 }, 0},
+    { {  0xFF }, {   0,  3 }, 0},
+    { {  0xFF }, {   0,  4 }, 0},
+    { {  0xFF }, {   0,  5 }, 0},
+    { {  0xFF }, {   0,  6 }, 0},
+    { {  0xFF }, {   1,  7 }, 0},
+    { {  0xFF }, {   2,  8 }, 0},
+    { {  0xFF }, {   1,  9 }, 0},
+    { {  0xFF }, {   2,  10 }, 0},
+    { {  0xFF }, {   1,  11 }, 0},
+    { {  0xFF }, {   2,  12 }, 0},
+    { {  0xFF }, {   1,  13 }, 0},
+    { {  0xFF }, {   2,  14 }, 0},
+    { {  0xFF }, {   1,  15 }, 0},
+    { {  0xFF }, {   2,  16 }, 0},
+    { {  0xFF }, {   1,  17 }, 0},
+    { {  0xFF }, {   2,  18 }, 0},
+    { {  0xFF }, {   1,  19 }, 0},
+  };
+#endif
diff --git a/keyboards/xd84/keymaps/yanfali/rules.mk b/keyboards/xd84/keymaps/yanfali/rules.mk
index 17c7c431e..74d33bb73 100644
--- a/keyboards/xd84/keymaps/yanfali/rules.mk
+++ b/keyboards/xd84/keymaps/yanfali/rules.mk
@@ -1,2 +1,4 @@
 CONSOLE_ENABLE = yes        # Console for debug(+400)
 COMMAND_ENABLE = yes        # Commands for debug and configuration
+RGB_MATRIX_ENABLE = WS2812
+RGBLIGHT_ENABLE = no

Used 2 light strips, one with 7 LEDs and one with 13. Was a very fun light show. This seems like a good addition.

Copy link
Contributor

@yanfali yanfali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a fun addition. Let's add this, I'm sure people with crkbd and sol keyboards will get a kick out of this. On normal RGB strips it's a little frenetic but very fun.

@Lenbok
Copy link
Contributor

Lenbok commented Mar 20, 2019

What would be required in order to use this for some LEDs in a single series and allow rgblight to control other LEDs in the series?

(The general ability to arbitrarily assign LEDs between rgbmatrix and rgblight effects could be quite cool, and you could get quite cool behaviours happening even on a keyboard that only had per-key LEDs, e.g. by assigning outer LEDs to rgblight)

@XScorpion2
Copy link
Contributor Author

@Lenbok we would need to setup quite a bit more in logic to understand which block which system was responsible for operating under.

Though in the long term, I don't that is a very good idea to implement. Both systems essentially do the same thing: run some animation code against a block of LEDs. So why does there need to be two different systems? The only answer to that is performance as today rgblight is more performant than rgbmatrix. Personally I'd rather migrate the animations that rgblight does into rgbmatrix then just have rgbmatrix as the gold standard for all lighting. Especially since there is a ton of room in that system for doing really efficient and dynamic effects, such as the possibility for 1 animation on the keys while another animation on the under/back/side lighting all in one system.

@XScorpion2 XScorpion2 force-pushed the features/ws2812_matrix_driver branch from 354ec47 to a13defd Compare March 23, 2019 21:56
@XScorpion2
Copy link
Contributor Author

Force push rebase on latest master

@XScorpion2 XScorpion2 force-pushed the features/ws2812_matrix_driver branch from a13defd to 82bc0ad Compare April 3, 2019 01:45
@XScorpion2
Copy link
Contributor Author

Rebased on master after the rgb matrix overhaul pr
Also added driver configuration docs
Come get some RGB!

Copy link
Member

@fauxpark fauxpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this out on a prototype 4x4 midi/macro pad, it looks fantastic! 👍

@drashna drashna requested a review from noroadsleft April 3, 2019 17:47
Copy link
Contributor

@r2d2rogers r2d2rogers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this out on a crkbd and approve of this feature!

@Lenbok
Copy link
Contributor

Lenbok commented Apr 5, 2019

@r2d2rogers Do you have a commit somewhere that demonstrates how to do this so I can have a play on my crkbd?

@r2d2rogers
Copy link
Contributor

@Lenbok look at my branch at https://github.com/r2d2rogers/qmk_firmware/tree/WSmatrix

It has some other PRs in the mix, but that's where I have the matrix setup for crkbd, you might find some bugs in the order for the opposite hand. I'll check in discord when I get to work if you have questions.

@XScorpion2 XScorpion2 force-pushed the features/ws2812_matrix_driver branch from 985d9ce to 91d7303 Compare April 14, 2019 13:28
@XScorpion2
Copy link
Contributor Author

Rebased on lasted master to fix merge errors

@drashna
Copy link
Member

drashna commented Apr 14, 2019

Passes Drashna CI.

Copy link
Contributor

@mechmerlin mechmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=)

@mechmerlin mechmerlin merged commit 5fcd744 into qmk:master Apr 15, 2019
@XScorpion2 XScorpion2 deleted the features/ws2812_matrix_driver branch April 15, 2019 03:13
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Apr 17, 2019
* WS2812 driver implementation for RGB Matrix

* Added driver configuration docs
fdidron added a commit to zsa/qmk_firmware that referenced this pull request Apr 18, 2019
shimesaba-type0 pushed a commit to shimesaba-type0/qmk_firmware that referenced this pull request Jun 22, 2019
* WS2812 driver implementation for RGB Matrix

* Added driver configuration docs
Timbus pushed a commit to Timbus/qmk_firmware that referenced this pull request Jun 23, 2019
* WS2812 driver implementation for RGB Matrix

* Added driver configuration docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants