aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/config_options.md11
-rw-r--r--docs/feature_rgblight.md9
-rw-r--r--keyboards/keebio/iris/rev3/config.h1
-rw-r--r--keyboards/keebio/nyquist/rev3/config.h1
-rw-r--r--layouts/community/ortho_4x12/bakingpy/config.h1
-rw-r--r--layouts/community/ortho_4x12/bakingpy/rules.mk7
-rw-r--r--quantum/rgblight.c28
-rw-r--r--quantum/rgblight.h1
-rw-r--r--quantum/split_common/split_util.c32
-rw-r--r--quantum/split_common/transport.c23
10 files changed, 76 insertions, 38 deletions
diff --git a/docs/config_options.md b/docs/config_options.md
index a8a106459..ad42e9780 100644
--- a/docs/config_options.md
+++ b/docs/config_options.md
@@ -171,11 +171,15 @@ If you define these options you will enable the associated feature, which may in
171## RGB Light Configuration 171## RGB Light Configuration
172 172
173* `#define RGB_DI_PIN D7` 173* `#define RGB_DI_PIN D7`
174 * pin the DI on the ws2812 is hooked-up to 174 * pin the DI on the WS2812 is hooked-up to
175* `#define RGBLIGHT_ANIMATIONS` 175* `#define RGBLIGHT_ANIMATIONS`
176 * run RGB animations 176 * run RGB animations
177* `#define RGBLED_NUM 15` 177* `#define RGBLED_NUM 12`
178 * number of LEDs 178 * number of LEDs
179* `#define RGBLED_SPLIT { 6, 6 }`
180 * number of LEDs connected that are directly wired to `RGB_DI_PIN` on each half of a split keyboard
181 * First value indicates number of LEDs for left half, second value is for the right half
182 * Needed if both halves of the board have RGB LEDs wired directly to the RGB output pin on the controllers instead of passing the output of the left half to the input of the right half
179* `#define RGBLIGHT_HUE_STEP 12` 183* `#define RGBLIGHT_HUE_STEP 12`
180 * units to step when in/decreasing hue 184 * units to step when in/decreasing hue
181* `#define RGBLIGHT_SAT_STEP 25` 185* `#define RGBLIGHT_SAT_STEP 25`
@@ -236,6 +240,9 @@ There are a few different ways to set handedness for split keyboards (listed in
236* `#define MATRIX_COL_PINS_RIGHT { <col pins> }` 240* `#define MATRIX_COL_PINS_RIGHT { <col pins> }`
237 * If you want to specify a different pinout for the right half than the left half, you can define `MATRIX_ROW_PINS_RIGHT`/`MATRIX_COL_PINS_RIGHT`. Currently, the size of `MATRIX_ROW_PINS` must be the same as `MATRIX_ROW_PINS_RIGHT` and likewise for the definition of columns. 241 * If you want to specify a different pinout for the right half than the left half, you can define `MATRIX_ROW_PINS_RIGHT`/`MATRIX_COL_PINS_RIGHT`. Currently, the size of `MATRIX_ROW_PINS` must be the same as `MATRIX_ROW_PINS_RIGHT` and likewise for the definition of columns.
238 242
243* `#define RGBLED_SPLIT { 6, 6 }`
244 * See [RGB Light Configuration](#rgb-light-configuration)
245
239* `#define SELECT_SOFT_SERIAL_SPEED <speed>` (default speed is 1) 246* `#define SELECT_SOFT_SERIAL_SPEED <speed>` (default speed is 1)
240 * Sets the protocol speed when using serial communication 247 * Sets the protocol speed when using serial communication
241 * Speeds: 248 * Speeds:
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md
index 800e59738..9ecc0deb5 100644
--- a/docs/feature_rgblight.md
+++ b/docs/feature_rgblight.md
@@ -23,10 +23,11 @@ RGBLIGHT_ENABLE = yes
23 23
24At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your `config.h`. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these. 24At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your `config.h`. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these.
25 25
26|Define |Description | 26|Define |Description |
27|------------|---------------------------------------------| 27|---------------|---------------------------------------------------------------------------------------------------------|
28|`RGB_DI_PIN`|The pin connected to the data pin of the LEDs| 28|`RGB_DI_PIN` |The pin connected to the data pin of the LEDs |
29|`RGBLED_NUM`|The number of LEDs connected | 29|`RGBLED_NUM` |The number of LEDs connected |
30|`RGBLED_SPLIT` |(Optional) For split keyboards, the number of LEDs connected on each half directly wired to `RGB_DI_PIN` |
30 31
31Then you should be able to use the keycodes below to change the RGB lighting to your liking. 32Then you should be able to use the keycodes below to change the RGB lighting to your liking.
32 33
diff --git a/keyboards/keebio/iris/rev3/config.h b/keyboards/keebio/iris/rev3/config.h
index 70e5d6e2a..ff0d28c73 100644
--- a/keyboards/keebio/iris/rev3/config.h
+++ b/keyboards/keebio/iris/rev3/config.h
@@ -71,6 +71,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
71/* ws2812 RGB LED */ 71/* ws2812 RGB LED */
72#define RGB_DI_PIN F7 72#define RGB_DI_PIN F7
73#define RGBLED_NUM 12 // Number of LEDs 73#define RGBLED_NUM 12 // Number of LEDs
74#define RGBLED_SPLIT { 6, 6 }
74 75
75#define DYNAMIC_KEYMAP_LAYER_COUNT 4 76#define DYNAMIC_KEYMAP_LAYER_COUNT 4
76 77
diff --git a/keyboards/keebio/nyquist/rev3/config.h b/keyboards/keebio/nyquist/rev3/config.h
index 18b40ecec..3c7822def 100644
--- a/keyboards/keebio/nyquist/rev3/config.h
+++ b/keyboards/keebio/nyquist/rev3/config.h
@@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGB_DI_PIN B4 56#define RGB_DI_PIN B4
57#define RGBLIGHT_ANIMATIONS 57#define RGBLIGHT_ANIMATIONS
58#define RGBLED_NUM 12 58#define RGBLED_NUM 12
59#define RGBLED_SPLIT { 6, 6 }
59 60
60/* Backlight LEDs */ 61/* Backlight LEDs */
61#define BACKLIGHT_PIN B5 62#define BACKLIGHT_PIN B5
diff --git a/layouts/community/ortho_4x12/bakingpy/config.h b/layouts/community/ortho_4x12/bakingpy/config.h
index b6b2ac577..a153adffb 100644
--- a/layouts/community/ortho_4x12/bakingpy/config.h
+++ b/layouts/community/ortho_4x12/bakingpy/config.h
@@ -10,6 +10,7 @@
10#undef RGBLED_NUM 10#undef RGBLED_NUM
11#define RGBLIGHT_ANIMATIONS 11#define RGBLIGHT_ANIMATIONS
12#define RGBLED_NUM 12 12#define RGBLED_NUM 12
13#define RGBLED_SPLIT { 6, 6 }
13#define RGBLIGHT_HUE_STEP 8 14#define RGBLIGHT_HUE_STEP 8
14#define RGBLIGHT_SAT_STEP 8 15#define RGBLIGHT_SAT_STEP 8
15#define RGBLIGHT_VAL_STEP 8 16#define RGBLIGHT_VAL_STEP 8
diff --git a/layouts/community/ortho_4x12/bakingpy/rules.mk b/layouts/community/ortho_4x12/bakingpy/rules.mk
index 9be2f01d4..17a589cd1 100644
--- a/layouts/community/ortho_4x12/bakingpy/rules.mk
+++ b/layouts/community/ortho_4x12/bakingpy/rules.mk
@@ -1,12 +1,13 @@
1# Enable RGB if not a Planck 1ifneq ($(LAYOUTS_HAS_RGB), no)
2ifeq ($(LAYOUTS_HAS_RGB),yes)
3 RGBLIGHT_ENABLE = yes 2 RGBLIGHT_ENABLE = yes
4endif 3endif
5AUDIO_ENABLE = no 4AUDIO_ENABLE = no
6ifeq ($(strip $(KEYBOARD)), zlant) 5ifeq ($(strip $(KEYBOARD)), zlant)
7 BACKLIGHT_ENABLE = no 6 BACKLIGHT_ENABLE = no
8else ifeq ($(strip $(KEYBOARD)), 40percentclub/4x4) 7else ifeq ($(strip $(KEYBOARD)), 40percentclub/4x4)
9 BACKLIGHT_ENABLE = no 8 BACKLIGHT_ENABLE = no
9else ifneq (, $(findstring lets_split, $(KEYBOARD)))
10 BACKLIGHT_ENABLE = no
10else 11else
11 BACKLIGHT_ENABLE = yes 12 BACKLIGHT_ENABLE = yes
12endif 13endif
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 3042ff11e..08515564b 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -66,6 +66,15 @@ bool is_rgblight_initialized = false;
66LED_TYPE led[RGBLED_NUM]; 66LED_TYPE led[RGBLED_NUM];
67bool rgblight_timer_enabled = false; 67bool rgblight_timer_enabled = false;
68 68
69static uint8_t clipping_start_pos = 0;
70static uint8_t clipping_num_leds = RGBLED_NUM;
71
72void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) {
73 clipping_start_pos = start_pos;
74 clipping_num_leds = num_leds;
75}
76
77
69void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { 78void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
70 uint8_t r = 0, g = 0, b = 0, base, color; 79 uint8_t r = 0, g = 0, b = 0, base, color;
71 80
@@ -621,7 +630,7 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
621 || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) 630 || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT)
622 631
623static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { 632static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
624 return 633 return
625#ifdef VELOCIKEY_ENABLE 634#ifdef VELOCIKEY_ENABLE
626 velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : 635 velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
627#endif 636#endif
@@ -668,21 +677,20 @@ void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) {
668 677
669#ifndef RGBLIGHT_CUSTOM_DRIVER 678#ifndef RGBLIGHT_CUSTOM_DRIVER
670void rgblight_set(void) { 679void rgblight_set(void) {
680 LED_TYPE *start_led = led + clipping_start_pos;
681 uint16_t num_leds = clipping_num_leds;
671 if (rgblight_config.enable) { 682 if (rgblight_config.enable) {
672 LED_TYPE *ledp;
673 #ifdef RGBLIGHT_LED_MAP 683 #ifdef RGBLIGHT_LED_MAP
674 LED_TYPE led0[RGBLED_NUM]; 684 LED_TYPE led0[RGBLED_NUM];
675 for(uint8_t i = 0; i < RGBLED_NUM; i++) { 685 for(uint8_t i = 0; i < RGBLED_NUM; i++) {
676 led0[i] = led[pgm_read_byte(&led_map[i])]; 686 led0[i] = led[pgm_read_byte(&led_map[i])];
677 } 687 }
678 ledp = led0; 688 start_led = led0 + clipping_start_pos;
679 #else
680 ledp = led;
681 #endif 689 #endif
682 #ifdef RGBW 690 #ifdef RGBW
683 ws2812_setleds_rgbw(ledp, RGBLED_NUM); 691 ws2812_setleds_rgbw(start_led, num_leds);
684 #else 692 #else
685 ws2812_setleds(ledp, RGBLED_NUM); 693 ws2812_setleds(start_led, num_leds);
686 #endif 694 #endif
687 } else { 695 } else {
688 for (uint8_t i = 0; i < RGBLED_NUM; i++) { 696 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
@@ -691,9 +699,9 @@ void rgblight_set(void) {
691 led[i].b = 0; 699 led[i].b = 0;
692 } 700 }
693 #ifdef RGBW 701 #ifdef RGBW
694 ws2812_setleds_rgbw(led, RGBLED_NUM); 702 ws2812_setleds_rgbw(start_led, num_leds);
695 #else 703 #else
696 ws2812_setleds(led, RGBLED_NUM); 704 ws2812_setleds(start_led, num_leds);
697 #endif 705 #endif
698 } 706 }
699} 707}
@@ -813,7 +821,7 @@ void rgblight_effect_breathing(uint8_t interval) {
813 float val; 821 float val;
814 822
815 uint8_t interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[interval], 1, 100); 823 uint8_t interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[interval], 1, 100);
816 824
817 if (timer_elapsed(last_timer) < interval_time) { 825 if (timer_elapsed(last_timer) < interval_time) {
818 return; 826 return;
819 } 827 }
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 36e436b89..1769f719d 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -197,6 +197,7 @@ void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b);
197void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); 197void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b);
198void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val); 198void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val);
199void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val); 199void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val);
200void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds);
200 201
201uint32_t eeconfig_read_rgblight(void); 202uint32_t eeconfig_read_rgblight(void);
202void eeconfig_update_rgblight(uint32_t val); 203void eeconfig_update_rgblight(uint32_t val);
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index da870f877..09a307b8e 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -11,25 +11,25 @@
11# include "eeconfig.h" 11# include "eeconfig.h"
12#endif 12#endif
13 13
14#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
15#include "rgblight.h"
16#endif
17
14volatile bool isLeftHand = true; 18volatile bool isLeftHand = true;
15 19
16__attribute__((weak)) 20__attribute__((weak))
17bool is_keyboard_left(void) { 21bool is_keyboard_left(void) {
18 #ifdef SPLIT_HAND_PIN 22 #if defined(SPLIT_HAND_PIN)
19 // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand 23 // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
20 setPinInput(SPLIT_HAND_PIN); 24 setPinInput(SPLIT_HAND_PIN);
21 return readPin(SPLIT_HAND_PIN); 25 return readPin(SPLIT_HAND_PIN);
22 #else 26 #elif defined(EE_HANDS)
23 #ifdef EE_HANDS 27 return eeprom_read_byte(EECONFIG_HANDEDNESS);
24 return eeprom_read_byte(EECONFIG_HANDEDNESS); 28 #elif defined(MASTER_RIGHT)
25 #else 29 return !is_keyboard_master();
26 #ifdef MASTER_RIGHT
27 return !is_keyboard_master();
28 #else
29 return is_keyboard_master();
30 #endif
31 #endif
32 #endif 30 #endif
31
32 return is_keyboard_master();
33} 33}
34 34
35bool is_keyboard_master(void) 35bool is_keyboard_master(void)
@@ -71,6 +71,16 @@ void matrix_setup(void)
71{ 71{
72 isLeftHand = is_keyboard_left(); 72 isLeftHand = is_keyboard_left();
73 73
74#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
75 uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT;
76 if (isLeftHand) {
77 rgblight_set_clipping_range(0, num_rgb_leds_split[0]);
78 }
79 else {
80 rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]);
81 }
82#endif
83
74 if (is_keyboard_master()) 84 if (is_keyboard_master())
75 { 85 {
76 keyboard_master_setup(); 86 keyboard_master_setup();
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 631d913f7..8d408f6fd 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -92,12 +92,13 @@ typedef struct _Serial_m2s_buffer_t {
92# ifdef BACKLIGHT_ENABLE 92# ifdef BACKLIGHT_ENABLE
93 uint8_t backlight_level; 93 uint8_t backlight_level;
94# endif 94# endif
95# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 95# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
96 rgblight_config_t rgblight_config; // not yet use 96 rgblight_config_t rgblight_config; // not yet use
97 // 97 //
98 // When MCUs on both sides drive their respective RGB LED chains, 98 // When MCUs on both sides drive their respective RGB LED chains,
99 // it is necessary to synchronize, so it is necessary to communicate RGB 99 // it is necessary to synchronize, so it is necessary to communicate RGB
100 // information. In that case, define the RGBLIGHT_SPLIT macro. 100 // information. In that case, define RGBLED_SPLIT with info on the number
101 // of LEDs on each half.
101 // 102 //
102 // Otherwise, if the master side MCU drives both sides RGB LED chains, 103 // Otherwise, if the master side MCU drives both sides RGB LED chains,
103 // there is no need to communicate. 104 // there is no need to communicate.
@@ -132,15 +133,20 @@ bool transport_master(matrix_row_t matrix[]) {
132 matrix[i] = serial_s2m_buffer.smatrix[i]; 133 matrix[i] = serial_s2m_buffer.smatrix[i];
133 } 134 }
134 135
135# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
136 // Code to send RGB over serial goes here (not implemented yet)
137# endif
138
139# ifdef BACKLIGHT_ENABLE 136# ifdef BACKLIGHT_ENABLE
140 // Write backlight level for slave to read 137 // Write backlight level for slave to read
141 serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; 138 serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0;
142# endif 139# endif
143 140
141# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
142 static rgblight_config_t prev_rgb = {~0};
143 uint32_t rgb = rgblight_read_dword();
144 if (rgb != prev_rgb.raw) {
145 serial_m2s_buffer.rgblight_config.raw = rgb;
146 prev_rgb.raw = rgb;
147 }
148# endif
149
144 return true; 150 return true;
145} 151}
146 152
@@ -152,8 +158,9 @@ void transport_slave(matrix_row_t matrix[]) {
152# ifdef BACKLIGHT_ENABLE 158# ifdef BACKLIGHT_ENABLE
153 backlight_set(serial_m2s_buffer.backlight_level); 159 backlight_set(serial_m2s_buffer.backlight_level);
154# endif 160# endif
155# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) 161# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
156// Add serial implementation for RGB here 162 // Update RGB config with the new data
163 rgblight_update_dword(serial_m2s_buffer.rgblight_config.raw);
157# endif 164# endif
158} 165}
159 166