summaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorDanny <nooges@users.noreply.github.com>2019-03-24 01:20:14 +0100
committerDrashna Jaelre <drashna@live.com>2019-03-24 01:20:14 +0100
commitf077204fae729e66f8dfa16db82263ff2ff84d59 (patch)
treedbd23687e838271e9f90b7dab25b0312745eb5e3 /quantum/rgblight.c
parent23086808a78c9234232e2ddbf0c977d1fb2cb6ae (diff)
downloadqmk_firmware-f077204fae729e66f8dfa16db82263ff2ff84d59.tar.gz
qmk_firmware-f077204fae729e66f8dfa16db82263ff2ff84d59.tar.xz
Add support for RGB LEDs wired directly to each half's controller (#5392)
* Add support for wiring RGB LEDs for both halves directly to their respective controllers RGB LEDs for each half don't need to be chained together across the TRRS cable with this * Add split RGB LED support for serial * Update config/rules for bakingpy layout * Un-nest ifdefs for hand detection * Read RGB config state from memory instead of EEPROM for serial updates * Reuse existing LED pointer instead of creating new one
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c28
1 files changed, 18 insertions, 10 deletions
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;
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;
}