aboutsummaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2017-09-06 14:49:19 -0700
committerGitHub <noreply@github.com>2017-09-06 14:49:19 -0700
commit4580d3a730c078484ea417575c617c17598b5a39 (patch)
tree6b180261bde6124a189b054a0657faa480e571c5 /quantum
parent0ce45eb0b7ad0af28de4418906543c51dbc505cc (diff)
downloadfirmware-4580d3a730c078484ea417575c617c17598b5a39.tar.gz
firmware-4580d3a730c078484ea417575c617c17598b5a39.tar.bz2
firmware-4580d3a730c078484ea417575c617c17598b5a39.zip
RGB improvements (#1684)
* Allow the knight animation to be restricted to a portion of the LED strip * Add keys for jumping directly to particular animation modes * Remove orphaned break statements * Tweak the `RGB_MODE` buttons so they cycle through the same mode. * small indentation fix
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c158
-rw-r--r--quantum/quantum_keycodes.h16
-rw-r--r--quantum/rgblight.c24
-rw-r--r--quantum/rgblight.h10
4 files changed, 147 insertions, 61 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 87975ef99..285e1e81e 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -249,105 +249,153 @@ bool process_record_quantum(keyrecord_t *record) {
if (record->event.pressed) {
reset_keyboard();
}
- return false;
- break;
+ return false;
case DEBUG:
if (record->event.pressed) {
debug_enable = true;
print("DEBUG: enabled.\n");
}
- return false;
- break;
+ return false;
#ifdef FAUXCLICKY_ENABLE
case FC_TOG:
if (record->event.pressed) {
FAUXCLICKY_TOGGLE;
}
return false;
- break;
case FC_ON:
if (record->event.pressed) {
FAUXCLICKY_ON;
}
return false;
- break;
case FC_OFF:
if (record->event.pressed) {
FAUXCLICKY_OFF;
}
return false;
- break;
#endif
- #ifdef RGBLIGHT_ENABLE
- case RGB_TOG:
- if (record->event.pressed) {
- rgblight_toggle();
- }
- return false;
- break;
- case RGB_MOD:
- if (record->event.pressed) {
- rgblight_step();
- }
- return false;
- break;
- case RGB_HUI:
- if (record->event.pressed) {
- rgblight_increase_hue();
+ #ifdef RGBLIGHT_ENABLE
+ case RGB_TOG:
+ if (record->event.pressed) {
+ rgblight_toggle();
+ }
+ return false;
+ case RGB_MOD:
+ if (record->event.pressed) {
+ rgblight_step();
+ }
+ return false;
+ case RGB_HUI:
+ if (record->event.pressed) {
+ rgblight_increase_hue();
+ }
+ return false;
+ case RGB_HUD:
+ if (record->event.pressed) {
+ rgblight_decrease_hue();
+ }
+ return false;
+ case RGB_SAI:
+ if (record->event.pressed) {
+ rgblight_increase_sat();
+ }
+ return false;
+ case RGB_SAD:
+ if (record->event.pressed) {
+ rgblight_decrease_sat();
+ }
+ return false;
+ case RGB_VAI:
+ if (record->event.pressed) {
+ rgblight_increase_val();
+ }
+ return false;
+ case RGB_VAD:
+ if (record->event.pressed) {
+ rgblight_decrease_val();
+ }
+ return false;
+ case RGB_MODE_PLAIN:
+ if (record->event.pressed) {
+ rgblight_mode(1);
+ }
+ return false;
+ case RGB_MODE_BREATHE:
+ if (record->event.pressed) {
+ if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(2);
}
- return false;
- break;
- case RGB_HUD:
- if (record->event.pressed) {
- rgblight_decrease_hue();
+ }
+ return false;
+ case RGB_MODE_RAINBOW:
+ if (record->event.pressed) {
+ if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(6);
}
- return false;
- break;
- case RGB_SAI:
- if (record->event.pressed) {
- rgblight_increase_sat();
+ }
+ return false;
+ case RGB_MODE_SWIRL:
+ if (record->event.pressed) {
+ if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(9);
}
- return false;
- break;
- case RGB_SAD:
- if (record->event.pressed) {
- rgblight_decrease_sat();
+ }
+ return false;
+ case RGB_MODE_SNAKE:
+ if (record->event.pressed) {
+ if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(15);
}
- return false;
- break;
- case RGB_VAI:
- if (record->event.pressed) {
- rgblight_increase_val();
+ }
+ return false;
+ case RGB_MODE_KNIGHT:
+ if (record->event.pressed) {
+ if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(21);
}
- return false;
- break;
- case RGB_VAD:
- if (record->event.pressed) {
- rgblight_decrease_val();
+ }
+ return false;
+ case RGB_MODE_XMAS:
+ if (record->event.pressed) {
+ rgblight_mode(24);
+ }
+ return false;
+ case RGB_MODE_GRADIENT:
+ if (record->event.pressed) {
+ if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) {
+ rgblight_step();
+ } else {
+ rgblight_mode(25);
}
- return false;
- break;
- #endif
+ }
+ return false;
+ #endif
#ifdef PROTOCOL_LUFA
case OUT_AUTO:
if (record->event.pressed) {
set_output(OUTPUT_AUTO);
}
return false;
- break;
case OUT_USB:
if (record->event.pressed) {
set_output(OUTPUT_USB);
}
return false;
- break;
#ifdef BLUETOOTH_ENABLE
case OUT_BT:
if (record->event.pressed) {
set_output(OUTPUT_BLUETOOTH);
}
return false;
- break;
#endif
#endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
@@ -454,7 +502,6 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_LSFT));
}
return false;
- // break;
}
case KC_RSPC: {
@@ -477,7 +524,6 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_RSFT));
}
return false;
- // break;
}
case GRAVE_ESC: {
uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 1bb6706ba..ccd4565f5 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -401,6 +401,14 @@ enum quantum_keycodes {
RGB_SAD,
RGB_VAI,
RGB_VAD,
+ RGB_MODE_PLAIN,
+ RGB_MODE_BREATHE,
+ RGB_MODE_RAINBOW,
+ RGB_MODE_SWIRL,
+ RGB_MODE_SNAKE,
+ RGB_MODE_KNIGHT,
+ RGB_MODE_XMAS,
+ RGB_MODE_GRADIENT,
// Left shift, open paren
KC_LSPO,
@@ -534,6 +542,14 @@ enum quantum_keycodes {
#define KC_GESC GRAVE_ESC
+#define RGB_M_P RGB_MODE_PLAIN
+#define RGB_M_B RGB_MODE_BREATHE
+#define RGB_M_R RGB_MODE_RAINBOW
+#define RGB_M_SW RGB_MODE_SWIRL
+#define RGB_M_SN RGB_MODE_SNAKE
+#define RGB_M_K RGB_MODE_KNIGHT
+#define RGB_M_X RGB_MODE_XMAS
+#define RGB_M_G RGB_MODE_GRADIENT
// L-ayer, T-ap - 256 keycode max, 16 layer max
#define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8))
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 1b5076450..5ae6e69d6 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -22,7 +22,6 @@
#include "debug.h"
#include "led_tables.h"
-
__attribute__ ((weak))
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
__attribute__ ((weak))
@@ -32,7 +31,7 @@ const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
__attribute__ ((weak))
const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20};
__attribute__ ((weak))
-const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20};
+const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
__attribute__ ((weak))
const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
@@ -197,6 +196,14 @@ void rgblight_step_reverse(void) {
rgblight_mode(mode);
}
+uint32_t rgblight_get_mode(void) {
+ if (!rgblight_config.enable) {
+ return false;
+ }
+
+ return rgblight_config.mode;
+}
+
void rgblight_mode(uint8_t mode) {
if (!rgblight_config.enable) {
return;
@@ -220,6 +227,8 @@ void rgblight_mode(uint8_t mode) {
// MODE 9-14, rainbow swirl
// MODE 15-20, snake
// MODE 21-23, knight
+ // MODE 24, xmas
+ // MODE 25-34, static rainbow
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_enable();
@@ -550,7 +559,14 @@ void rgblight_effect_knight(uint8_t interval) {
static int8_t increment = 1;
uint8_t i, cur;
+ // Set all the LEDs to 0
for (i = 0; i < RGBLED_NUM; i++) {
+ led[i].r = 0;
+ led[i].g = 0;
+ led[i].b = 0;
+ }
+ // Determine which LEDs should be lit up
+ for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
if (i >= low_bound && i <= high_bound) {
@@ -563,10 +579,12 @@ void rgblight_effect_knight(uint8_t interval) {
}
rgblight_set();
+ // Move from low_bound to high_bound changing the direction we increment each
+ // time a boundary is hit.
low_bound += increment;
high_bound += increment;
- if (high_bound <= 0 || low_bound >= RGBLED_NUM - 1) {
+ if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) {
increment = -increment;
}
}
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index d0dd6e490..7acd5a257 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -23,16 +23,21 @@
#endif
#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
-#define RGBLIGHT_EFFECT_SNAKE_LENGTH 7
+#define RGBLIGHT_EFFECT_SNAKE_LENGTH 4
#endif
#ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH
-#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7
+#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3
#endif
+
#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0
#endif
+#ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM
+#define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM
+#endif
+
#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL
#define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000
#endif
@@ -85,6 +90,7 @@ void rgblight_toggle(void);
void rgblight_enable(void);
void rgblight_step(void);
void rgblight_step_reverse(void);
+uint32_t rgblight_get_mode(void);
void rgblight_mode(uint8_t mode);
void rgblight_set(void);
void rgblight_update_dword(uint32_t dword);