1
0
Fork 0

Rename RGBW define to WS2812_RGBW (#23585)

This commit is contained in:
Ryan 2024-04-28 00:36:54 +10:00 committed by GitHub
parent 8f8fffc174
commit 0ff53b2498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 68 additions and 44 deletions

View file

@ -1,7 +1,7 @@
#include "ws2812.h"
#include "i2c_master.h"
#ifdef RGBW
#ifdef WS2812_RGBW
# error "RGBW not supported"
#endif

View file

@ -161,7 +161,7 @@ static void ws2812_dma_callback(void* p, uint32_t ct) {
// FIFO is already empty.
rtcnt_t time_to_completion = (pio_sm_get_tx_fifo_level(pio, STATE_MACHINE) + 1) * MAX(WS2812_T1H + WS2812_T1L, WS2812_T0H + WS2812_T0L);
#if defined(RGBW)
#if defined(WS2812_RGBW)
time_to_completion *= 32;
#else
time_to_completion *= 24;
@ -222,7 +222,7 @@ void ws2812_init(void) {
sm_config_set_sideset(&config, 1, false, false);
#endif
#if defined(RGBW)
#if defined(WS2812_RGBW)
sm_config_set_out_shift(&config, false, true, 32);
#else
sm_config_set_out_shift(&config, false, true, 24);
@ -270,7 +270,7 @@ void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
sync_ws2812_transfer();
for (int i = 0; i < leds; i++) {
#if defined(RGBW)
#if defined(WS2812_RGBW)
WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w);
#else
WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, 0);

View file

@ -101,7 +101,7 @@ void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
sendByte(ledarray[i].r);
#endif
#ifdef RGBW
#ifdef WS2812_RGBW
sendByte(ledarray[i].w);
#endif
}

View file

@ -16,7 +16,7 @@
/* Adapted from https://github.com/joewa/WS2812-LED-Driver_ChibiOS/ */
#ifdef RGBW
#ifdef WS2812_RGBW
# define WS2812_CHANNELS 4
#else
# define WS2812_CHANNELS 3
@ -262,7 +262,7 @@
# define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 0, (bit))
#endif
#ifdef RGBW
#ifdef WS2812_RGBW
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given white bit
*
@ -381,7 +381,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,
ws2812_frame_buffer[WS2812_RED_BIT(led_number, bit)] = ((r >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_GREEN_BIT(led_number, bit)] = ((g >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_BLUE_BIT(led_number, bit)] = ((b >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
#ifdef RGBW
#ifdef WS2812_RGBW
ws2812_frame_buffer[WS2812_WHITE_BIT(led_number, bit)] = ((w >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
#endif
}
@ -390,7 +390,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,
// Setleds for standard RGB
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
for (uint16_t i = 0; i < leds; i++) {
#ifdef RGBW
#ifdef WS2812_RGBW
ws2812_write_led_rgbw(i, ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w);
#else
ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b);

View file

@ -76,7 +76,7 @@
#endif
#define BYTES_FOR_LED_BYTE 4
#ifdef RGBW
#ifdef WS2812_RGBW
# define WS2812_CHANNELS 4
#else
# define WS2812_CHANNELS 3
@ -131,7 +131,7 @@ static void set_led_color_rgb(rgb_led_t color, int pos) {
for (int j = 0; j < 4; j++)
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j);
#endif
#ifdef RGBW
#ifdef WS2812_RGBW
for (int j = 0; j < 4; j++)
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j);
#endif