diff options
| author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2019-05-16 13:11:28 +0900 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-05-15 21:11:28 -0700 |
| commit | 670a9b7f83dacf2b0e9fb42756935a77598c6677 (patch) | |
| tree | e265e0b8f4dbc2df2e0eff45c474a3ce9423b122 /quantum | |
| parent | acd3e79add2d47ab664b831936e5b6e71d3b8e15 (diff) | |
| download | qmk_firmware-670a9b7f83dacf2b0e9fb42756935a77598c6677.tar.gz qmk_firmware-670a9b7f83dacf2b0e9fb42756935a77598c6677.zip | |
Add effect range to rgblight.c (#5856)
* add rgblight_set_effect_range()
* implement effect range
* Arrange the order of function list in rgblight.h .
* update docs/feature_rgblight.md
* fix RGBLIGHT_RAINBOW_SWIRL_RANGE default value
* add example code about Utility Functions
* add example code about direct operation functions
* When RGBLIGHT_SPLIT is defined, the following function has no meaning and is invalidated.
* rgblight_setrgb_master(r, g, b)
* rgblight_setrgb_slave(r, g, b)
* rgblight_sethsv_master(h, s, v)
* rgblight_sethsv_slave(h, s, v)
* add temporary test code for rgblight_set_effect_range
* fix rgblight_effect_knight() bug
* Test End. Revert "add temporary test code for rgblight_set_effect_range"
This reverts commit 5680cddd012d68b2db75a532862a7fef250f8973.
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/rgblight.c | 117 | ||||
| -rw-r--r-- | quantum/rgblight.h | 123 |
2 files changed, 138 insertions, 102 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 77772e292..75e4ef0d8 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -101,19 +101,35 @@ LED_TYPE led[RGBLED_NUM]; | |||
| 101 | 101 | ||
| 102 | static uint8_t clipping_start_pos = 0; | 102 | static uint8_t clipping_start_pos = 0; |
| 103 | static uint8_t clipping_num_leds = RGBLED_NUM; | 103 | static uint8_t clipping_num_leds = RGBLED_NUM; |
| 104 | static uint8_t effect_start_pos = 0; | ||
| 105 | static uint8_t effect_end_pos = RGBLED_NUM; | ||
| 106 | static uint8_t effect_num_leds = RGBLED_NUM; | ||
| 104 | 107 | ||
| 105 | void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) { | 108 | void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) { |
| 106 | clipping_start_pos = start_pos; | 109 | clipping_start_pos = start_pos; |
| 107 | clipping_num_leds = num_leds; | 110 | clipping_num_leds = num_leds; |
| 108 | } | 111 | } |
| 109 | 112 | ||
| 113 | void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) { | ||
| 114 | if (start_pos >= RGBLED_NUM) return; | ||
| 115 | if (start_pos + num_leds > RGBLED_NUM) return; | ||
| 116 | effect_start_pos = start_pos; | ||
| 117 | effect_end_pos = start_pos + num_leds; | ||
| 118 | effect_num_leds = num_leds; | ||
| 119 | } | ||
| 110 | 120 | ||
| 111 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | 121 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { |
| 112 | HSV hsv = { hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val }; | 122 | HSV hsv = { hue, sat, val }; |
| 113 | RGB rgb = hsv_to_rgb(hsv); | 123 | RGB rgb = hsv_to_rgb(hsv); |
| 114 | setrgb(rgb.r, rgb.g, rgb.b, led1); | 124 | setrgb(rgb.r, rgb.g, rgb.b, led1); |
| 115 | } | 125 | } |
| 116 | 126 | ||
| 127 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | ||
| 128 | sethsv_raw( hue, sat, | ||
| 129 | val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, | ||
| 130 | led1); | ||
| 131 | } | ||
| 132 | |||
| 117 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { | 133 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { |
| 118 | (*led1).r = r; | 134 | (*led1).r = r; |
| 119 | (*led1).g = g; | 135 | (*led1).g = g; |
| @@ -501,15 +517,15 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w | |||
| 501 | #else | 517 | #else |
| 502 | uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2]; | 518 | uint8_t range = RGBLED_GRADIENT_RANGES[delta / 2]; |
| 503 | #endif | 519 | #endif |
| 504 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 520 | for (uint8_t i = 0; i < effect_num_leds; i++) { |
| 505 | uint8_t _hue = ((uint16_t)i * (uint16_t)range) / RGBLED_NUM; | 521 | uint8_t _hue = ((uint16_t)i * (uint16_t)range) / effect_num_leds; |
| 506 | if (direction) { | 522 | if (direction) { |
| 507 | _hue = hue + _hue; | 523 | _hue = hue + _hue; |
| 508 | } else { | 524 | } else { |
| 509 | _hue = hue - _hue; | 525 | _hue = hue - _hue; |
| 510 | } | 526 | } |
| 511 | dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); | 527 | dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); |
| 512 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); | 528 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i + effect_start_pos]); |
| 513 | } | 529 | } |
| 514 | rgblight_set(); | 530 | rgblight_set(); |
| 515 | } | 531 | } |
| @@ -557,7 +573,7 @@ uint8_t rgblight_get_val(void) { | |||
| 557 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | 573 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { |
| 558 | if (!rgblight_config.enable) { return; } | 574 | if (!rgblight_config.enable) { return; } |
| 559 | 575 | ||
| 560 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 576 | for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) { |
| 561 | led[i].r = r; | 577 | led[i].r = r; |
| 562 | led[i].g = g; | 578 | led[i].g = g; |
| 563 | led[i].b = b; | 579 | led[i].b = b; |
| @@ -615,6 +631,7 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, | |||
| 615 | rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end); | 631 | rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end); |
| 616 | } | 632 | } |
| 617 | 633 | ||
| 634 | #ifndef RGBLIGHT_SPLIT | ||
| 618 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { | 635 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { |
| 619 | rgblight_setrgb_range(r, g, b, 0 , (uint8_t) RGBLED_NUM/2); | 636 | rgblight_setrgb_range(r, g, b, 0 , (uint8_t) RGBLED_NUM/2); |
| 620 | } | 637 | } |
| @@ -630,36 +647,34 @@ void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { | |||
| 630 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { | 647 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { |
| 631 | rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); | 648 | rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); |
| 632 | } | 649 | } |
| 650 | #endif // ifndef RGBLIGHT_SPLIT | ||
| 633 | 651 | ||
| 634 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 652 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 635 | void rgblight_set(void) { | 653 | void rgblight_set(void) { |
| 636 | LED_TYPE *start_led = led + clipping_start_pos; | 654 | LED_TYPE *start_led; |
| 637 | uint16_t num_leds = clipping_num_leds; | 655 | uint16_t num_leds = clipping_num_leds; |
| 638 | if (rgblight_config.enable) { | 656 | |
| 639 | #ifdef RGBLIGHT_LED_MAP | 657 | if (!rgblight_config.enable) { |
| 640 | LED_TYPE led0[RGBLED_NUM]; | 658 | for (uint8_t i = effect_start_pos; i < effect_end_pos; i++) { |
| 641 | for(uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 642 | led0[i] = led[pgm_read_byte(&led_map[i])]; | ||
| 643 | } | ||
| 644 | start_led = led0 + clipping_start_pos; | ||
| 645 | #endif | ||
| 646 | #ifdef RGBW | ||
| 647 | ws2812_setleds_rgbw(start_led, num_leds); | ||
| 648 | #else | ||
| 649 | ws2812_setleds(start_led, num_leds); | ||
| 650 | #endif | ||
| 651 | } else { | ||
| 652 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 653 | led[i].r = 0; | 659 | led[i].r = 0; |
| 654 | led[i].g = 0; | 660 | led[i].g = 0; |
| 655 | led[i].b = 0; | 661 | led[i].b = 0; |
| 656 | } | 662 | } |
| 657 | #ifdef RGBW | ||
| 658 | ws2812_setleds_rgbw(start_led, num_leds); | ||
| 659 | #else | ||
| 660 | ws2812_setleds(start_led, num_leds); | ||
| 661 | #endif | ||
| 662 | } | 663 | } |
| 664 | #ifdef RGBLIGHT_LED_MAP | ||
| 665 | LED_TYPE led0[RGBLED_NUM]; | ||
| 666 | for(uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 667 | led0[i] = led[pgm_read_byte(&led_map[i])]; | ||
| 668 | } | ||
| 669 | start_led = led0 + clipping_start_pos; | ||
| 670 | #else | ||
| 671 | start_led = led + clipping_start_pos; | ||
| 672 | #endif | ||
| 673 | #ifdef RGBW | ||
| 674 | ws2812_setleds_rgbw(start_led, num_leds); | ||
| 675 | #else | ||
| 676 | ws2812_setleds(start_led, num_leds); | ||
| 677 | #endif | ||
| 663 | } | 678 | } |
| 664 | #endif | 679 | #endif |
| 665 | 680 | ||
| @@ -926,9 +941,9 @@ void rgblight_effect_rainbow_swirl(animation_status_t *anim) { | |||
| 926 | uint8_t hue; | 941 | uint8_t hue; |
| 927 | uint8_t i; | 942 | uint8_t i; |
| 928 | 943 | ||
| 929 | for (i = 0; i < RGBLED_NUM; i++) { | 944 | for (i = 0; i < effect_num_leds; i++) { |
| 930 | hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / RGBLED_NUM * i + anim->current_hue); | 945 | hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / effect_num_leds * i + anim->current_hue); |
| 931 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | 946 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]); |
| 932 | } | 947 | } |
| 933 | rgblight_set(); | 948 | rgblight_set(); |
| 934 | 949 | ||
| @@ -957,7 +972,7 @@ void rgblight_effect_snake(animation_status_t *anim) { | |||
| 957 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 972 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 958 | if (anim->pos == 0) { // restart signal | 973 | if (anim->pos == 0) { // restart signal |
| 959 | if (increment == 1) { | 974 | if (increment == 1) { |
| 960 | pos = RGBLED_NUM - 1; | 975 | pos = effect_num_leds - 1; |
| 961 | } else { | 976 | } else { |
| 962 | pos = 0; | 977 | pos = 0; |
| 963 | } | 978 | } |
| @@ -965,26 +980,27 @@ void rgblight_effect_snake(animation_status_t *anim) { | |||
| 965 | } | 980 | } |
| 966 | #endif | 981 | #endif |
| 967 | 982 | ||
| 968 | for (i = 0; i < RGBLED_NUM; i++) { | 983 | for (i = 0; i < effect_num_leds; i++) { |
| 969 | led[i].r = 0; | 984 | LED_TYPE *ledp = led + i + effect_start_pos; |
| 970 | led[i].g = 0; | 985 | ledp->r = 0; |
| 971 | led[i].b = 0; | 986 | ledp->g = 0; |
| 987 | ledp->b = 0; | ||
| 972 | for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { | 988 | for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { |
| 973 | k = pos + j * increment; | 989 | k = pos + j * increment; |
| 974 | if (k < 0) { | 990 | if (k < 0) { |
| 975 | k = k + RGBLED_NUM; | 991 | k = k + effect_num_leds; |
| 976 | } | 992 | } |
| 977 | if (i == k) { | 993 | if (i == k) { |
| 978 | sethsv(rgblight_config.hue, rgblight_config.sat, | 994 | sethsv(rgblight_config.hue, rgblight_config.sat, |
| 979 | (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), | 995 | (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), |
| 980 | (LED_TYPE *)&led[i]); | 996 | ledp); |
| 981 | } | 997 | } |
| 982 | } | 998 | } |
| 983 | } | 999 | } |
| 984 | rgblight_set(); | 1000 | rgblight_set(); |
| 985 | if (increment == 1) { | 1001 | if (increment == 1) { |
| 986 | if (pos - 1 < 0) { | 1002 | if (pos - 1 < 0) { |
| 987 | pos = RGBLED_NUM - 1; | 1003 | pos = effect_num_leds - 1; |
| 988 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 1004 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 989 | anim->pos = 0; | 1005 | anim->pos = 0; |
| 990 | #endif | 1006 | #endif |
| @@ -995,7 +1011,7 @@ void rgblight_effect_snake(animation_status_t *anim) { | |||
| 995 | #endif | 1011 | #endif |
| 996 | } | 1012 | } |
| 997 | } else { | 1013 | } else { |
| 998 | pos = (pos + 1) % RGBLED_NUM; | 1014 | pos = (pos + 1) % effect_num_leds; |
| 999 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) | 1015 | #if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) |
| 1000 | anim->pos = pos; | 1016 | anim->pos = pos; |
| 1001 | #endif | 1017 | #endif |
| @@ -1023,14 +1039,14 @@ void rgblight_effect_knight(animation_status_t *anim) { | |||
| 1023 | } | 1039 | } |
| 1024 | #endif | 1040 | #endif |
| 1025 | // Set all the LEDs to 0 | 1041 | // Set all the LEDs to 0 |
| 1026 | for (i = 0; i < RGBLED_NUM; i++) { | 1042 | for (i = effect_start_pos; i < effect_end_pos; i++) { |
| 1027 | led[i].r = 0; | 1043 | led[i].r = 0; |
| 1028 | led[i].g = 0; | 1044 | led[i].g = 0; |
| 1029 | led[i].b = 0; | 1045 | led[i].b = 0; |
| 1030 | } | 1046 | } |
| 1031 | // Determine which LEDs should be lit up | 1047 | // Determine which LEDs should be lit up |
| 1032 | for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { | 1048 | for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { |
| 1033 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; | 1049 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % effect_num_leds + effect_start_pos; |
| 1034 | 1050 | ||
| 1035 | if (i >= low_bound && i <= high_bound) { | 1051 | if (i >= low_bound && i <= high_bound) { |
| 1036 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); | 1052 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); |
| @@ -1064,9 +1080,9 @@ void rgblight_effect_christmas(animation_status_t *anim) { | |||
| 1064 | uint8_t i; | 1080 | uint8_t i; |
| 1065 | 1081 | ||
| 1066 | anim->current_offset = (anim->current_offset + 1) % 2; | 1082 | anim->current_offset = (anim->current_offset + 1) % 2; |
| 1067 | for (i = 0; i < RGBLED_NUM; i++) { | 1083 | for (i = 0; i < effect_num_leds; i++) { |
| 1068 | hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85; | 1084 | hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + anim->current_offset) % 2) * 85; |
| 1069 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | 1085 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + effect_start_pos]); |
| 1070 | } | 1086 | } |
| 1071 | rgblight_set(); | 1087 | rgblight_set(); |
| 1072 | } | 1088 | } |
| @@ -1099,13 +1115,14 @@ void rgblight_effect_rgbtest(animation_status_t *anim) { | |||
| 1099 | #ifdef RGBLIGHT_EFFECT_ALTERNATING | 1115 | #ifdef RGBLIGHT_EFFECT_ALTERNATING |
| 1100 | void rgblight_effect_alternating(animation_status_t *anim) { | 1116 | void rgblight_effect_alternating(animation_status_t *anim) { |
| 1101 | 1117 | ||
| 1102 | for(int i = 0; i<RGBLED_NUM; i++){ | 1118 | for (int i = 0; i < effect_num_leds; i++) { |
| 1103 | if(i<RGBLED_NUM/2 && anim->pos){ | 1119 | LED_TYPE *ledp = led + i + effect_start_pos; |
| 1104 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | 1120 | if (i<effect_num_leds/2 && anim->pos) { |
| 1105 | }else if (i>=RGBLED_NUM/2 && !anim->pos){ | 1121 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp); |
| 1106 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | 1122 | } else if (i>=effect_num_leds/2 && !anim->pos) { |
| 1107 | }else{ | 1123 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp); |
| 1108 | sethsv(rgblight_config.hue, rgblight_config.sat, 0, (LED_TYPE *)&led[i]); | 1124 | } else { |
| 1125 | sethsv(rgblight_config.hue, rgblight_config.sat, 0, ledp); | ||
| 1109 | } | 1126 | } |
| 1110 | } | 1127 | } |
| 1111 | rgblight_set(); | 1128 | rgblight_set(); |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 35d7942ca..064522a2b 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -99,7 +99,7 @@ enum RGBLIGHT_EFFECT_MODE { | |||
| 99 | #endif | 99 | #endif |
| 100 | 100 | ||
| 101 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM | 101 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM |
| 102 | #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM | 102 | #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM (effect_num_leds) |
| 103 | #endif | 103 | #endif |
| 104 | 104 | ||
| 105 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL | 105 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL |
| @@ -170,61 +170,79 @@ typedef struct _rgblight_status_t { | |||
| 170 | #endif | 170 | #endif |
| 171 | } rgblight_status_t; | 171 | } rgblight_status_t; |
| 172 | 172 | ||
| 173 | #ifdef RGBLIGHT_SPLIT | 173 | /* === Utility Functions ===*/ |
| 174 | #define RGBLIGHT_STATUS_CHANGE_MODE (1<<0) | 174 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); |
| 175 | #define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1) | 175 | void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check |
| 176 | #define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2) | 176 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); |
| 177 | #define RGBLIGHT_STATUS_ANIMATION_TICK (1<<3) | ||
| 178 | 177 | ||
| 179 | typedef struct _rgblight_syncinfo_t { | 178 | /* === Low level Functions === */ |
| 180 | rgblight_config_t config; | 179 | void rgblight_set(void); |
| 181 | rgblight_status_t status; | 180 | void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); |
| 182 | } rgblight_syncinfo_t; | ||
| 183 | 181 | ||
| 184 | /* for split keyboard master side */ | 182 | /* === Effects and Animations Functions === */ |
| 185 | uint8_t rgblight_get_change_flags(void); | 183 | /* effect range setting */ |
| 186 | void rgblight_clear_change_flags(void); | 184 | void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds); |
| 187 | void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo); | 185 | |
| 188 | /* for split keyboard slave side */ | 186 | /* direct operation */ |
| 189 | void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom); | 187 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); |
| 188 | void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index); | ||
| 189 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end); | ||
| 190 | void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end); | ||
| 191 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); | ||
| 192 | |||
| 193 | #ifndef RGBLIGHT_SPLIT | ||
| 194 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b); | ||
| 195 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); | ||
| 196 | void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 197 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 190 | #endif | 198 | #endif |
| 191 | 199 | ||
| 192 | void rgblight_init(void); | 200 | /* effect mode change */ |
| 201 | void rgblight_mode(uint8_t mode); | ||
| 202 | void rgblight_mode_noeeprom(uint8_t mode); | ||
| 193 | void rgblight_increase(void); | 203 | void rgblight_increase(void); |
| 194 | void rgblight_decrease(void); | 204 | void rgblight_decrease(void); |
| 205 | void rgblight_step(void); | ||
| 206 | void rgblight_step_noeeprom(void); | ||
| 207 | void rgblight_step_reverse(void); | ||
| 208 | void rgblight_step_reverse_noeeprom(void); | ||
| 209 | |||
| 210 | /* effects mode disable/enable */ | ||
| 195 | void rgblight_toggle(void); | 211 | void rgblight_toggle(void); |
| 212 | void rgblight_toggle_noeeprom(void); | ||
| 196 | void rgblight_enable(void); | 213 | void rgblight_enable(void); |
| 214 | void rgblight_enable_noeeprom(void); | ||
| 197 | void rgblight_disable(void); | 215 | void rgblight_disable(void); |
| 198 | void rgblight_step(void); | 216 | void rgblight_disable_noeeprom(void); |
| 199 | void rgblight_step_reverse(void); | 217 | |
| 200 | uint8_t rgblight_get_mode(void); | 218 | /* hue, sat, val change */ |
| 201 | void rgblight_mode(uint8_t mode); | ||
| 202 | void rgblight_set(void); | ||
| 203 | uint32_t rgblight_read_dword(void); | ||
| 204 | void rgblight_update_dword(uint32_t dword); | ||
| 205 | void rgblight_increase_hue(void); | 219 | void rgblight_increase_hue(void); |
| 220 | void rgblight_increase_hue_noeeprom(void); | ||
| 206 | void rgblight_decrease_hue(void); | 221 | void rgblight_decrease_hue(void); |
| 222 | void rgblight_decrease_hue_noeeprom(void); | ||
| 207 | void rgblight_increase_sat(void); | 223 | void rgblight_increase_sat(void); |
| 224 | void rgblight_increase_sat_noeeprom(void); | ||
| 208 | void rgblight_decrease_sat(void); | 225 | void rgblight_decrease_sat(void); |
| 226 | void rgblight_decrease_sat_noeeprom(void); | ||
| 209 | void rgblight_increase_val(void); | 227 | void rgblight_increase_val(void); |
| 228 | void rgblight_increase_val_noeeprom(void); | ||
| 210 | void rgblight_decrease_val(void); | 229 | void rgblight_decrease_val(void); |
| 230 | void rgblight_decrease_val_noeeprom(void); | ||
| 211 | void rgblight_increase_speed(void); | 231 | void rgblight_increase_speed(void); |
| 212 | void rgblight_decrease_speed(void); | 232 | void rgblight_decrease_speed(void); |
| 213 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); | 233 | void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); |
| 234 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 235 | |||
| 236 | /* query */ | ||
| 237 | uint8_t rgblight_get_mode(void); | ||
| 214 | uint8_t rgblight_get_hue(void); | 238 | uint8_t rgblight_get_hue(void); |
| 215 | uint8_t rgblight_get_sat(void); | 239 | uint8_t rgblight_get_sat(void); |
| 216 | uint8_t rgblight_get_val(void); | 240 | uint8_t rgblight_get_val(void); |
| 217 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); | ||
| 218 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); | ||
| 219 | void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index); | ||
| 220 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end); | ||
| 221 | void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end); | ||
| 222 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b); | ||
| 223 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); | ||
| 224 | void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 225 | void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 226 | void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); | ||
| 227 | 241 | ||
| 242 | /* === qmk_firmware (core)internal Functions === */ | ||
| 243 | void rgblight_init(void); | ||
| 244 | uint32_t rgblight_read_dword(void); | ||
| 245 | void rgblight_update_dword(uint32_t dword); | ||
| 228 | uint32_t eeconfig_read_rgblight(void); | 246 | uint32_t eeconfig_read_rgblight(void); |
| 229 | void eeconfig_update_rgblight(uint32_t val); | 247 | void eeconfig_update_rgblight(uint32_t val); |
| 230 | void eeconfig_update_rgblight_default(void); | 248 | void eeconfig_update_rgblight_default(void); |
| @@ -233,27 +251,9 @@ void eeconfig_debug_rgblight(void); | |||
| 233 | void rgb_matrix_increase(void); | 251 | void rgb_matrix_increase(void); |
| 234 | void rgb_matrix_decrease(void); | 252 | void rgb_matrix_decrease(void); |
| 235 | 253 | ||
| 236 | void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); | ||
| 237 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); | ||
| 238 | |||
| 239 | void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); | ||
| 240 | void rgblight_mode_noeeprom(uint8_t mode); | ||
| 241 | void rgblight_toggle_noeeprom(void); | ||
| 242 | void rgblight_enable_noeeprom(void); | ||
| 243 | void rgblight_disable_noeeprom(void); | ||
| 244 | void rgblight_step_noeeprom(void); | ||
| 245 | void rgblight_step_reverse_noeeprom(void); | ||
| 246 | void rgblight_increase_hue_noeeprom(void); | ||
| 247 | void rgblight_decrease_hue_noeeprom(void); | ||
| 248 | void rgblight_increase_sat_noeeprom(void); | ||
| 249 | void rgblight_decrease_sat_noeeprom(void); | ||
| 250 | void rgblight_increase_val_noeeprom(void); | ||
| 251 | void rgblight_decrease_val_noeeprom(void); | ||
| 252 | |||
| 253 | void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); | 254 | void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); |
| 254 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); | 255 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); |
| 255 | 256 | ||
| 256 | |||
| 257 | #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) | 257 | #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) |
| 258 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); | 258 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); |
| 259 | 259 | ||
| @@ -264,6 +264,25 @@ void rgblight_timer_enable(void); | |||
| 264 | void rgblight_timer_disable(void); | 264 | void rgblight_timer_disable(void); |
| 265 | void rgblight_timer_toggle(void); | 265 | void rgblight_timer_toggle(void); |
| 266 | 266 | ||
| 267 | #ifdef RGBLIGHT_SPLIT | ||
| 268 | #define RGBLIGHT_STATUS_CHANGE_MODE (1<<0) | ||
| 269 | #define RGBLIGHT_STATUS_CHANGE_HSVS (1<<1) | ||
| 270 | #define RGBLIGHT_STATUS_CHANGE_TIMER (1<<2) | ||
| 271 | #define RGBLIGHT_STATUS_ANIMATION_TICK (1<<3) | ||
| 272 | |||
| 273 | typedef struct _rgblight_syncinfo_t { | ||
| 274 | rgblight_config_t config; | ||
| 275 | rgblight_status_t status; | ||
| 276 | } rgblight_syncinfo_t; | ||
| 277 | |||
| 278 | /* for split keyboard master side */ | ||
| 279 | uint8_t rgblight_get_change_flags(void); | ||
| 280 | void rgblight_clear_change_flags(void); | ||
| 281 | void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo); | ||
| 282 | /* for split keyboard slave side */ | ||
| 283 | void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom); | ||
| 284 | #endif | ||
| 285 | |||
| 267 | #ifdef RGBLIGHT_USE_TIMER | 286 | #ifdef RGBLIGHT_USE_TIMER |
| 268 | 287 | ||
| 269 | typedef struct _animation_status_t { | 288 | typedef struct _animation_status_t { |
