Unify RGB and RGBW commands (#7297)
* Fix unicode in comments Co-Authored-By: fauxpark <fauxpark@gmail.com> * Remove separate RGBW implementation for a unified function * Set White to 0 in RGBW LEDs This is just to get this working, later, proper brightness can be handled elsewhere. * Use us instead of nanoseconds(?) since it renders correctly on web * Remove RGBW function from arm/ws2812.h * Remove RGBW function from arm/ws2812.c * Formatting changes * Add doc info
This commit is contained in:
parent
78205e64a7
commit
60e4921378
8 changed files with 45 additions and 41 deletions
|
@ -196,8 +196,8 @@ If you define these options you will enable the associated feature, which may in
|
|||
* units to step when in/decreasing saturation
|
||||
* `#define RGBLIGHT_VAL_STEP 12`
|
||||
* units to step when in/decreasing value (brightness)
|
||||
* `#define RGBW_BB_TWI`
|
||||
* bit-bangs TWI to EZ RGBW LEDs (only required for Ergodox EZ)
|
||||
* `#define RGBW`
|
||||
* Enables RGBW LED support
|
||||
|
||||
## Mouse Key Options
|
||||
|
||||
|
|
|
@ -84,17 +84,12 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
|
|||
sendByte(ledarray[i].g);
|
||||
sendByte(ledarray[i].r);
|
||||
sendByte(ledarray[i].b);
|
||||
#ifdef RGBW
|
||||
sendByte(ledarray[i].w);
|
||||
#endif
|
||||
}
|
||||
|
||||
wait_ns(RES);
|
||||
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
// Setleds for SK6812RGBW
|
||||
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
|
||||
// not supported - for now error out if its enabled
|
||||
#ifdef RGBW
|
||||
# error "RGBW not supported"
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* The functions will perform the following actions:
|
||||
* - Set the data-out pin as output
|
||||
* - Send out the LED data
|
||||
* - Wait 50<EFBFBD>s to reset the LEDs
|
||||
* - Wait 50us to reset the LEDs
|
||||
*/
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
void ws2812_sendarray(uint8_t *array, uint16_t length);
|
||||
void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);
|
||||
|
||||
|
||||
#ifdef RGBW_BB_TWI
|
||||
|
||||
// Port for the I2C
|
||||
|
@ -146,16 +145,6 @@ void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
|
|||
}
|
||||
|
||||
void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) {
|
||||
// ws2812_DDRREG |= pinmask; // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
|
||||
|
||||
ws2812_sendarray_mask((uint8_t *)ledarray, leds + leds + leds, pinmask);
|
||||
_delay_us(50);
|
||||
}
|
||||
|
||||
// Setleds for SK6812RGBW
|
||||
void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
|
||||
#ifdef RGBW_BB_TWI
|
||||
uint8_t sreg_prev, twcr_prev;
|
||||
sreg_prev = SREG;
|
||||
|
@ -176,15 +165,18 @@ void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
|
|||
SREG = sreg_prev;
|
||||
TWCR = twcr_prev;
|
||||
#endif
|
||||
|
||||
// ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
|
||||
// ws2812_DDRREG |= pinmask; // Enable DDR
|
||||
// new universal format (DDR)
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
|
||||
_SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
|
||||
|
||||
ws2812_sendarray_mask((uint8_t *)ledarray, leds << 2, _BV(RGB_DI_PIN & 0xF));
|
||||
ws2812_sendarray_mask((uint8_t *)ledarray, leds * sizeof(LED_TYPE), pinmask);
|
||||
|
||||
#ifndef RGBW_BB_TWI
|
||||
# ifdef RGBW
|
||||
_delay_us(80);
|
||||
# else
|
||||
_delay_us(50);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* The functions will perform the following actions:
|
||||
* - Set the data-out pin as output
|
||||
* - Send out the LED data
|
||||
* - Wait 50<EFBFBD>s to reset the LEDs
|
||||
* - Wait 50us to reset the LEDs
|
||||
*/
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
|
||||
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "ws2812.h"
|
||||
#include "i2c_master.h"
|
||||
|
||||
#ifdef RGBW
|
||||
# error "RGBW not supported"
|
||||
#endif
|
||||
|
||||
#ifndef WS2812_ADDRESS
|
||||
# define WS2812_ADDRESS 0xb0
|
||||
#endif
|
||||
|
@ -21,11 +25,3 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
|
|||
|
||||
i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT);
|
||||
}
|
||||
|
||||
// Setleds for SK6812RGBW
|
||||
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
|
||||
// not supported - for now error out if its enabled
|
||||
#ifdef RGBW
|
||||
# error "RGBW not supported"
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -112,6 +112,9 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
|
|||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
# ifdef RGBW
|
||||
led[i].w = 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
|
||||
|
|
|
@ -126,6 +126,9 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
|
|||
(*led1).r = r;
|
||||
(*led1).g = g;
|
||||
(*led1).b = b;
|
||||
#ifdef RGBW
|
||||
(*led1).w = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rgblight_check_config(void) {
|
||||
|
@ -514,6 +517,9 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
|
|||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
#ifdef RGBW
|
||||
led[i].w = 0;
|
||||
#endif
|
||||
}
|
||||
rgblight_set();
|
||||
}
|
||||
|
@ -526,6 +532,9 @@ void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) {
|
|||
led[index].r = r;
|
||||
led[index].g = g;
|
||||
led[index].b = b;
|
||||
#ifdef RGBW
|
||||
led[index].w = 0;
|
||||
#endif
|
||||
rgblight_set();
|
||||
}
|
||||
|
||||
|
@ -560,6 +569,9 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8
|
|||
led[i].r = r;
|
||||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
#ifdef RGBW
|
||||
led[i].w = 0;
|
||||
#endif
|
||||
}
|
||||
rgblight_set();
|
||||
wait_ms(1);
|
||||
|
@ -595,6 +607,9 @@ void rgblight_set(void) {
|
|||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
# ifdef RGBW
|
||||
led[i].w = 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
# ifdef RGBLIGHT_LED_MAP
|
||||
|
@ -606,11 +621,7 @@ void rgblight_set(void) {
|
|||
# else
|
||||
start_led = led + clipping_start_pos;
|
||||
# endif
|
||||
# ifdef RGBW
|
||||
ws2812_setleds_rgbw(start_led, num_leds);
|
||||
# else
|
||||
ws2812_setleds(start_led, num_leds);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -908,6 +919,9 @@ void rgblight_effect_snake(animation_status_t *anim) {
|
|||
ledp->r = 0;
|
||||
ledp->g = 0;
|
||||
ledp->b = 0;
|
||||
# ifdef RGBW
|
||||
ledp->w = 0;
|
||||
# endif
|
||||
for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
|
||||
k = pos + j * increment;
|
||||
if (k > RGBLED_NUM) {
|
||||
|
@ -965,6 +979,9 @@ void rgblight_effect_knight(animation_status_t *anim) {
|
|||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
# ifdef RGBW
|
||||
led[i].w = 0;
|
||||
# endif
|
||||
}
|
||||
// Determine which LEDs should be lit up
|
||||
for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
|
||||
|
@ -976,6 +993,9 @@ void rgblight_effect_knight(animation_status_t *anim) {
|
|||
led[cur].r = 0;
|
||||
led[cur].g = 0;
|
||||
led[cur].b = 0;
|
||||
# ifdef RGBW
|
||||
led[cur].w = 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
rgblight_set();
|
||||
|
|
Loading…
Reference in a new issue