diff options
| author | Drashna Jaelre <drashna@live.com> | 2021-07-31 06:09:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-31 06:09:47 -0700 |
| commit | e755c5fe1f92ad6f34088b457ce0d170f316a940 (patch) | |
| tree | 731d9b1160304b6cc0545a5fbf4bce09edc4c090 | |
| parent | fb6c66a14b3b7eb51381b938aa96dd56718d0e17 (diff) | |
| download | qmk_firmware-e755c5fe1f92ad6f34088b457ce0d170f316a940.tar.gz qmk_firmware-e755c5fe1f92ad6f34088b457ce0d170f316a940.zip | |
[Keyboard] Fix RGBKB Pan Rev1 Encoder RGB handling (#13781)
| -rw-r--r-- | keyboards/rgbkb/pan/pan.c | 99 | ||||
| -rw-r--r-- | keyboards/rgbkb/pan/rev1/rules.mk | 3 |
2 files changed, 76 insertions, 26 deletions
diff --git a/keyboards/rgbkb/pan/pan.c b/keyboards/rgbkb/pan/pan.c index bc438f2d0..c367550e4 100644 --- a/keyboards/rgbkb/pan/pan.c +++ b/keyboards/rgbkb/pan/pan.c | |||
| @@ -1,24 +1,70 @@ | |||
| 1 | /* Copyright 2020 RGBKB | 1 | /* Copyright 2020 RGBKB |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation, either version 2 of the License, or | 5 | * the Free Software Foundation, either version 2 of the License, or |
| 6 | * (at your option) any later version. | 6 | * (at your option) any later version. |
| 7 | * | 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
| 12 | * | 12 | * |
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include "pan.h" | 16 | #include "pan.h" |
| 17 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | #include "rgb_matrix_types.h" | 18 | #include "rgb_matrix_types.h" |
| 19 | 19 | ||
| 20 | |||
| 21 | #if defined RGB_MATRIX_ENABLE | 20 | #if defined RGB_MATRIX_ENABLE |
| 21 | # if defined(KEYBOARD_rgbkb_pan_rev1) | ||
| 22 | # include "ws2812.h" | ||
| 23 | |||
| 24 | // LED color buffer | ||
| 25 | LED_TYPE rgb_matrix_ws2812_array[DRIVER_LED_TOTAL]; | ||
| 26 | |||
| 27 | static void init(void) {} | ||
| 28 | |||
| 29 | static void flush(void) { | ||
| 30 | // Assumes use of RGB_DI_PIN | ||
| 31 | ws2812_setleds(rgb_matrix_ws2812_array, DRIVER_LED_TOTAL); | ||
| 32 | } | ||
| 33 | |||
| 34 | // Set an led in the buffer to a color | ||
| 35 | static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { | ||
| 36 | # if defined(RGB_ENCODERS) || defined(STAGGERED_RGB_ENCODERS) | ||
| 37 | if (i == 0 || i == 1) { // if encoder LEDs, change LEDs | ||
| 38 | rgb_matrix_ws2812_array[i].r = g; | ||
| 39 | rgb_matrix_ws2812_array[i].g = b; | ||
| 40 | rgb_matrix_ws2812_array[i].b = r; | ||
| 41 | } else | ||
| 42 | # endif | ||
| 43 | { | ||
| 44 | rgb_matrix_ws2812_array[i].r = r; | ||
| 45 | rgb_matrix_ws2812_array[i].g = g; | ||
| 46 | rgb_matrix_ws2812_array[i].b = b; | ||
| 47 | } | ||
| 48 | # ifdef RGBW | ||
| 49 | convert_rgb_to_rgbw(&rgb_matrix_ws2812_array[i]); | ||
| 50 | # endif | ||
| 51 | } | ||
| 52 | |||
| 53 | static void setled_all(uint8_t r, uint8_t g, uint8_t b) { | ||
| 54 | for (int i = 0; i < sizeof(rgb_matrix_ws2812_array) / sizeof(rgb_matrix_ws2812_array[0]); i++) { | ||
| 55 | setled(i, r, g, b); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | const rgb_matrix_driver_t rgb_matrix_driver = { | ||
| 60 | .init = init, | ||
| 61 | .flush = flush, | ||
| 62 | .set_color = setled, | ||
| 63 | .set_color_all = setled_all, | ||
| 64 | }; | ||
| 65 | # endif | ||
| 66 | |||
| 67 | // clang-format off | ||
| 22 | led_config_t g_led_config = { { | 68 | led_config_t g_led_config = { { |
| 23 | { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, | 69 | { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }, |
| 24 | { 0, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15 }, | 70 | { 0, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15 }, |
| @@ -26,14 +72,14 @@ | |||
| 26 | { 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40 }, | 72 | { 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40 }, |
| 27 | { 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, NO_LED } | 73 | { 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, NO_LED } |
| 28 | }, { | 74 | }, { |
| 29 | #ifdef STAGGERED_RGB_ENCODERS | 75 | # ifdef STAGGERED_RGB_ENCODERS |
| 30 | {0, -19},{228, -19}, | 76 | {0, -19},{228, -19}, |
| 31 | {0, 0}, {14, 0}, {33, 0}, {52, 0}, {71, 0}, {90, 0}, {109, 0}, {128, 0}, {147, 0}, {166, 0}, {185, 0}, {204, 0}, {223, 0}, | 77 | {0, 0}, {14, 0}, {33, 0}, {52, 0}, {71, 0}, {90, 0}, {109, 0}, {128, 0}, {147, 0}, {166, 0}, {185, 0}, {204, 0}, {223, 0}, |
| 32 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, | 78 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, |
| 33 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, | 79 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, |
| 34 | {223, 57}, {204, 57}, {185, 57}, {171, 57}, {147, 57}, {128, 57}, {109, 57}, {90, 57}, {71, 57}, {52, 57}, {33, 57}, {14, 57}, {0, 57}, | 80 | {223, 57}, {204, 57}, {185, 57}, {171, 57}, {147, 57}, {128, 57}, {109, 57}, {90, 57}, {71, 57}, {52, 57}, {33, 57}, {14, 57}, {0, 57}, |
| 35 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, | 81 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, |
| 36 | #elif defined RGB_ENCODERS | 82 | # elif defined RGB_ENCODERS |
| 37 | {0, -19},{228, -19}, | 83 | {0, -19},{228, -19}, |
| 38 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, | 84 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, |
| 39 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, | 85 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, |
| @@ -41,48 +87,49 @@ | |||
| 41 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, | 87 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, |
| 42 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, | 88 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, |
| 43 | {0, 95},{19, 95}, //not used | 89 | {0, 95},{19, 95}, //not used |
| 44 | #elif defined STAGGERED_LAYOUT | 90 | # elif defined STAGGERED_LAYOUT |
| 45 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, {0, 0}, | 91 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, {0, 0}, |
| 46 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, | 92 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, |
| 47 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, | 93 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, |
| 48 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, {0, 0}, | 94 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, {0, 0}, |
| 49 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, | 95 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, |
| 50 | {0, 95},{19, 95},//not used | 96 | {0, 95},{19, 95},//not used |
| 51 | #else | 97 | # else |
| 52 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, | 98 | {0, 0}, {19, 0}, {38, 0}, {57, 0}, {76, 0}, {95, 0}, {114, 0}, {133, 0}, {152, 0}, {171, 0}, {190, 0}, {209, 0}, |
| 53 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, | 99 | {209, 19}, {190, 19}, {171, 19}, {152, 19}, {133, 19}, {114, 19}, {95, 19}, {76, 19}, {57, 19}, {38, 19}, {19, 19}, {0, 19}, |
| 54 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, | 100 | {0, 38}, {19, 38}, {38, 38}, {57, 38}, {76, 38}, {95, 38}, {114, 38}, {133, 38}, {152, 38}, {171, 38}, {190, 38}, {209, 38}, |
| 55 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, | 101 | {209, 57}, {190, 57}, {171, 57}, {152, 57}, {133, 57}, {114, 57}, {95, 57}, {76, 57}, {57, 57}, {38, 57}, {19, 57}, {0, 57}, |
| 56 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, | 102 | {0, 76}, {19, 76}, {38, 76}, {57, 76}, {76, 76}, {95, 76}, {114, 76}, {133, 76}, {152, 76}, {171, 76}, {190, 76}, {209, 76}, |
| 57 | {0, 0},{0, 0}, {0, 0},{0, 0},//not used | 103 | {0, 0},{0, 0}, {0, 0},{0, 0},//not used |
| 58 | #endif | 104 | # endif |
| 59 | }, { | 105 | }, { |
| 60 | #ifdef STAGGERED_RGB_ENCODERS | 106 | # ifdef STAGGERED_RGB_ENCODERS |
| 61 | 1, 1, | 107 | 1, 1, |
| 62 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 108 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 63 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 109 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 64 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 110 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 65 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 111 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 66 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | 112 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 |
| 67 | #elif defined RGB_ENCODERS | 113 | # elif defined RGB_ENCODERS |
| 68 | 1, 1, | 114 | 1, 1, |
| 69 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 115 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 70 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 116 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 71 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 117 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 72 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 118 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 73 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | 119 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 |
| 74 | #elif defined STAGGERED_LAYOUT | 120 | # elif defined STAGGERED_LAYOUT |
| 75 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 121 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 76 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 122 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 77 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 123 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 78 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 124 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 79 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | 125 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 |
| 80 | #else | 126 | # else |
| 81 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 127 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 82 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 128 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 83 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 129 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 84 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, | 130 | 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, |
| 85 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | 131 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 |
| 86 | #endif | 132 | # endif |
| 87 | } }; | 133 | } }; |
| 134 | // clang-format on | ||
| 88 | #endif | 135 | #endif |
diff --git a/keyboards/rgbkb/pan/rev1/rules.mk b/keyboards/rgbkb/pan/rev1/rules.mk index 4d3c0f667..667c29005 100644 --- a/keyboards/rgbkb/pan/rev1/rules.mk +++ b/keyboards/rgbkb/pan/rev1/rules.mk | |||
| @@ -1,2 +1,5 @@ | |||
| 1 | # The default configuration is a atmega32a | 1 | # The default configuration is a atmega32a |
| 2 | DEFAULT_FOLDER = rgbkb/pan/rev1/32a | 2 | DEFAULT_FOLDER = rgbkb/pan/rev1/32a |
| 3 | |||
| 4 | RGB_MATRIX_DRIVER = custom | ||
| 5 | WS2812_DRIVER_REQUIRED := yes | ||
