Simple RGB backlight theming

This commit is contained in:
Priyadi Iman Nurcahyo 2017-04-30 18:04:58 +07:00
parent 2f28652dcc
commit 343f8d368e
5 changed files with 161 additions and 72 deletions

View File

@ -0,0 +1,15 @@
#define COLOR_BLANK 0, 0, 0
#define COLOR_BLACK 0, 0, 0
#define COLOR_WHITE 15,15,15
#define COLOR_GRAY 7, 7, 7
#define COLOR_RED 15, 0, 0
#define COLOR_GREEN 0,15, 0
#define COLOR_BLUE 0, 0,15
#define COLOR_YELLOW 15,15, 0
#define COLOR_MAGENTA 15, 0,15
#define COLOR_CYAN 0,15,15
#define COLOR_ORANGE 15, 5, 0

View File

@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum.h"
#ifdef RGBSPS_ENABLE
#include "rgbsps.h"
#include "rgbtheme.h"
#endif
#ifdef PS2_MOUSE_ENABLE
#include "ps2_mouse.h"
@ -42,13 +43,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#undef FAUXCLICKY_OFF
#define FAUXCLICKY_OFF do { \
fauxclicky_enabled = false; \
rgbsps_set(LED_AUDIO, 0, 0, 0); \
rgbsps_set(LED_AUDIO, COLOR_BLANK); \
fauxclicky_stop(); \
} while (0)
#undef FAUXCLICKY_ON
#define FAUXCLICKY_ON do { \
fauxclicky_enabled = true; \
rgbsps_set(LED_AUDIO, 8, 0, 8); \
rgbsps_set(LED_AUDIO, THEME_COLOR_AUDIO); \
} while (0)
#endif
#endif
@ -469,33 +470,33 @@ const uint8_t PROGMEM LED_TRACKPOINT[] = {
void led_turnoff_keys(void) {
for(uint8_t i = 0; i < COUNT(LED_ALNUM); i++) {
rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), 0, 0, 0);
rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), COLOR_BLACK);
}
for(uint8_t i = 0; i < COUNT(LED_MODS); i++) {
rgbsps_set(pgm_read_byte(&LED_MODS[i]), 0, 0, 0);
rgbsps_set(pgm_read_byte(&LED_MODS[i]), COLOR_BLACK);
}
for(uint8_t i = 0; i < COUNT(LED_FN); i++) {
rgbsps_set(pgm_read_byte(&LED_FN[i]), 0, 0, 0);
rgbsps_set(pgm_read_byte(&LED_FN[i]), COLOR_BLACK);
}
}
#ifdef RGBSPS_DEMO_ENABLE
void led_demo(void) {
rgbsps_set(LED_IND_LINUX, 15, 15, 15);
rgbsps_set(LED_IND_APPLE, 15, 15, 15);
rgbsps_set(LED_IND_WINDOWS, 15, 15, 15);
rgbsps_set(LED_IND_QWERTY, 15, 10, 0);
rgbsps_set(LED_IND_ALT, 15, 10, 0);
rgbsps_set(LED_IND_AUDIO, 5, 11, 13);
rgbsps_set(LED_IND_BLUETOOTH, 0, 0, 15);
rgbsps_set(LED_IND_USB, 15, 15, 15);
rgbsps_set(LED_IND_CAPSLOCK, 15, 0, 0);
rgbsps_set(LED_IND_GUI, 15, 0, 15);
rgbsps_set(LED_IND_FUN, 15, 0, 0);
rgbsps_set(LED_IND_NUM, 0, 0, 15);
rgbsps_set(LED_IND_PUNC, 0, 15, 0);
rgbsps_set(LED_IND_GREEK, 0, 15, 15);
rgbsps_set(LED_IND_EMOJI, 15, 15, 0);
rgbsps_set(LED_IND_LINUX, THEME_COLOR_LINUX);
rgbsps_set(LED_IND_APPLE, THEME_COLOR_APPLE);
rgbsps_set(LED_IND_WINDOWS, THEME_COLOR_WINDOWS);
rgbsps_set(LED_IND_QWERTY, THEME_COLOR_QWERTY);
rgbsps_set(LED_IND_ALT, THEME_COLOR_ALT);
rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
rgbsps_set(LED_IND_BLUETOOTH, THEME_COLOR_BLUETOOTH);
rgbsps_set(LED_IND_USB, THEME_COLOR_USB);
rgbsps_set(LED_IND_CAPSLOCK, THEME_COLOR_CAPSLOCK);
rgbsps_set(LED_IND_GUI, THEME_COLOR_GUI);
rgbsps_set(LED_IND_FUN, THEME_COLOR_FUN);
rgbsps_set(LED_IND_NUM, THEME_COLOR_NUM);
rgbsps_set(LED_IND_PUNC, THEME_COLOR_PUNC);
rgbsps_set(LED_IND_GREEK, THEME_COLOR_GREEK);
rgbsps_set(LED_IND_EMOJI, THEME_COLOR_EMOJI);
rgbsps_send();
}
#endif
@ -508,26 +509,26 @@ void led_reset(void) {
case GLOW_MIN:
led_turnoff_keys();
for(uint8_t i = 0; i < COUNT(LED_HOMING); i++) {
rgbsps_set(pgm_read_byte(&LED_HOMING[i]), 8, 8, 8);
rgbsps_set(pgm_read_byte(&LED_HOMING[i]), THEME_COLOR_GLOW1_HOME);
}
rgbsps_set(LED_F, 15, 0, 0);
rgbsps_set(LED_J, 15, 0, 0);
rgbsps_set(LED_F, THEME_COLOR_GLOW1_HOMING);
rgbsps_set(LED_J, THEME_COLOR_GLOW1_HOMING);
break;
case GLOW_FULL:
for(uint8_t i = 0; i < COUNT(LED_ALNUM); i++) {
rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), 8, 8, 8);
rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), THEME_COLOR_GLOW2_ALPHA);
}
for(uint8_t i = 0; i < COUNT(LED_MODS); i++) {
rgbsps_set(pgm_read_byte(&LED_MODS[i]), 0, 15, 0);
rgbsps_set(pgm_read_byte(&LED_MODS[i]), THEME_COLOR_GLOW2_MODS);
}
for(uint8_t i = 0; i < COUNT(LED_FN); i++) {
rgbsps_set(pgm_read_byte(&LED_FN[i]), 0, 0, 15);
rgbsps_set(pgm_read_byte(&LED_FN[i]), THEME_COLOR_GLOW2_FN);
}
for(uint8_t i = 0; i < COUNT(LED_HOMING); i++) {
rgbsps_set(pgm_read_byte(&LED_HOMING[i]), 15, 0, 0);
rgbsps_set(pgm_read_byte(&LED_HOMING[i]), THEME_COLOR_GLOW2_HOME);
}
rgbsps_set(LED_F, 15, 15, 0);
rgbsps_set(LED_J, 15, 15, 0);
rgbsps_set(LED_F, THEME_COLOR_GLOW2_HOMING);
rgbsps_set(LED_J, THEME_COLOR_GLOW2_HOMING);
break;
}
}
@ -535,11 +536,11 @@ void led_reset(void) {
void led_set_default_layer_indicator(void) {
uint8_t default_layer = biton32(default_layer_state);
if (default_layer == _QWERTY) {
rgbsps_set(LED_IND_QWERTY, 15, 10, 0);
rgbsps_set(LED_IND_ALT, 0, 0, 0);
rgbsps_set(LED_IND_QWERTY, THEME_COLOR_QWERTY);
rgbsps_set(LED_IND_ALT, COLOR_BLANK);
} else {
rgbsps_set(LED_IND_QWERTY, 0, 0, 0);
rgbsps_set(LED_IND_ALT, 15, 10, 0);
rgbsps_set(LED_IND_QWERTY, COLOR_BLANK);
rgbsps_set(LED_IND_ALT, THEME_COLOR_ALT);
}
rgbsps_send();
return;
@ -550,12 +551,12 @@ void led_set_layer_indicator(void) {
led_reset();
rgbsps_set(LED_IND_GUI, 0, 0, 0);
rgbsps_set(LED_IND_FUN, 0, 0, 0);
rgbsps_set(LED_IND_NUM, 0, 0, 0);
rgbsps_set(LED_IND_PUNC, 0, 0, 0);
rgbsps_set(LED_IND_GREEK, 0, 0, 0);
rgbsps_set(LED_IND_EMOJI, 0, 0, 0);
rgbsps_set(LED_IND_GUI, COLOR_BLANK);
rgbsps_set(LED_IND_FUN, COLOR_BLANK);
rgbsps_set(LED_IND_NUM, COLOR_BLANK);
rgbsps_set(LED_IND_PUNC, COLOR_BLANK);
rgbsps_set(LED_IND_GREEK, COLOR_BLANK);
rgbsps_set(LED_IND_EMOJI, COLOR_BLANK);
uint8_t layer = biton32(layer_state);
if (oldlayer == layer) {
@ -571,71 +572,71 @@ void led_set_layer_indicator(void) {
switch(layer) {
case _GUI:
rgbsps_set(LED_IND_GUI, 15, 0, 15);
rgbsps_set(LED_IND_GUI, THEME_COLOR_GUI);
break;
case _FUN:
rgbsps_set(LED_IND_FUN, 15, 0, 0);
rgbsps_set(LED_IND_FUN, THEME_COLOR_FUN);
break;
case _NUM:
rgbsps_set(LED_IND_NUM, 0, 0, 15);
rgbsps_set(LED_IND_NUM, THEME_COLOR_NUM);
break;
case _PUNC:
rgbsps_set(LED_IND_PUNC, 0, 15, 0);
rgbsps_set(LED_IND_PUNC, THEME_COLOR_PUNC);
break;
case _GREEKL:
case _GREEKU:
rgbsps_set(LED_IND_GREEK, 0, 15, 15);
rgbsps_set(LED_IND_GREEK, THEME_COLOR_GREEK);
break;
case _EMOJI:
rgbsps_set(LED_IND_EMOJI, 15, 15, 0);
rgbsps_set(LED_IND_EMOJI, THEME_COLOR_EMOJI);
break;
default:
rgbsps_set(LED_IND_GUI, 3, 3, 3);
rgbsps_set(LED_IND_FUN, 3, 3, 3);
rgbsps_set(LED_IND_NUM, 3, 3, 3);
rgbsps_set(LED_IND_PUNC, 3, 3, 3);
rgbsps_set(LED_IND_GREEK, 3, 3, 3);
rgbsps_set(LED_IND_EMOJI, 3, 3, 3);
rgbsps_set(LED_IND_GUI, THEME_COLOR_OTHERLAYER);
rgbsps_set(LED_IND_FUN, THEME_COLOR_OTHERLAYER);
rgbsps_set(LED_IND_NUM, THEME_COLOR_OTHERLAYER);
rgbsps_set(LED_IND_PUNC, THEME_COLOR_OTHERLAYER);
rgbsps_set(LED_IND_GREEK, THEME_COLOR_OTHERLAYER);
rgbsps_set(LED_IND_EMOJI, THEME_COLOR_OTHERLAYER);
}
rgbsps_send();
}
void led_set_unicode_input_mode(void) {
rgbsps_set(LED_IND_LINUX, 0, 0, 0);
rgbsps_set(LED_IND_APPLE, 0, 0, 0);
rgbsps_set(LED_IND_WINDOWS, 0, 0, 0);
rgbsps_set(LED_IND_LINUX, COLOR_BLANK);
rgbsps_set(LED_IND_APPLE, COLOR_BLANK);
rgbsps_set(LED_IND_WINDOWS, COLOR_BLANK);
switch (get_unicode_input_mode()) {
case UC_LNX:
rgbsps_set(LED_IND_LINUX, 15, 15, 15);
rgbsps_set(LED_IND_LINUX, THEME_COLOR_LINUX);
break;
case UC_OSX:
rgbsps_set(LED_IND_APPLE, 15, 15, 15);
rgbsps_set(LED_IND_APPLE, THEME_COLOR_APPLE);
break;
case UC_WIN:
case UC_WINC:
rgbsps_set(LED_IND_WINDOWS, 15, 15, 15);
rgbsps_set(LED_IND_WINDOWS, THEME_COLOR_WINDOWS);
break;
}
rgbsps_send();
}
void led_set_output_ble(void) {
rgbsps_set(LED_IND_BLUETOOTH, 0, 0, 15);
rgbsps_set(LED_IND_USB, 0, 0, 0);
rgbsps_set(LED_IND_BLUETOOTH, THEME_COLOR_BLUETOOTH);
rgbsps_set(LED_IND_USB, COLOR_BLANK);
rgbsps_send();
}
void led_set_output_usb(void) {
rgbsps_set(LED_IND_BLUETOOTH, 0, 0, 0);
rgbsps_set(LED_IND_USB, 15, 15, 15);
rgbsps_set(LED_IND_BLUETOOTH, COLOR_BLANK);
rgbsps_set(LED_IND_USB, THEME_COLOR_USB);
rgbsps_send();
}
void led_set_output_none(void) {
rgbsps_set(LED_IND_BLUETOOTH, 0, 0, 0);
rgbsps_set(LED_IND_USB, 0, 0, 0);
rgbsps_set(LED_IND_BLUETOOTH, COLOR_BLANK);
rgbsps_set(LED_IND_USB, COLOR_BLANK);
rgbsps_send();
}
@ -644,9 +645,9 @@ void led_init(void) {
rgbsps_turnoff();
// set trackpoint color
rgbsps_set(LED_TRACKPOINT1, 15, 0, 0);
rgbsps_set(LED_TRACKPOINT2, 0, 0, 15);
rgbsps_set(LED_TRACKPOINT3, 15, 0, 0);
rgbsps_set(LED_TRACKPOINT1, THEME_COLOR_TP1);
rgbsps_set(LED_TRACKPOINT2, THEME_COLOR_TP2);
rgbsps_set(LED_TRACKPOINT3, THEME_COLOR_TP3);
// unicode input mode
led_set_unicode_input_mode();
@ -658,9 +659,9 @@ void led_init(void) {
// clicky
#ifdef FAUXCLICKY_ENABLE
if (fauxclicky_enabled) {
rgbsps_set(LED_IND_AUDIO, 5, 11, 13);
rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
} else {
rgbsps_set(LED_IND_AUDIO, 0, 0, 0);
rgbsps_set(LED_IND_AUDIO, COLOR_BLANK);
}
#endif
@ -1244,9 +1245,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case FC_TOG:
#ifdef RGBSPS_ENABLE
if (fauxclicky_enabled) {
rgbsps_set(LED_IND_AUDIO, 5, 11, 13);
rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
} else {
rgbsps_set(LED_IND_AUDIO, 0, 0, 0);
rgbsps_set(LED_IND_AUDIO, COLOR_BLANK);
}
rgbsps_send();
#endif
@ -1320,9 +1321,9 @@ void turn_off_capslock() {
bool new_capslock = usb_led & (1<<USB_LED_CAPS_LOCK);
if (new_capslock ^ capslock) { // capslock state is different
if ((capslock = new_capslock)) {
rgbsps_set(LED_IND_CAPSLOCK, 15, 0, 0);
rgbsps_set(LED_IND_CAPSLOCK, THEME_COLOR_CAPSLOCK);
} else {
rgbsps_set(LED_IND_CAPSLOCK, 0, 0, 0);
rgbsps_set(LED_IND_CAPSLOCK, COLOR_BLANK);
}
rgbsps_send();
}

View File

@ -0,0 +1 @@
#include "rgbtheme_default.h"

View File

@ -0,0 +1,36 @@
#include "color.h"
#define THEME_COLOR_LINUX COLOR_WHITE
#define THEME_COLOR_APPLE COLOR_WHITE
#define THEME_COLOR_WINDOWS COLOR_WHITE
#define THEME_COLOR_QWERTY COLOR_RED
#define THEME_COLOR_ALT COLOR_RED
#define THEME_COLOR_AUDIO COLOR_GREEN
#define THEME_COLOR_BLUETOOTH 7,7,15
#define THEME_COLOR_USB COLOR_WHITE
#define THEME_COLOR_CAPSLOCK COLOR_RED
#define THEME_COLOR_GUI COLOR_MAGENTA
#define THEME_COLOR_FUN COLOR_RED
#define THEME_COLOR_NUM 7,7,15
#define THEME_COLOR_PUNC COLOR_GREEN
#define THEME_COLOR_GREEK COLOR_CYAN
#define THEME_COLOR_EMOJI COLOR_YELLOW
#define THEME_COLOR_OTHERLAYER COLOR_GRAY
#define THEME_COLOR_GLOW1_HOME COLOR_ORANGE
#define THEME_COLOR_GLOW1_HOMING COLOR_RED
#define THEME_COLOR_GLOW2_ALPHA COLOR_ORANGE
#define THEME_COLOR_GLOW2_MODS COLOR_ORANGE
#define THEME_COLOR_GLOW2_FN COLOR_ORANGE
#define THEME_COLOR_GLOW2_HOME COLOR_ORANGE
#define THEME_COLOR_GLOW2_HOMING COLOR_RED
#define THEME_COLOR_TP1 COLOR_ORANGE
#define THEME_COLOR_TP2 COLOR_RED
#define THEME_COLOR_TP3 COLOR_ORANGE

View File

@ -0,0 +1,36 @@
#include "color.h"
#define THEME_COLOR_LINUX COLOR_WHITE
#define THEME_COLOR_APPLE COLOR_WHITE
#define THEME_COLOR_WINDOWS COLOR_WHITE
#define THEME_COLOR_QWERTY COLOR_RED
#define THEME_COLOR_ALT COLOR_RED
#define THEME_COLOR_AUDIO COLOR_GREEN
#define THEME_COLOR_BLUETOOTH COLOR_BLUE
#define THEME_COLOR_USB COLOR_WHITE
#define THEME_COLOR_CAPSLOCK COLOR_RED
#define THEME_COLOR_GUI COLOR_MAGENTA
#define THEME_COLOR_FUN COLOR_RED
#define THEME_COLOR_NUM COLOR_BLUE
#define THEME_COLOR_PUNC COLOR_GREEN
#define THEME_COLOR_GREEK COLOR_CYAN
#define THEME_COLOR_EMOJI COLOR_YELLOW
#define THEME_COLOR_OTHERLAYER COLOR_GRAY
#define THEME_COLOR_GLOW1_HOME COLOR_GRAY
#define THEME_COLOR_GLOW1_HOMING COLOR_RED
#define THEME_COLOR_GLOW2_ALPHA COLOR_GRAY
#define THEME_COLOR_GLOW2_MODS COLOR_GREEN
#define THEME_COLOR_GLOW2_FN COLOR_BLUE
#define THEME_COLOR_GLOW2_HOME COLOR_RED
#define THEME_COLOR_GLOW2_HOMING COLOR_YELLOW
#define THEME_COLOR_TP1 COLOR_RED
#define THEME_COLOR_TP2 COLOR_BLUE
#define THEME_COLOR_TP3 COLOR_RED