From 481cc0ede25e3a256800c63801899d619c3eb57d Mon Sep 17 00:00:00 2001 From: openshwprojects <85486843+openshwprojects@users.noreply.github.com> Date: Sun, 14 Sep 2025 21:07:24 +0200 Subject: [PATCH] DMX works on ESP32 LilyGO, other platforms requires porting code to change baudrate * ENABLE DMX on ESP * test * s * Update hal_uart_espidf.c * Update obk_main.cmake * w * test * Update hal_uart_espidf.c * Update drv_dmx512.c * test * test * test * w * t * c * t * test * T * Update drv_dmx512.c * test * test * try flush * try wait * ticks w * t * fx * 100 ms * SIM fx * Update cmd_newLEDDriver.c * test 2x * tests * fixes * free * fix * misc * b * hal * s * Update workflow.yaml * pin * fin * test * Update hal_uart_espidf.c --- .github/workflows/workflow.yaml | 2 +- platforms/obk_main.cmake | 1 + src/cmnds/cmd_newLEDDriver.c | 5 +- src/driver/drv_ddp.c | 8 +- src/driver/drv_ddpSend.c | 16 ++- src/driver/drv_dmx512.c | 80 +++++++++++---- src/driver/drv_drawers.c | 8 +- src/driver/drv_leds_shared.c | 45 ++++++--- src/driver/drv_local.h | 14 +-- src/driver/drv_pixelAnim.c | 99 ++++++++++++++++--- src/driver/drv_public.h | 2 +- src/driver/drv_sm16703P.c | 1 - src/driver/drv_uart.c | 4 +- src/hal/bk7231/hal_uart_bk7231.c | 2 +- src/hal/bl602/hal_uart_bl602.c | 2 +- src/hal/ecr6600/hal_uart_ecr6600.c | 2 +- src/hal/espidf/hal_uart_espidf.c | 75 ++++++++------ src/hal/generic/hal_uart_generic.c | 13 ++- src/hal/hal_uart.h | 4 +- src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c | 2 +- src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c | 2 +- src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c | 2 +- .../realtek/rtl8721da/hal_uart_rtl8721da.c | 2 +- src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c | 2 +- src/hal/w800/hal_uart_w800.c | 2 +- src/hal/win32/hal_uart_win32.c | 9 +- src/hal/xradio/hal_uart_xradio.c | 2 +- src/httpserver/http_fns.c | 3 + src/obk_config.h | 1 + src/selftest/selftest_ws2812b.c | 58 ++++++++--- 30 files changed, 337 insertions(+), 131 deletions(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 0b6b88d87..e219644fa 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -575,4 +575,4 @@ jobs: echo ${{ steps.semantic.outputs.new_release_version }} echo ${{ steps.semantic.outputs.new_release_major_version }} echo ${{ steps.semantic.outputs.new_release_minor_version }} - echo ${{ steps.semantic.outputs.new_release_patch_version }} + echo ${{ steps.semantic.outputs.new_release_patch_version }} \ No newline at end of file diff --git a/platforms/obk_main.cmake b/platforms/obk_main.cmake index d65d9e6db..fb251aa81 100644 --- a/platforms/obk_main.cmake +++ b/platforms/obk_main.cmake @@ -72,6 +72,7 @@ set(OBKM_SRC ${OBK_SRCS}driver/drv_cse7761.c ${OBK_SRCS}driver/drv_cse7766.c ${OBK_SRCS}driver/drv_ddp.c + ${OBK_SRCS}driver/drv_dmx512.c ${OBK_SRCS}driver/drv_debouncer.c ${OBK_SRCS}driver/drv_dht_internal.c ${OBK_SRCS}driver/drv_dht.c diff --git a/src/cmnds/cmd_newLEDDriver.c b/src/cmnds/cmd_newLEDDriver.c index cc24d6281..759327533 100644 --- a/src/cmnds/cmd_newLEDDriver.c +++ b/src/cmnds/cmd_newLEDDriver.c @@ -146,6 +146,7 @@ bool LED_IsLedDriverChipRunning() || DRV_IsRunning("KP18058") || DRV_IsRunning("SM16703P") || DRV_IsRunning("SM15155E") + || DRV_IsRunning("DMX") ; #else return false; @@ -660,8 +661,8 @@ void apply_smart_light() { #endif #if ENABLE_DRIVER_SM16703P if (pixel_count > 0 && (g_lightMode != Light_Anim || g_lightEnableAll == 0)) { - SM16703P_setAllPixels(finalColors[0], finalColors[1], finalColors[2], finalColors[3], finalColors[4]); - SM16703P_Show(); + Strip_setAllPixels(finalColors[0], finalColors[1], finalColors[2], finalColors[3], finalColors[4]); + Strip_Apply(); } #endif diff --git a/src/driver/drv_ddp.c b/src/driver/drv_ddp.c index 2e426b0f3..a585f8112 100644 --- a/src/driver/drv_ddp.c +++ b/src/driver/drv_ddp.c @@ -129,11 +129,13 @@ void DDP_Parse(byte *data, int len) { byte bytesPerPixel = ((data[2] & 0b00111000) >> 3 == 0b011) ? 4 : 3; #if ENABLE_DRIVER_SM16703P - if (spiLED.ready) { + if (Strip_IsActive()) { // Note that this is limited by DDP msgbuf size uint32_t numPixels = (len - 10) / 3; + // debug + //addLogAdv(LOG_INFO, LOG_FEATURE_DDP, "DDP_Parse: STRIP path: %i pixels", numPixels); // This immediately activates the pixels, maybe we should read the PUSH flag - SM16703P_setMultiplePixel(numPixels, &data[10], true); + Strip_setMultiplePixel(numPixels, &data[10], true); } else #endif { @@ -141,6 +143,8 @@ void DDP_Parse(byte *data, int len) { g = data[11]; b = data[12]; + //addLogAdv(LOG_INFO, LOG_FEATURE_DDP, "DDP_Parse: bulb path"); + #if ENABLE_LED_BASIC LED_SetDimmerIfChanged(100); if (data[9] == 4) { diff --git a/src/driver/drv_ddpSend.c b/src/driver/drv_ddpSend.c index 3dc265664..7fb64d1bc 100644 --- a/src/driver/drv_ddpSend.c +++ b/src/driver/drv_ddpSend.c @@ -1,5 +1,9 @@ +/* + +*/ + #include "../new_common.h" #include "../new_pins.h" #include "../new_cfg.h" @@ -156,16 +160,18 @@ void DDP_SetHeader(byte *data, int pixelSize, int bytesCount) { data[8] = (byte)((bytesCount >> 8) & 0xFF); // MSB data[9] = (byte)(bytesCount & 0xFF); // LSB } +// startDriver DDPSend +// DDP_Send 192.168.0.226 3 0 FF000000 commandResult_t DDP_Send(const void* context, const char* cmd, const char* args, int cmdFlags) { Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES | TOKENIZER_DONT_EXPAND); if (Tokenizer_GetArgsCount() < 1) { return CMD_RES_NOT_ENOUGH_ARGUMENTS; } const char *ip = Tokenizer_GetArg(0); - int host = Tokenizer_GetArgInteger(1); - int pixelSize = Tokenizer_GetArgInteger(2); - int delay = Tokenizer_GetArgInteger(3); - const char *pData = Tokenizer_GetArg(4); + int port = 4048;// Tokenizer_GetArgInteger(1); + int pixelSize = Tokenizer_GetArgInteger(1); + int delay = Tokenizer_GetArgInteger(2); + const char *pData = Tokenizer_GetArg(3); int numBytes = strlen(pData) / 2; int headerSize = 10; byte *data = malloc(headerSize+numBytes); @@ -175,7 +181,7 @@ commandResult_t DDP_Send(const void* context, const char* cmd, const char* args, cur++; } DDP_SetHeader(data, pixelSize, (cur- headerSize)); - DRV_DDPSend_Send(ip, host, data, cur, delay); + DRV_DDPSend_Send(ip, port, data, cur, delay); free(data); return CMD_RES_OK; } diff --git a/src/driver/drv_dmx512.c b/src/driver/drv_dmx512.c index fee705c82..7ee5cf654 100644 --- a/src/driver/drv_dmx512.c +++ b/src/driver/drv_dmx512.c @@ -1,9 +1,31 @@ -#include "../new_cfg.h" +/* + +// #define RS485_SE_PIN 19 +// digitalWrite(RS485_SE_PIN, HIGH); +setPinRole 19 AlwaysHigh + +// #define RS485_EN_PIN 17 +// digitalWrite(RS485_EN_PIN, HIGH); +setPinRole 17 AlwaysHigh + +// #define PIN_5V_EN 16 +// digitalWrite(PIN_5V_EN, HIGH); +setPinRole 16 AlwaysHigh + +// UART TX (for RS485) on 22 +startDriver DMX 22 +SM16703P_Init 50 RGBW +startDriver PixelAnim + +*/ +#include "../new_cfg.h" #include "../new_common.h" #include "../new_pins.h" // Commands register, execution API and cmd tokenizer #include "../cmnds/cmd_public.h" #include "../hal/hal_pins.h" +#include "../hal/hal_uart.h" +#include "../hal/hal_generic.h" #include "../httpserver/new_http.h" #include "../logging/logging.h" #include "../mqtt/new_mqtt.h" @@ -20,24 +42,43 @@ static byte *g_dmxBuffer; static int dmx_pixelCount = 0; static int dmx_pixelSize = 3; -int dmx_pin = 0; +int dmx_pin = 22; +void HAL_UART_Flush(void); +void HAL_SetBaud(uint32_t baud); void DMX_Show() { - // BREAK: pull TX low manually - HAL_PIN_Setup_Output(dmx_pin); - HAL_PIN_SetOutputValue(dmx_pin, 0); - HAL_Delay_us(120); // ≥88µs - HAL_PIN_SetOutputValue(dmx_pin, 1); - HAL_Delay_us(12); // MAB ≥8µs - - // restore UART and send DMX data - HAL_UART_Init(250000, 2, true); - for (int i = 0; i < DMX_BUFFER_SIZE; i++) { - HAL_UART_SendByte(g_dmxBuffer[i]); + if (g_dmxBuffer == 0) { + return; + } +#if !WINDOWS + for (int i = 0; i < 2; i++) +#endif + { +#if WINDOWS + // BREAK: pull TX low manually + HAL_PIN_Setup_Output(dmx_pin); + HAL_PIN_SetOutputValue(dmx_pin, 0); + HAL_Delay_us(120); // ≥88µs + HAL_PIN_SetOutputValue(dmx_pin, 1); + HAL_Delay_us(12); // MAB ≥8µs + HAL_UART_Init(250000, 2, false, dmx_pin, -1); +#else +#define DMX_BREAK_DURATION_MICROS 88 + uint32_t breakBaud = 1000000 * 8 / DMX_BREAK_DURATION_MICROS; + HAL_SetBaud(breakBaud); + HAL_UART_SendByte(0); + HAL_UART_Flush(); + HAL_SetBaud(250000); +#endif + + // restore UART and send DMX data + for (int i = 0; i < DMX_BUFFER_SIZE; i++) { + HAL_UART_SendByte(g_dmxBuffer[i]); + } + //Serial485.begin(250000, SERIAL_8N2, RS485_RX_PIN, RS485_TX_PIN); + ////Serial485.write(dmxBuffer, sizeof(dmxBuffer)); + //Serial485.flush(); } - //Serial485.begin(250000, SERIAL_8N2, RS485_RX_PIN, RS485_TX_PIN); - ////Serial485.write(dmxBuffer, sizeof(dmxBuffer)); - //Serial485.flush(); } byte DMX_GetByte(uint32_t idx) { @@ -47,7 +88,7 @@ byte DMX_GetByte(uint32_t idx) { } void DMX_setByte(int idx, byte color) { if (idx >= DMX_CHANNELS_SIZE) - return 0; + return; g_dmxBuffer[1 + idx] = color; } @@ -57,6 +98,8 @@ void DMX_SetLEDCount(int pixel_count, int pixel_size) { } void DMX_Init() { + dmx_pin = Tokenizer_GetArgIntegerDefault(1, dmx_pin); + g_dmxBuffer = (byte*)malloc(DMX_BUFFER_SIZE); memset(g_dmxBuffer, 0, DMX_BUFFER_SIZE); ledStrip_t ws_export; @@ -66,9 +109,10 @@ void DMX_Init() { ws_export.setLEDCount = DMX_SetLEDCount; LEDS_InitShared(&ws_export); + + HAL_UART_Init(250000, 2, false, dmx_pin, -1); } void DMX_OnEverySecond() { - } diff --git a/src/driver/drv_drawers.c b/src/driver/drv_drawers.c index 292abd2ad..f37e6845f 100644 --- a/src/driver/drv_drawers.c +++ b/src/driver/drv_drawers.c @@ -34,7 +34,7 @@ static int DR_LedIndex(http_request_t* request) { int index = atoi(tmp); g_timeOuts[index] = g_on_timeout_ms; #if ENABLE_DRIVER_SM16703P - SM16703P_setPixel(index, SPLIT_COLOR(g_on_color), 0, 0); + Strip_setPixel(index, SPLIT_COLOR(g_on_color), 0, 0); #endif g_changes++; return 0; @@ -47,7 +47,7 @@ static void applyAmbient() { g_changes++; for (int i = 0; i < g_numLEDs; i++) { #if ENABLE_DRIVER_SM16703P - SM16703P_setPixel(i, SPLIT_COLOR(c), 0, 0); + Strip_setPixel(i, SPLIT_COLOR(c), 0, 0); #endif } } @@ -148,14 +148,14 @@ void Drawers_Init() { } void Drawers_QuickTick() { - //SM16703P_setAllPixels(SPLIT_COLOR(g_on_color)); + //Strip_setAllPixels(SPLIT_COLOR(g_on_color)); for (int i = 0; i < g_numLEDs; i++) { if (g_timeOuts[i] > 0) { g_timeOuts[i] -= g_deltaTimeMS; if (g_timeOuts[i] <= 0) { #if ENABLE_DRIVER_SM16703P - SM16703P_setPixel(i,SPLIT_COLOR(g_off_color), 0, 0); + Strip_setPixel(i,SPLIT_COLOR(g_off_color), 0, 0); #endif g_timeOuts[i] = 0; g_changes++; diff --git a/src/driver/drv_leds_shared.c b/src/driver/drv_leds_shared.c index 21b9d801a..c9ccbd138 100644 --- a/src/driver/drv_leds_shared.c +++ b/src/driver/drv_leds_shared.c @@ -41,7 +41,7 @@ void SM16703P_GetPixel(uint32_t pixel, byte *dst) { } } -bool SM16703P_VerifyPixel(uint32_t pixel, byte r, byte g, byte b) { +bool Strip_VerifyPixel(uint32_t pixel, byte r, byte g, byte b) { byte real[4]; SM16703P_GetPixel(pixel, real); if (real[0] != r) @@ -52,7 +52,7 @@ bool SM16703P_VerifyPixel(uint32_t pixel, byte r, byte g, byte b) { return false; return true; } -bool SM16703P_VerifyPixel4(uint32_t pixel, byte r, byte g, byte b, byte w) { +bool Strip_VerifyPixel4(uint32_t pixel, byte r, byte g, byte b, byte w) { byte real[4]; SM16703P_GetPixel(pixel, real); if (real[0] != r) @@ -67,7 +67,7 @@ bool SM16703P_VerifyPixel4(uint32_t pixel, byte r, byte g, byte b, byte w) { } -void SM16703P_setPixel(int pixel, int r, int g, int b, int c, int w) { +void Strip_setPixel(int pixel, int r, int g, int b, int c, int w) { if (pixel < 0 || pixel >= pixel_count) { return; // out of range - would crash } @@ -100,7 +100,7 @@ void SM16703P_setPixel(int pixel, int r, int g, int b, int c, int w) { } } -void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push) { +void Strip_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push) { // Check max pixel if (pixel > pixel_count) pixel = pixel_count; @@ -112,15 +112,14 @@ void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push) { g = *data++; b = *data++; // TODO: Not sure how this works. Should we add Cold and Warm white here as well? - SM16703P_setPixel((int)i, (int)r, (int)g, (int)b, 0, 0); + Strip_setPixel((int)i, (int)r, (int)g, (int)b, 0, 0); } if (push) { - SM16703P_Show(); - + Strip_Apply(); } } extern float g_brightness0to100;//TODO -void SM16703P_setPixelWithBrig(int pixel, int r, int g, int b, int c, int w) { +void Strip_setPixelWithBrig(int pixel, int r, int g, int b, int c, int w) { // scale brightness #if ENABLE_LED_BASIC r = (int)(r * g_brightness0to100*0.01f); @@ -129,11 +128,11 @@ void SM16703P_setPixelWithBrig(int pixel, int r, int g, int b, int c, int w) { c = (int)(c * g_brightness0to100*0.01f); w = (int)(w * g_brightness0to100*0.01f); #endif - SM16703P_setPixel(pixel, r, g, b, c, w); + Strip_setPixel(pixel, r, g, b, c, w); } #define SCALE8_PIXEL(x, scale) (uint8_t)(((uint32_t)x * (uint32_t)scale) / 256) -void SM16703P_scaleAllPixels(int scale) { +void Strip_scaleAllPixels(int scale) { int pixel; byte b; int ofs; @@ -148,11 +147,11 @@ void SM16703P_scaleAllPixels(int scale) { } } } -void SM16703P_setAllPixels(int r, int g, int b, int c, int w) { +void Strip_setAllPixels(int r, int g, int b, int c, int w) { int pixel; for (pixel = 0; pixel < pixel_count; pixel++) { - SM16703P_setPixel(pixel, r, g, b, c, w); + Strip_setPixel(pixel, r, g, b, c, w); } } @@ -213,11 +212,11 @@ commandResult_t SM16703P_CMD_setPixel(const void *context, const char *cmd, cons if (all) { for (i = 0; i < pixel_count; i++) { - SM16703P_setPixel(i, r, g, b, c, w); + Strip_setPixel(i, r, g, b, c, w); } } else { - SM16703P_setPixel(pixel, r, g, b, c, w); + Strip_setPixel(pixel, r, g, b, c, w); } @@ -233,7 +232,7 @@ commandResult_t SM16703P_InitForLEDCount(const void *context, const char *cmd, c return CMD_RES_NOT_ENOUGH_ARGUMENTS; } - SM16703P_Shutdown(); + //SM16703P_Shutdown(); // First arg: number of pixel to address pixel_count = Tokenizer_GetArgIntegerRange(0, 0, 255); @@ -271,6 +270,9 @@ commandResult_t SM16703P_InitForLEDCount(const void *context, const char *cmd, c } } pixel_size = i; // number of color channels + if (color_channel_order != default_color_channel_order) { + os_free(color_channel_order); + } color_channel_order = new_channel_order; } led_backend.setLEDCount(pixel_count, pixel_size); @@ -281,8 +283,17 @@ commandResult_t SM16703P_InitForLEDCount(const void *context, const char *cmd, c return CMD_RES_OK; } -static commandResult_t SM16703P_StartTX(const void *context, const char *cmd, const char *args, int flags) { +bool Strip_IsActive() { + if (led_backend.apply) { + return true; + } + return false; +} +void Strip_Apply() { led_backend.apply(); +} +static commandResult_t SM16703P_StartTX(const void *context, const char *cmd, const char *args, int flags) { + Strip_Apply(); return CMD_RES_OK; } @@ -322,4 +333,6 @@ void LEDS_ShutdownShared() { color_channel_order = default_color_channel_order; } pixel_size = DEFAULT_PIXEL_SIZE; + pixel_count = 0; + memset(&led_backend, 0, sizeof(led_backend)); } diff --git a/src/driver/drv_local.h b/src/driver/drv_local.h index e27c7d091..cb18c3a10 100644 --- a/src/driver/drv_local.h +++ b/src/driver/drv_local.h @@ -67,14 +67,16 @@ void SM16703P_Shutdown(); // set RGBCW values - Cold and Warm White are optional and might be ignored if hardware does not support them, or if // channel order does not include them. // default is RGB, so C and W are ignored by default - needs to be enabled with something like 'SM16703P_Init 20 RGBCW' -void SM16703P_setPixel(int pixel, int r, int g, int b, int c, int w); -void SM16703P_setPixelWithBrig(int pixel, int r, int g, int b, int c, int w); -void SM16703P_setAllPixels(int r, int g, int b, int c, int w); -void SM16703P_scaleAllPixels(int scale); -void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t* data, bool push); +void Strip_setPixel(int pixel, int r, int g, int b, int c, int w); +void Strip_setPixelWithBrig(int pixel, int r, int g, int b, int c, int w); +void Strip_setAllPixels(int r, int g, int b, int c, int w); +void Strip_scaleAllPixels(int scale); +void Strip_setMultiplePixel(uint32_t pixel, uint8_t* data, bool push); void SM16703P_Show(); void SM15155E_Init(); -void SM15155E_Write(); +void SM15155E_Write(float *rgbcw); +void Strip_Apply(); +bool Strip_IsActive(); extern uint32_t pixel_count; void TM1637_Init(); diff --git a/src/driver/drv_pixelAnim.c b/src/driver/drv_pixelAnim.c index dcd7d5645..05537aa0f 100644 --- a/src/driver/drv_pixelAnim.c +++ b/src/driver/drv_pixelAnim.c @@ -51,20 +51,20 @@ uint16_t count = 0; int direction = 1; void fadeToBlackBy(uint8_t fadeBy) { - SM16703P_scaleAllPixels(255-fadeBy); + Strip_scaleAllPixels(255-fadeBy); } void ShootingStar_Run() { int tail_length = 32; if (direction == -1) { // Reverse direction option for LEDs if (count < pixel_count) { - SM16703P_setPixelWithBrig(pixel_count - (count % (pixel_count + 1)), + Strip_setPixelWithBrig(pixel_count - (count % (pixel_count + 1)), led_baseColors[0], led_baseColors[1], led_baseColors[2], led_baseColors[3], led_baseColors[4]); // Set LEDs with the color value } count++; } else { if (count < pixel_count) { // Forward direction option for LEDs - SM16703P_setPixelWithBrig(count % pixel_count, + Strip_setPixelWithBrig(count % pixel_count, led_baseColors[0], led_baseColors[1], led_baseColors[2], led_baseColors[3], led_baseColors[4]); // Set LEDs with the color value } count++; @@ -73,7 +73,7 @@ void ShootingStar_Run() { count = 0; } fadeToBlackBy(tail_length); // Fade the tail LEDs to black - SM16703P_Show(); + Strip_Apply(); } void RainbowCycle_Run() { byte *c; @@ -81,9 +81,9 @@ void RainbowCycle_Run() { for (i = 0; i < pixel_count; i++) { c = RainbowWheel_Wheel(((i * 256 / pixel_count) + j) & 255); - SM16703P_setPixelWithBrig(pixel_count - 1 - i, *c, *(c + 1), *(c + 2), 0, 0); + Strip_setPixelWithBrig(pixel_count - 1 - i, *c, *(c + 1), *(c + 2), 0, 0); } - SM16703P_Show(); + Strip_Apply(); j++; j %= 256; } @@ -98,13 +98,13 @@ void Fire_setPixelHeatColor(int Pixel, byte temperature) { // Figure out which third of the spectrum we're in: if (t192 > 0x80) { // hottest - SM16703P_setPixelWithBrig(Pixel, 255, 255, heatramp, 0, 0); // red to yellow + Strip_setPixelWithBrig(Pixel, 255, 255, heatramp, 0, 0); // red to yellow } else if (t192 > 0x40) { // middle - SM16703P_setPixelWithBrig(Pixel, 255, heatramp, 0, 0, 0); // red to yellow + Strip_setPixelWithBrig(Pixel, 255, heatramp, 0, 0, 0); // red to yellow } else { // coolest - SM16703P_setPixelWithBrig(Pixel, heatramp, 0, 0, 0, 0); + Strip_setPixelWithBrig(Pixel, heatramp, 0, 0, 0, 0); } } // FlameHeight - Use larger value for shorter flames, default=50. @@ -164,10 +164,84 @@ void Fire_Run() { for (int j = 0; j < pixel_count; j++) { Fire_setPixelHeatColor(j, heat[j]); } - SM16703P_Show(); + Strip_Apply(); } +static int comet_pos = 0; +static int comet_dir_local = 1; +static int comet_tail_len = 16; +void Comet_Run() { + int head = comet_pos; + int tail = comet_tail_len; + if (comet_dir_local > 0) { + comet_pos++; + if (comet_pos >= pixel_count) { + comet_pos = pixel_count - 1; + comet_dir_local = -1; + } + } + else { + comet_pos--; + if (comet_pos < 0) { + comet_pos = 0; + comet_dir_local = 1; + } + } + + fadeToBlackBy(48); + + Strip_setPixelWithBrig(head, + led_baseColors[0], led_baseColors[1], led_baseColors[2], led_baseColors[3], led_baseColors[4]); + + for (int t = 1; t <= tail; t++) { + int idx = head - t * comet_dir_local; + if (idx < 0 || idx >= pixel_count) continue; + float scale = (float)(tail - t) / (float)tail; + if (scale < 0) scale = 0; + byte r = (byte)round(led_baseColors[0] * scale); + byte g = (byte)round(led_baseColors[1] * scale); + byte b = (byte)round(led_baseColors[2] * scale); + Strip_setPixelWithBrig(idx, r, g, b, 0, 0); + } + + Strip_Apply(); +} +static int chase_pos = 0; + +void TheaterChase_Run() { + fadeToBlackBy(200); + + for (int i = 0; i < pixel_count; i++) { + if ((i + chase_pos) % 3 == 0) { + Strip_setPixelWithBrig(i, + led_baseColors[0], led_baseColors[1], led_baseColors[2], + led_baseColors[3], led_baseColors[4]); + } + } + Strip_Apply(); + + chase_pos++; + if (chase_pos >= 3) chase_pos = 0; +} + +static int chase_rainbow_pos = 0; + +void TheaterChaseRainbow_Run() { + for (int i = 0; i < pixel_count; i++) { + if ((i + chase_rainbow_pos) % 3 == 0) { + byte *c = RainbowWheel_Wheel((i + chase_rainbow_pos * 8) & 255); + Strip_setPixelWithBrig(i, *c, *(c + 1), *(c + 2), 0, 0); + } + else { + Strip_setPixelWithBrig(i, 0, 0, 0, 0, 0); + } + } + Strip_Apply(); + + chase_rainbow_pos++; + if (chase_rainbow_pos >= 3) chase_rainbow_pos = 0; +} // startDriver PixelAnim typedef struct ledAnim_s { @@ -179,7 +253,10 @@ int activeAnim = -1; ledAnim_t g_anims[] = { { "Rainbow Cycle", RainbowCycle_Run }, { "Fire", Fire_Run }, - { "Shooting Star", ShootingStar_Run } + { "Shooting Star", ShootingStar_Run }, + { "Comet", Comet_Run }, + { "Theater Chase", TheaterChase_Run }, + { "Theater Chase Rainbow", TheaterChaseRainbow_Run } }; int g_numAnims = sizeof(g_anims) / sizeof(g_anims[0]); int g_speed = 0; diff --git a/src/driver/drv_public.h b/src/driver/drv_public.h index c8f8c7369..05766bed8 100644 --- a/src/driver/drv_public.h +++ b/src/driver/drv_public.h @@ -62,7 +62,7 @@ void DRV_ShutdownAllDrivers(); bool DRV_IsRunning(const char* name); void DRV_OnChannelChanged(int channel, int iVal); #if PLATFORM_BK7231N -void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push); +void Strip_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push); #endif void DRV_GosundSW2_Write(float* rgbcw); void SM2135_Write(float* rgbcw); diff --git a/src/driver/drv_sm16703P.c b/src/driver/drv_sm16703P.c index deb628c8e..891ade23f 100644 --- a/src/driver/drv_sm16703P.c +++ b/src/driver/drv_sm16703P.c @@ -14,7 +14,6 @@ #include "drv_local.h" #include "drv_spiLED.h" - void SM16703P_Show() { if (spiLED.ready == 0) return; diff --git a/src/driver/drv_uart.c b/src/driver/drv_uart.c index 1c9c186a3..acc481929 100644 --- a/src/driver/drv_uart.c +++ b/src/driver/drv_uart.c @@ -252,9 +252,9 @@ int UART_InitUARTEx(int auartindex, int baud, int parity, bool hwflowc) uartbuf_t* fuartbuf = UART_GetBufFromPort(auartindex); fuartbuf->g_uart_init_counter++; #ifdef UART_2_UARTS_CONCURRENT - HAL_UART_InitEx(auartindex, baud, parity, hwflowc); + HAL_UART_InitEx(auartindex, baud, parity, hwflowc, -1, -1); #else - HAL_UART_Init(baud, parity, hwflowc); + HAL_UART_Init(baud, parity, hwflowc, -1, -1); #endif return fuartbuf->g_uart_init_counter; } diff --git a/src/hal/bk7231/hal_uart_bk7231.c b/src/hal/bk7231/hal_uart_bk7231.c index d3cdc8bbc..be6067a13 100644 --- a/src/hal/bk7231/hal_uart_bk7231.c +++ b/src/hal/bk7231/hal_uart_bk7231.c @@ -28,7 +28,7 @@ void HAL_UART_SendByteEx(int auartindex, byte b) bk_send_byte(bk_port_from_portindex(auartindex), b); } -int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc) +int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { bk_uart_config_t config; diff --git a/src/hal/bl602/hal_uart_bl602.c b/src/hal/bl602/hal_uart_bl602.c index ce7e3299c..6e85846f8 100644 --- a/src/hal/bl602/hal_uart_bl602.c +++ b/src/hal/bl602/hal_uart_bl602.c @@ -66,7 +66,7 @@ void HAL_UART_SendByte(byte b) //bl_uart_data_send(g_id, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(fd_console < 0) { diff --git a/src/hal/ecr6600/hal_uart_ecr6600.c b/src/hal/ecr6600/hal_uart_ecr6600.c index 09294d253..077251ff2 100644 --- a/src/hal/ecr6600/hal_uart_ecr6600.c +++ b/src/hal/ecr6600/hal_uart_ecr6600.c @@ -25,7 +25,7 @@ void HAL_UART_SendByte(byte b) drv_uart_send_poll(uart, &b, 1); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { drv_uart_close(uart); T_DRV_UART_CONFIG config = diff --git a/src/hal/espidf/hal_uart_espidf.c b/src/hal/espidf/hal_uart_espidf.c index 58b3521fd..7cbb331dd 100644 --- a/src/hal/espidf/hal_uart_espidf.c +++ b/src/hal/espidf/hal_uart_espidf.c @@ -30,29 +30,29 @@ uint8_t* data = NULL; static void uart_event_task(void* pvParameters) { uart_event_t event; - for(;;) + for (;;) { - if(xQueueReceive(uart_queue, (void*)&event, (TickType_t)portMAX_DELAY)) + if (xQueueReceive(uart_queue, (void*)&event, (TickType_t)portMAX_DELAY)) { bzero(data, 512); - switch(event.type) + switch (event.type) { - case UART_DATA: - uart_read_bytes(uartnum, data, event.size, portMAX_DELAY); - for(int i = 0; i < event.size; i++) - { - UART_AppendByteToReceiveRingBuffer(data[i]); - } - break; - case UART_BUFFER_FULL: - case UART_FIFO_OVF: - addLogAdv(LOG_WARN, LOG_FEATURE_CMD, "%s", event.type == UART_BUFFER_FULL ? "UART_BUFFER_FULL" : "UART_FIFO_OVF"); - uart_flush_input(uartnum); - xQueueReset(uart_queue); - break; - default: - addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU, "uart event type: %d", event.type); - break; + case UART_DATA: + uart_read_bytes(uartnum, data, event.size, portMAX_DELAY); + for (int i = 0; i < event.size; i++) + { + UART_AppendByteToReceiveRingBuffer(data[i]); + } + break; + case UART_BUFFER_FULL: + case UART_FIFO_OVF: + addLogAdv(LOG_WARN, LOG_FEATURE_CMD, "%s", event.type == UART_BUFFER_FULL ? "UART_BUFFER_FULL" : "UART_FIFO_OVF"); + uart_flush_input(uartnum); + xQueueReset(uart_queue); + break; + default: + addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU, "uart event type: %d", event.type); + break; } } } @@ -85,12 +85,12 @@ static void uart_event_task(void* pvParameters) static void uart_event_task(void* pvParameters) { uint8_t* data = (uint8_t*)malloc(512); - while(1) + while (1) { int len = uart_read_bytes(uartnum, data, 512, 20 / portTICK_RATE_MS); - if(len) + if (len) { - for(int i = 0; i < len; i++) + for (int i = 0; i < len; i++) { UART_AppendByteToReceiveRingBuffer(data[i]); } @@ -103,9 +103,17 @@ void HAL_UART_SendByte(byte b) uart_write_bytes(uartnum, &b, 1); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +void HAL_UART_Flush(void) { - if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART)) + uart_wait_tx_done(uartnum, pdMS_TO_TICKS(100)); +} +void HAL_SetBaud(uint32_t baud) +{ + uart_set_baudrate(uartnum, baud); +} +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) +{ + if (CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART)) { uartnum = UART_NUM_1; esp_log_level_set("*", ESP_LOG_INFO); @@ -115,7 +123,7 @@ int HAL_UART_Init(int baud, int parity, bool hwflowc) uartnum = UART_NUM_0; esp_log_level_set("*", ESP_LOG_NONE); } - if(uart_is_driver_installed(uartnum)) + if (uart_is_driver_installed(uartnum)) { uart_disable_rx_intr(uartnum); uart_driver_delete(uartnum); @@ -132,10 +140,19 @@ int HAL_UART_Init(int baud, int parity, bool hwflowc) #endif }; uart_param_config(uartnum, &uart_config); - uart_driver_install(uartnum, 512, 0, 0, NULL, 0); + uart_driver_install(uartnum, 4096, 4096, 0, NULL, 0); uart_enable_rx_intr(uartnum); + +#if PLATFORM_ESPIDF + if (txOverride != -1) { + uart_set_pin(uartnum, + txOverride, 21, + UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); + } +#endif + #if 0//PLATFORM_ESPIDF - if(uartnum == UART_NUM_0) + if (uartnum == UART_NUM_0) { uart_set_pin(uartnum, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); } @@ -143,7 +160,7 @@ int HAL_UART_Init(int baud, int parity, bool hwflowc) { uart_set_pin(uartnum, TX1_PIN, RX1_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); } - if(data == NULL) + if (data == NULL) { //data = (uint8_t*)malloc(512); xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 16, NULL); @@ -155,4 +172,4 @@ int HAL_UART_Init(int baud, int parity, bool hwflowc) return 1; } -#endif +#endif \ No newline at end of file diff --git a/src/hal/generic/hal_uart_generic.c b/src/hal/generic/hal_uart_generic.c index 25b57dd96..bfeee64a0 100644 --- a/src/hal/generic/hal_uart_generic.c +++ b/src/hal/generic/hal_uart_generic.c @@ -4,8 +4,15 @@ void __attribute__((weak)) HAL_UART_SendByte(byte b) { } - -int __attribute__((weak)) HAL_UART_Init(int baud, int parity, bool hwflowc) +int __attribute__((weak)) HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { return 0; -} \ No newline at end of file +} +void __attribute__((weak)) HAL_UART_Flush() +{ +} +void __attribute__((weak)) HAL_SetBaud(unsigned int baud) +{ +} + + diff --git a/src/hal/hal_uart.h b/src/hal/hal_uart.h index 8cf97e3fc..ddec5bf54 100644 --- a/src/hal/hal_uart.h +++ b/src/hal/hal_uart.h @@ -8,9 +8,9 @@ #ifdef UART_2_UARTS_CONCURRENT void HAL_UART_SendByteEx(int auartindex, byte b); -int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc); +int HAL_UART_InitEx(int auartindex, int baud, int parity, bool hwflowc, int txOverride, int rxOverride); #else void HAL_UART_SendByte(byte b); -int HAL_UART_Init(int baud, int parity, bool hwflowc); +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride); #endif \ No newline at end of file diff --git a/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c b/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c index 41e601544..d85dc3137 100644 --- a/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c +++ b/src/hal/realtek/rtl8710a/hal_uart_rtl8710a.c @@ -28,7 +28,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c b/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c index 439aed817..0bd9285d8 100644 --- a/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c +++ b/src/hal/realtek/rtl8710b/hal_uart_rtl8710b.c @@ -31,7 +31,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c b/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c index df171b182..051c18e96 100644 --- a/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c +++ b/src/hal/realtek/rtl8720d/hal_uart_rtl8720d.c @@ -36,7 +36,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c b/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c index e4967565f..40ede9c3c 100644 --- a/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c +++ b/src/hal/realtek/rtl8721da/hal_uart_rtl8721da.c @@ -46,7 +46,7 @@ void HAL_UART_SendByte(byte b) serial_putc(&sobj, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c b/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c index 1fdd6332d..3e82ea7a1 100644 --- a/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c +++ b/src/hal/realtek/rtl87x0c/hal_uart_rtl87x0c.c @@ -34,7 +34,7 @@ void HAL_UART_SendByte(byte b) hal_uart_putc(&sobj.uart_adp, b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInitialized) { diff --git a/src/hal/w800/hal_uart_w800.c b/src/hal/w800/hal_uart_w800.c index 341ddfa75..a4e3582ad 100644 --- a/src/hal/w800/hal_uart_w800.c +++ b/src/hal/w800/hal_uart_w800.c @@ -45,7 +45,7 @@ void HAL_UART_SendByte(byte b) tls_uart_write(used_uart, (char*)&b, 1); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { struct tls_uart_options uart_opts; uart_opts.baudrate = baud; diff --git a/src/hal/win32/hal_uart_win32.c b/src/hal/win32/hal_uart_win32.c index 40f660052..8d4de82ce 100644 --- a/src/hal/win32/hal_uart_win32.c +++ b/src/hal/win32/hal_uart_win32.c @@ -13,9 +13,14 @@ void HAL_UART_SendByte(byte b) //addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU,"%02X", b); } -int HAL_UART_Init(int baud, int parity, bool hwflowc) +int HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { return 1; } - +void HAL_UART_Flush(void) +{ +} +void HAL_SetBaud(unsigned int baud) +{ +} #endif \ No newline at end of file diff --git a/src/hal/xradio/hal_uart_xradio.c b/src/hal/xradio/hal_uart_xradio.c index 8e0f853ed..2775514f6 100644 --- a/src/hal/xradio/hal_uart_xradio.c +++ b/src/hal/xradio/hal_uart_xradio.c @@ -29,7 +29,7 @@ void HAL_UART_SendByte(byte b) HAL_UART_Transmit_IT(uart, &b, 1); } -int OBK_HAL_UART_Init(int baud, int parity, bool hwflowc) +int OBK_HAL_UART_Init(int baud, int parity, bool hwflowc, int txOverride, int rxOverride) { if(isInit) return 1; HAL_Status status = HAL_ERROR; diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 583c40fb2..7c2ffaecb 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -230,6 +230,9 @@ int http_fn_index(http_request_t* request) { if (DRV_IsRunning("SM16703P")) { bForceShowRGB = true; } + if (DRV_IsRunning("DMX")) { + bForceShowRGB = true; + } #endif } http_setup(request, httpMimeTypeHTML); //Add mimetype regardless of the request diff --git a/src/obk_config.h b/src/obk_config.h index c4c002d0a..a8fbbd6a3 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -409,6 +409,7 @@ #if (OBK_VARIANT == OBK_VARIANT_ESP4M) #define ENABLE_DRIVER_TCA9554 1 +#define ENABLE_DRIVER_DMX 1 #endif #elif PLATFORM_TR6260 diff --git a/src/selftest/selftest_ws2812b.c b/src/selftest/selftest_ws2812b.c index 7496be3d7..f126616a0 100644 --- a/src/selftest/selftest_ws2812b.c +++ b/src/selftest/selftest_ws2812b.c @@ -3,13 +3,13 @@ #include "selftest_local.h" -bool SM16703P_VerifyPixel(uint32_t pixel, byte r, byte g, byte b); -bool SM16703P_VerifyPixel4(uint32_t pixel, byte r, byte g, byte b, byte a); +bool Strip_VerifyPixel(uint32_t pixel, byte r, byte g, byte b); +bool Strip_VerifyPixel4(uint32_t pixel, byte r, byte g, byte b, byte a); -#define SELFTEST_ASSERT_PIXEL(index, r, g, b) SELFTEST_ASSERT(SM16703P_VerifyPixel(index, r, g, b)); -#define SELFTEST_ASSERT_PIXEL4(index, r, g, b, w) SELFTEST_ASSERT(SM16703P_VerifyPixel4(index, r, g, b, w)); +#define SELFTEST_ASSERT_PIXEL(index, r, g, b) SELFTEST_ASSERT(Strip_VerifyPixel(index, r, g, b)); +#define SELFTEST_ASSERT_PIXEL4(index, r, g, b, w) SELFTEST_ASSERT(Strip_VerifyPixel4(index, r, g, b, w)); -void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push); +void Strip_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push); void Test_DMX_RGB() { // reset whole device @@ -55,6 +55,32 @@ void Test_DMX_RGB() { SELFTEST_ASSERT_HAS_SENT_UART_STRING("00 00 00"); SELFTEST_ASSERT_HAS_UART_EMPTY(); + CMD_ExecuteCommand("startDriver DDP", 0); + // fake DDP packet + { + byte ddpPacket[128]; + + // data starts at offset 10 + // pixel 0 + ddpPacket[10] = 0xFF; + ddpPacket[11] = 0xFF; + ddpPacket[12] = 0xFF; + // pixel 1 + ddpPacket[13] = 0xFF; + ddpPacket[14] = 0x0; + ddpPacket[15] = 0x0; + // pixel 2 + ddpPacket[16] = 0xFF; + ddpPacket[17] = 0x0; + ddpPacket[18] = 0xFF; + + DDP_Parse(ddpPacket, sizeof(ddpPacket)); + + SELFTEST_ASSERT_PIXEL(0, 0xFF, 0xFF, 0xFF); + SELFTEST_ASSERT_PIXEL(1, 0xFF, 0, 0); + SELFTEST_ASSERT_PIXEL(2, 0xFF, 0, 0xFF); + } + // nothing is sent by OBK at that point } void Test_DMX_RGBC() { @@ -185,7 +211,7 @@ void Test_WS2812B() { uint8_t dat[9] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 }; - SM16703P_setMultiplePixel(3, dat, false); + Strip_setMultiplePixel(3, dat, false); SELFTEST_ASSERT_PIXEL(0, 255, 0, 0); SELFTEST_ASSERT_PIXEL(1, 0, 255, 0); SELFTEST_ASSERT_PIXEL(2, 0, 0, 255); @@ -195,7 +221,7 @@ void Test_WS2812B() { uint8_t dat[9] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 }; - SM16703P_setMultiplePixel(3, dat, false); + Strip_setMultiplePixel(3, dat, false); SELFTEST_ASSERT_PIXEL(0, 0, 0, 255); SELFTEST_ASSERT_PIXEL(1, 0, 255, 0); SELFTEST_ASSERT_PIXEL(2, 255, 0, 0); @@ -205,7 +231,7 @@ void Test_WS2812B() { uint8_t dat[9] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 }; - SM16703P_setMultiplePixel(3, dat, false); + Strip_setMultiplePixel(3, dat, false); SELFTEST_ASSERT_PIXEL(0, 0, 0, 255); SELFTEST_ASSERT_PIXEL(1, 0, 255, 0); SELFTEST_ASSERT_PIXEL(2, 255, 0, 0); @@ -215,7 +241,7 @@ void Test_WS2812B() { uint8_t dat[9] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 }; - SM16703P_setMultiplePixel(3, dat, false); + Strip_setMultiplePixel(3, dat, false); SELFTEST_ASSERT_PIXEL(0, 0, 255, 0); SELFTEST_ASSERT_PIXEL(1, 255, 0, 0); SELFTEST_ASSERT_PIXEL(2, 0, 0, 255); @@ -225,7 +251,7 @@ void Test_WS2812B() { uint8_t dat[9] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 }; - SM16703P_setMultiplePixel(3, dat, false); + Strip_setMultiplePixel(3, dat, false); SELFTEST_ASSERT_PIXEL(0, 0, 255, 0); SELFTEST_ASSERT_PIXEL(1, 0, 0, 255); SELFTEST_ASSERT_PIXEL(2, 255, 0, 0); @@ -288,18 +314,18 @@ void Test_WS2812B() { } CMD_ExecuteCommand("startDriver DDP", 0); CMD_ExecuteCommand("startDriver DDPSend", 0); - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 FF00AB", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 FF00AB", 0); SIM_WaitForDDPPacket(); // this requires udp to work so it can pass... if (1) { SELFTEST_ASSERT_PIXEL(0, 0xFF, 0x00, 0xAB); } - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 ABCDEF", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 ABCDEF", 0); SIM_WaitForDDPPacket(); if (1) { SELFTEST_ASSERT_PIXEL(0, 0xAB, 0xCD, 0xEF); } - CMD_ExecuteCommand("DDP_Send 127.0.0.1 4048 3 0 ABCDEFAABBCC", 0); + CMD_ExecuteCommand("DDP_Send 127.0.0.1 3 0 ABCDEFAABBCC", 0); SIM_WaitForDDPPacket(); if (1) { SELFTEST_ASSERT_PIXEL(0, 0xAB, 0xCD, 0xEF); @@ -360,15 +386,15 @@ void Test_WS2812B() { for (int i = 0; i < 6; i++) { SELFTEST_ASSERT_PIXEL(i, 128, 128, 128); } - SM16703P_scaleAllPixels(128); + Strip_scaleAllPixels(128); for (int i = 0; i < 6; i++) { SELFTEST_ASSERT_PIXEL(i, 64, 64, 64); } - SM16703P_scaleAllPixels(128); + Strip_scaleAllPixels(128); for (int i = 0; i < 6; i++) { SELFTEST_ASSERT_PIXEL(i, 32, 32, 32); } - SM16703P_scaleAllPixels(64); + Strip_scaleAllPixels(64); for (int i = 0; i < 6; i++) { SELFTEST_ASSERT_PIXEL(i, 8, 8, 8); }