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
This commit is contained in:
Danny 2019-03-23 20:20:14 -04:00 committed by Drashna Jaelre
parent 23086808a7
commit f077204fae
10 changed files with 76 additions and 38 deletions

View file

@ -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;
}