diff options
| author | Luiz Ribeiro <luizribeiro@gmail.com> | 2017-06-10 12:40:32 -0400 |
|---|---|---|
| committer | Luiz Ribeiro <luizribeiro@gmail.com> | 2017-06-11 12:30:48 -0400 |
| commit | d4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d (patch) | |
| tree | 8f62acf6a849da7f7c61c18635b905ba8cd63132 | |
| parent | 964d7060e1176d487a1f9dfe9bb76b491983748d (diff) | |
| download | qmk_firmware-d4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d.tar.gz qmk_firmware-d4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d.zip | |
Added a build flag for using a custom rgblight driver
| -rw-r--r-- | build_keyboard.mk | 8 | ||||
| -rwxr-xr-x | keyboards/ps2avrGB/program | 2 | ||||
| -rw-r--r-- | keyboards/ps2avrGB/rules.mk | 2 | ||||
| -rwxr-xr-x | quantum/light_ws2812.h | 18 | ||||
| -rw-r--r-- | quantum/rgblight.c | 3 | ||||
| -rw-r--r-- | quantum/rgblight.h | 3 | ||||
| -rw-r--r-- | quantum/rgblight_types.h | 44 |
7 files changed, 57 insertions, 23 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index dc9e5dad6..550440cbc 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -198,12 +198,14 @@ endif | |||
| 198 | 198 | ||
| 199 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | 199 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) |
| 200 | OPT_DEFS += -DRGBLIGHT_ENABLE | 200 | OPT_DEFS += -DRGBLIGHT_ENABLE |
| 201 | ifneq ($(strip $(DISABLE_WS2812)), yes) | ||
| 202 | SRC += $(QUANTUM_DIR)/light_ws2812.c | ||
| 203 | endif | ||
| 204 | SRC += $(QUANTUM_DIR)/rgblight.c | 201 | SRC += $(QUANTUM_DIR)/rgblight.c |
| 205 | CIE1931_CURVE = yes | 202 | CIE1931_CURVE = yes |
| 206 | LED_BREATHING_TABLE = yes | 203 | LED_BREATHING_TABLE = yes |
| 204 | ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes) | ||
| 205 | OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER | ||
| 206 | else | ||
| 207 | SRC += $(QUANTUM_DIR)/light_ws2812.c | ||
| 208 | endif | ||
| 207 | endif | 209 | endif |
| 208 | 210 | ||
| 209 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | 211 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) |
diff --git a/keyboards/ps2avrGB/program b/keyboards/ps2avrGB/program index a88d9cd9b..081a8219c 100755 --- a/keyboards/ps2avrGB/program +++ b/keyboards/ps2avrGB/program | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3.5 |
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> |
| 3 | # | 3 | # |
| 4 | # This program is free software: you can redistribute it and/or modify | 4 | # This program is free software: you can redistribute it and/or modify |
diff --git a/keyboards/ps2avrGB/rules.mk b/keyboards/ps2avrGB/rules.mk index 9fb27efed..9e76993c4 100644 --- a/keyboards/ps2avrGB/rules.mk +++ b/keyboards/ps2avrGB/rules.mk | |||
| @@ -32,7 +32,7 @@ CONSOLE_ENABLE = yes | |||
| 32 | COMMAND_ENABLE = yes | 32 | COMMAND_ENABLE = yes |
| 33 | BACKLIGHT_ENABLE = no | 33 | BACKLIGHT_ENABLE = no |
| 34 | RGBLIGHT_ENABLE = yes | 34 | RGBLIGHT_ENABLE = yes |
| 35 | DISABLE_WS2812 = yes | 35 | RGBLIGHT_CUSTOM_DRIVER = yes |
| 36 | 36 | ||
| 37 | OPT_DEFS = -DDEBUG_LEVEL=0 | 37 | OPT_DEFS = -DDEBUG_LEVEL=0 |
| 38 | OPT_DEFS += -DBOOTLOADER_SIZE=2048 | 38 | OPT_DEFS += -DBOOTLOADER_SIZE=2048 |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 60924a0fb..f7e0c3144 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
| @@ -28,23 +28,7 @@ | |||
| 28 | //#include "ws2812_config.h" | 28 | //#include "ws2812_config.h" |
| 29 | //#include "i2cmaster.h" | 29 | //#include "i2cmaster.h" |
| 30 | 30 | ||
| 31 | #ifdef RGBW | 31 | #include "rgblight_types.h" |
| 32 | #define LED_TYPE struct cRGBW | ||
| 33 | #else | ||
| 34 | #define LED_TYPE struct cRGB | ||
| 35 | #endif | ||
| 36 | |||
| 37 | |||
| 38 | /* | ||
| 39 | * Structure of the LED array | ||
| 40 | * | ||
| 41 | * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106 | ||
| 42 | * cRGBW: RGBW for SK6812RGBW | ||
| 43 | */ | ||
| 44 | |||
| 45 | struct cRGB { uint8_t g; uint8_t r; uint8_t b; }; | ||
| 46 | struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;}; | ||
| 47 | |||
| 48 | 32 | ||
| 49 | 33 | ||
| 50 | /* User Interface | 34 | /* User Interface |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 4eec2a776..49420de37 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -364,7 +364,7 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | |||
| 364 | rgblight_set(); | 364 | rgblight_set(); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | __attribute__ ((weak)) | 367 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 368 | void rgblight_set(void) { | 368 | void rgblight_set(void) { |
| 369 | if (rgblight_config.enable) { | 369 | if (rgblight_config.enable) { |
| 370 | #ifdef RGBW | 370 | #ifdef RGBW |
| @@ -385,6 +385,7 @@ void rgblight_set(void) { | |||
| 385 | #endif | 385 | #endif |
| 386 | } | 386 | } |
| 387 | } | 387 | } |
| 388 | #endif | ||
| 388 | 389 | ||
| 389 | #ifdef RGBLIGHT_ANIMATIONS | 390 | #ifdef RGBLIGHT_ANIMATIONS |
| 390 | 391 | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 92130192c..6b609da7f 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -61,7 +61,10 @@ | |||
| 61 | #include <stdint.h> | 61 | #include <stdint.h> |
| 62 | #include <stdbool.h> | 62 | #include <stdbool.h> |
| 63 | #include "eeconfig.h" | 63 | #include "eeconfig.h" |
| 64 | #ifndef RGBLIGHT_CUSTOM_DRIVER | ||
| 64 | #include "light_ws2812.h" | 65 | #include "light_ws2812.h" |
| 66 | #endif | ||
| 67 | #include "rgblight_types.h" | ||
| 65 | 68 | ||
| 66 | extern LED_TYPE led[RGBLED_NUM]; | 69 | extern LED_TYPE led[RGBLED_NUM]; |
| 67 | 70 | ||
diff --git a/quantum/rgblight_types.h b/quantum/rgblight_types.h new file mode 100644 index 000000000..1d1467a12 --- /dev/null +++ b/quantum/rgblight_types.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | * light weight WS2812 lib include | ||
| 3 | * | ||
| 4 | * Version 2.3 - Nev 29th 2015 | ||
| 5 | * Author: Tim (cpldcpu@gmail.com) | ||
| 6 | * | ||
| 7 | * Please do not change this file! All configuration is handled in "ws2812_config.h" | ||
| 8 | * | ||
| 9 | * This program is free software: you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation, either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef RGBLIGHT_TYPES | ||
| 24 | |||
| 25 | #include <avr/io.h> | ||
| 26 | |||
| 27 | #ifdef RGBW | ||
| 28 | #define LED_TYPE struct cRGBW | ||
| 29 | #else | ||
| 30 | #define LED_TYPE struct cRGB | ||
| 31 | #endif | ||
| 32 | |||
| 33 | |||
| 34 | /* | ||
| 35 | * Structure of the LED array | ||
| 36 | * | ||
| 37 | * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106 | ||
| 38 | * cRGBW: RGBW for SK6812RGBW | ||
| 39 | */ | ||
| 40 | |||
| 41 | struct cRGB { uint8_t g; uint8_t r; uint8_t b; }; | ||
| 42 | struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;}; | ||
| 43 | |||
| 44 | #endif | ||
