summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common_features.mk24
-rw-r--r--drivers/arm/ws2812.c1
-rw-r--r--drivers/arm/ws2812_pwm.c1
-rw-r--r--drivers/arm/ws2812_spi.c1
-rw-r--r--drivers/avr/ws2812_i2c.c31
-rw-r--r--quantum/template/ps2avrgb/rules.mk6
-rw-r--r--quantum/template/ps2avrgb/template.c44
-rw-r--r--tmk_core/protocol/vusb/main.c9
8 files changed, 82 insertions, 35 deletions
diff --git a/common_features.mk b/common_features.mk
index a4af319fc6..cfa0358e51 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -112,7 +112,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
else
- SRC += ws2812.c
+ WS2812_DRIVER_REQUIRED = yes
endif
endif
@@ -176,7 +176,7 @@ endif
ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
OPT_DEFS += -DWS2812
- SRC += ws2812.c
+ WS2812_DRIVER_REQUIRED = yes
endif
ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
@@ -244,6 +244,26 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
endif
endif
+VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
+
+WS2812_DRIVER ?= bitbang
+ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
+ ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
+ $(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
+ endif
+
+ ifeq ($(strip $(WS2812_DRIVER)), bitbang)
+ SRC += ws2812.c
+ else
+ SRC += ws2812_$(strip $(WS2812_DRIVER)).c
+ endif
+
+ # add extra deps
+ ifeq ($(strip $(WS2812_DRIVER)), i2c)
+ QUANTUM_LIB_SRC += i2c_master.c
+ endif
+endif
+
ifeq ($(strip $(CIE1931_CURVE)), yes)
OPT_DEFS += -DUSE_CIE1931_CURVE
LED_TABLES = yes
diff --git a/drivers/arm/ws2812.c b/drivers/arm/ws2812.c
new file mode 100644
index 0000000000..2094e50098
--- /dev/null
+++ b/drivers/arm/ws2812.c
@@ -0,0 +1 @@
+#error("NOT SUPPORTED") \ No newline at end of file
diff --git a/drivers/arm/ws2812_pwm.c b/drivers/arm/ws2812_pwm.c
new file mode 100644
index 0000000000..2094e50098
--- /dev/null
+++ b/drivers/arm/ws2812_pwm.c
@@ -0,0 +1 @@
+#error("NOT SUPPORTED") \ No newline at end of file
diff --git a/drivers/arm/ws2812_spi.c b/drivers/arm/ws2812_spi.c
new file mode 100644
index 0000000000..2094e50098
--- /dev/null
+++ b/drivers/arm/ws2812_spi.c
@@ -0,0 +1 @@
+#error("NOT SUPPORTED") \ No newline at end of file
diff --git a/drivers/avr/ws2812_i2c.c b/drivers/avr/ws2812_i2c.c
new file mode 100644
index 0000000000..8525a026c7
--- /dev/null
+++ b/drivers/avr/ws2812_i2c.c
@@ -0,0 +1,31 @@
+#include "ws2812.h"
+#include "i2c_master.h"
+
+#ifndef WS2812_ADDRESS
+# define WS2812_ADDRESS 0xb0
+#endif
+
+#ifndef WS2812_TIMEOUT
+# define WS2812_TIMEOUT 100
+#endif
+
+void ws2812_init(void) { i2c_init(); }
+
+// Setleds for standard RGB
+void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
+ static bool s_init = false;
+ if (!s_init) {
+ ws2812_init();
+ s_init = true;
+ }
+
+ i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT);
+}
+
+// Setleds for SK6812RGBW
+void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
+// not supported - for now error out if its enabled
+#ifdef RGBW
+# error "RGBW not supported"
+#endif
+}
diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk
index 69554cd308..52d9988125 100644
--- a/quantum/template/ps2avrgb/rules.mk
+++ b/quantum/template/ps2avrgb/rules.mk
@@ -14,9 +14,7 @@ EXTRAKEY_ENABLE = yes
CONSOLE_ENABLE = yes
COMMAND_ENABLE = yes
BACKLIGHT_ENABLE = no
-RGBLIGHT_ENABLE = no
-RGBLIGHT_CUSTOM_DRIVER = yes
+RGBLIGHT_ENABLE = yes
+WS2812_DRIVER = i2c
OPT_DEFS = -DDEBUG_LEVEL=0
-
-SRC += i2c_master.c
diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c
index acc8698f56..503da7ca71 100644
--- a/quantum/template/ps2avrgb/template.c
+++ b/quantum/template/ps2avrgb/template.c
@@ -15,44 +15,30 @@
*/
#include "%KEYBOARD%.h"
-#ifdef RGBLIGHT_ENABLE
-# include <string.h>
-# include "i2c_master.h"
-# include "rgblight.h"
+// Optional override functions below.
+// You can leave any or all of these undefined.
+// These are only required if you want to perform custom actions.
-extern rgblight_config_t rgblight_config;
+/*
void matrix_init_kb(void) {
- i2c_init();
- // call user level keymaps, if any
- matrix_init_user();
-}
-
-// custom RGB driver
-void rgblight_set(void) {
- if (!rgblight_config.enable) {
- memset(led, 0, 3 * RGBLED_NUM);
- }
+ // put your keyboard start-up code here
+ // runs once when the firmware starts up
- i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
+ matrix_init_user();
}
-bool rgb_init = false;
-
void matrix_scan_kb(void) {
- // if LEDs were previously on before poweroff, turn them back on
- if (rgb_init == false && rgblight_config.enable) {
- i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
- rgb_init = true;
- }
-
- rgblight_task();
- matrix_scan_user();
+ // put your looping keyboard code here
+ // runs every cycle (a lot)
+
+ matrix_scan_user();
}
-#endif
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+ // put your per-action keyboard code here
+ // runs for every action, just before processing by the firmware
-__attribute__ ((weak))
-void matrix_scan_user(void) {
+ return process_record_user(keycode, record);
}
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index f8322d94ac..8cc736497d 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -20,6 +20,11 @@
#include "timer.h"
#include "uart.h"
#include "debug.h"
+#include "rgblight_reconfig.h"
+
+#if (defined(RGB_MIDI) | defined(RGBLIGHT_ANIMATIONS)) & defined(RGBLIGHT_ENABLE)
+# include "rgblight.h"
+#endif
#define UART_BAUD_RATE 115200
@@ -94,6 +99,10 @@ int main(void) {
// To prevent failing to configure NOT scan keyboard during configuration
if (usbConfiguration && usbInterruptIsReady()) {
keyboard_task();
+
+#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE)
+ rgblight_task();
+#endif
}
vusb_transfer_keyboard();
}