Add rgblight mode 35 (R,G,B test mode) (#3114)

* add rgblight mode 35 (RGB cyclic mode) into quantum/rgblight.c

* Update docs, add rgblight mode 35(RGB cyclic)

* rename RGBCYCLIC to RGBTEST
This commit is contained in:
Takeshi ISHII 2018-06-05 00:10:39 +09:00 committed by Drashna Jaelre
parent cb91320d6d
commit 5229734647
6 changed files with 48 additions and 5 deletions

View File

@ -146,6 +146,7 @@ These control the RGB Lighting functionality.
|`RGB_MODE_KNIGHT` |`RGB_M_K` |"Knight Rider" animation mode |
|`RGB_MODE_XMAS` |`RGB_M_X` |Christmas animation mode |
|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode |
|`RGB_MODE_RGBTEST `|`RGB_M_T` |Red,Green,Blue test animation mode |
note: for backwards compatibility, `RGB_SMOD` is an alias for `RGB_MOD`.

View File

@ -283,6 +283,7 @@ This is a reference only. Each group of keys links to the page documenting their
|`RGB_MODE_KNIGHT` |`RGB_M_K` |"Knight Rider" animation mode |
|`RGB_MODE_XMAS` |`RGB_M_X` |Christmas animation mode |
|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode |
|`RGB_MODE_RGBTEST` |`RGB_M_T` |Red,Green,Blue test animation mode |
## [RGB Matrix Lighting](feature_rgb_matrix.md)

View File

@ -442,7 +442,12 @@ bool process_record_quantum(keyrecord_t *record) {
}
}
return false;
#endif
case RGB_MODE_RGBTEST:
if (record->event.pressed) {
rgblight_mode(35);
}
return false;
#endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
#ifdef PROTOCOL_LUFA
case OUT_AUTO:
if (record->event.pressed) {

View File

@ -423,6 +423,7 @@ enum quantum_keycodes {
RGB_MODE_KNIGHT,
RGB_MODE_XMAS,
RGB_MODE_GRADIENT,
RGB_MODE_RGBTEST,
// Left shift, open paren
KC_LSPO,
@ -586,6 +587,7 @@ enum quantum_keycodes {
#define RGB_M_K RGB_MODE_KNIGHT
#define RGB_M_X RGB_MODE_XMAS
#define RGB_M_G RGB_MODE_GRADIENT
#define RGB_M_T RGB_MODE_RGBTEST
// L-ayer, T-ap - 256 keycode max, 16 layer max
#define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8))

View File

@ -42,6 +42,8 @@ __attribute__ ((weak))
const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
__attribute__ ((weak))
const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
__attribute__ ((weak))
const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024};
rgblight_config_t rgblight_config;
@ -238,14 +240,15 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_disable();
#endif
} else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) {
} else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) ||
rgblight_config.mode == 35 ) {
// MODE 2-5, breathing
// MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl
// MODE 15-20, snake
// MODE 21-23, knight
// MODE 24, xmas
// MODE 25-34, static rainbow
// MODE 35 RGB test
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_enable();
@ -579,6 +582,9 @@ void rgblight_task(void) {
} else if (rgblight_config.mode == 24) {
// mode = 24, christmas mode
rgblight_effect_christmas();
} else if (rgblight_config.mode == 35) {
// mode = 35, RGB test
rgblight_effect_rgbtest();
}
}
}
@ -734,4 +740,30 @@ void rgblight_effect_christmas(void) {
rgblight_set();
}
#endif
void rgblight_effect_rgbtest(void) {
static uint8_t pos = 0;
static uint16_t last_timer = 0;
static uint8_t maxval = 0;
uint8_t g; uint8_t r; uint8_t b;
if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0])) {
return;
}
if( maxval == 0 ) {
LED_TYPE tmp_led;
sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
maxval = tmp_led.r;
}
last_timer = timer_read();
g = r = b = 0;
switch( pos ) {
case 0: r = maxval; break;
case 1: g = maxval; break;
case 2: b = maxval; break;
}
rgblight_setrgb(r, g, b);
pos = (pos + 1) % 3;
}
#endif /* RGBLIGHT_ANIMATIONS */

View File

@ -17,7 +17,7 @@
#define RGBLIGHT_H
#ifdef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_MODES 34
#define RGBLIGHT_MODES 35
#else
#define RGBLIGHT_MODES 1
#endif
@ -83,6 +83,7 @@ extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM;
extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM;
extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM;
extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM;
typedef union {
uint32_t raw;
@ -160,5 +161,6 @@ void rgblight_effect_rainbow_swirl(uint8_t interval);
void rgblight_effect_snake(uint8_t interval);
void rgblight_effect_knight(uint8_t interval);
void rgblight_effect_christmas(void);
void rgblight_effect_rgbtest(void);
#endif