summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-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
4 files changed, 55 insertions, 29 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 3042ff11ea..08515564bc 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -66,6 +66,15 @@ bool is_rgblight_initialized = false;
LED_TYPE led[RGBLED_NUM];
bool rgblight_timer_enabled = false;
+static uint8_t clipping_start_pos = 0;
+static uint8_t clipping_num_leds = RGBLED_NUM;
+
+void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) {
+ clipping_start_pos = start_pos;
+ clipping_num_leds = num_leds;
+}
+
+
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
uint8_t r = 0, g = 0, b = 0, base, color;
@@ -621,7 +630,7 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
|| defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT)
static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
- return
+ return
#ifdef VELOCIKEY_ENABLE
velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
#endif
@@ -668,21 +677,20 @@ void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) {
#ifndef RGBLIGHT_CUSTOM_DRIVER
void rgblight_set(void) {
+ LED_TYPE *start_led = led + clipping_start_pos;
+ uint16_t num_leds = clipping_num_leds;
if (rgblight_config.enable) {
- LED_TYPE *ledp;
#ifdef RGBLIGHT_LED_MAP
LED_TYPE led0[RGBLED_NUM];
for(uint8_t i = 0; i < RGBLED_NUM; i++) {
led0[i] = led[pgm_read_byte(&led_map[i])];
}
- ledp = led0;
- #else
- ledp = led;
+ start_led = led0 + clipping_start_pos;
#endif
#ifdef RGBW
- ws2812_setleds_rgbw(ledp, RGBLED_NUM);
+ ws2812_setleds_rgbw(start_led, num_leds);
#else
- ws2812_setleds(ledp, RGBLED_NUM);
+ ws2812_setleds(start_led, num_leds);
#endif
} else {
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
@@ -691,9 +699,9 @@ void rgblight_set(void) {
led[i].b = 0;
}
#ifdef RGBW
- ws2812_setleds_rgbw(led, RGBLED_NUM);
+ ws2812_setleds_rgbw(start_led, num_leds);
#else
- ws2812_setleds(led, RGBLED_NUM);
+ ws2812_setleds(start_led, num_leds);
#endif
}
}
@@ -813,7 +821,7 @@ void rgblight_effect_breathing(uint8_t interval) {
float val;
uint8_t interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[interval], 1, 100);
-
+
if (timer_elapsed(last_timer) < interval_time) {
return;
}
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 36e436b899..1769f719d9 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);
void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b);
void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val);
void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val);
+void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds);
uint32_t eeconfig_read_rgblight(void);
void eeconfig_update_rgblight(uint32_t val);
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index da870f8775..09a307b8ed 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -11,25 +11,25 @@
# include "eeconfig.h"
#endif
+#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+#include "rgblight.h"
+#endif
+
volatile bool isLeftHand = true;
__attribute__((weak))
bool is_keyboard_left(void) {
- #ifdef SPLIT_HAND_PIN
+ #if defined(SPLIT_HAND_PIN)
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
setPinInput(SPLIT_HAND_PIN);
return readPin(SPLIT_HAND_PIN);
- #else
- #ifdef EE_HANDS
- return eeprom_read_byte(EECONFIG_HANDEDNESS);
- #else
- #ifdef MASTER_RIGHT
- return !is_keyboard_master();
- #else
- return is_keyboard_master();
- #endif
- #endif
+ #elif defined(EE_HANDS)
+ return eeprom_read_byte(EECONFIG_HANDEDNESS);
+ #elif defined(MASTER_RIGHT)
+ return !is_keyboard_master();
#endif
+
+ return is_keyboard_master();
}
bool is_keyboard_master(void)
@@ -71,6 +71,16 @@ void matrix_setup(void)
{
isLeftHand = is_keyboard_left();
+#if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+ uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT;
+ if (isLeftHand) {
+ rgblight_set_clipping_range(0, num_rgb_leds_split[0]);
+ }
+ else {
+ rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]);
+ }
+#endif
+
if (is_keyboard_master())
{
keyboard_master_setup();
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 631d913f70..8d408f6fdc 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -92,12 +92,13 @@ typedef struct _Serial_m2s_buffer_t {
# ifdef BACKLIGHT_ENABLE
uint8_t backlight_level;
# endif
-# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
rgblight_config_t rgblight_config; // not yet use
//
// When MCUs on both sides drive their respective RGB LED chains,
// it is necessary to synchronize, so it is necessary to communicate RGB
- // information. In that case, define the RGBLIGHT_SPLIT macro.
+ // information. In that case, define RGBLED_SPLIT with info on the number
+ // of LEDs on each half.
//
// Otherwise, if the master side MCU drives both sides RGB LED chains,
// there is no need to communicate.
@@ -132,15 +133,20 @@ bool transport_master(matrix_row_t matrix[]) {
matrix[i] = serial_s2m_buffer.smatrix[i];
}
-# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
- // Code to send RGB over serial goes here (not implemented yet)
-# endif
-
# ifdef BACKLIGHT_ENABLE
// Write backlight level for slave to read
serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0;
# endif
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+ static rgblight_config_t prev_rgb = {~0};
+ uint32_t rgb = rgblight_read_dword();
+ if (rgb != prev_rgb.raw) {
+ serial_m2s_buffer.rgblight_config.raw = rgb;
+ prev_rgb.raw = rgb;
+ }
+# endif
+
return true;
}
@@ -152,8 +158,9 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef BACKLIGHT_ENABLE
backlight_set(serial_m2s_buffer.backlight_level);
# endif
-# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
-// Add serial implementation for RGB here
+# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
+ // Update RGB config with the new data
+ rgblight_update_dword(serial_m2s_buffer.rgblight_config.raw);
# endif
}