aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Ribeiro <luizribeiro@gmail.com>2017-06-10 12:40:32 -0400
committerLuiz Ribeiro <luizribeiro@gmail.com>2017-06-11 12:30:48 -0400
commitd4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d (patch)
tree8f62acf6a849da7f7c61c18635b905ba8cd63132
parent964d7060e1176d487a1f9dfe9bb76b491983748d (diff)
downloadqmk_firmware-d4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d.tar.gz
qmk_firmware-d4cd5dda5c3e3c5b8b8d4db5d0bbed2fec0c770d.zip
Added a build flag for using a custom rgblight driver
-rw-r--r--build_keyboard.mk8
-rwxr-xr-xkeyboards/ps2avrGB/program2
-rw-r--r--keyboards/ps2avrGB/rules.mk2
-rwxr-xr-xquantum/light_ws2812.h18
-rw-r--r--quantum/rgblight.c3
-rw-r--r--quantum/rgblight.h3
-rw-r--r--quantum/rgblight_types.h44
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
199ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) 199ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
200 OPT_DEFS += -DRGBLIGHT_ENABLE 200 OPT_DEFS += -DRGBLIGHT_ENABLE
201ifneq ($(strip $(DISABLE_WS2812)), yes)
202 SRC += $(QUANTUM_DIR)/light_ws2812.c
203endif
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
204ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
205 OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
206else
207 SRC += $(QUANTUM_DIR)/light_ws2812.c
208endif
207endif 209endif
208 210
209ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) 211ifeq ($(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
32COMMAND_ENABLE = yes 32COMMAND_ENABLE = yes
33BACKLIGHT_ENABLE = no 33BACKLIGHT_ENABLE = no
34RGBLIGHT_ENABLE = yes 34RGBLIGHT_ENABLE = yes
35DISABLE_WS2812 = yes 35RGBLIGHT_CUSTOM_DRIVER = yes
36 36
37OPT_DEFS = -DDEBUG_LEVEL=0 37OPT_DEFS = -DDEBUG_LEVEL=0
38OPT_DEFS += -DBOOTLOADER_SIZE=2048 38OPT_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
45struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
46struct 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
368void rgblight_set(void) { 368void 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
66extern LED_TYPE led[RGBLED_NUM]; 69extern 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
41struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
42struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;};
43
44#endif