Repository navigation
Conversation
Single-wire WS2811/WS2812 driver that plugs into the shared LED layer, so SM16703P_Init/SetPixel/Start and the DDP driver work on top of it. Written for the Action HDMI sync box, where the data goes out on P0 (UCS1912_DIN) as inverted WS2812B with P8 held low (AlwaysLow). The send loop is placed in section .text.WS2811BB_SendRam so it can run from ITCM; this needs a matching line in the SDK linker script (openshwprojects/OpenBK7231N). Enabled for PLATFORM_BK7231N only.
The OpenBK7231N_ALT build uses sdk/beken_freertos_sdk (PLATFORM_BEKEN_NEW) and an explicit source list in platforms/obk_main.mk, so drv_ws2811bb.c was not compiled there and drv_main.c failed to link (undefined reference to WS2811BB_Init/WS2811BB_Shutdown). The driver relies on the standard SDK linker script (ITCM section), headers and interrupt macros, and has not been tested on the ALT SDK, so it is not enabled there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
WS2811BBdriver: a bit-banged single-wire driver for WS2811/WS2812 style strips on the BK7231N, plugged into the shared LED layer (drv_leds_shared).SM16703P_Init,SM16703P_SetPixel,SM16703P_Startand the DDP driver work on top of it, so a strip can be driven in real time from Hyperion (udpddp).It was written for the Action "LSC Smart Connect HDMI Sync Box" (Tuya based, BK7231N/CBU), following the discussion in https://www.elektroda.com/rtvforum/topic4123137.html. On that box, P0 and P8 are the two inputs of a NOR gate whose output is the strip data line: P8 must be held low (pin role
AlwaysLow) and the data goes out on P0 (pin roleUCS1912_DIN) as inverted WS2812B (idle high, pulses low). P0 is UART2_TXD, so SPI is not an option, hence bit-banging. Pinout credit: emarck, in the thread above.How it works
.text.WS2811BB_SendRam) so that it can run from ITCM, where instruction fetch time is constant.WS2811BB_Timing n0h n0l n1h n1l(loop iterations),WS2811BB_Invert 0|1(default 1),WS2811BB_Calib(measures the real bit period, result in the log).ENABLE_DRIVER_WS2811BBis enabled for the standard BK7231N SDK build only (PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW), not forOpenBK7231N_ALT(beken_freertos_sdk), where it has not been tested.Dependency on the SDK (separate repository)
For reliable timing the function above must actually be linked into ITCM. That needs one line in the SDK linker script
bk7231n_ota.ld(*(.text.WS2811BB_SendRam)), which lives inopenshwprojects/OpenBK7231N: openshwprojects/OpenBK7231N#30. Without it the code runs from flash. I tried exactly that: with Hyperion streaming frames over DDP the strip visibly flickered (observed by eye; the measured delay-loop iteration was about 87 ns instead of about 55 ns with ITCM, so the pulse widths also move). Code placed in.dataRAM crashed the device (watchdog), ITCM works.Note: this PR compiles and works on its own, but until that SDK change is merged and the
sdk/OpenBK7231Nsubmodule here points to a commit that contains it, the send loop stays in flash and the output will flicker.Testing
main(168cba5) and on tag 1.18.219 for OpenBK7231N; CI is green, including theOpenBK7231N_ALTbuilds where the driver is not enabled.Questions for the maintainers
Documentation and build notes: https://github.com/NassimDIB/hdmi-sync-box-ambilight
Disclosure: this work was developed with the help of Claude Code (Anthropic); all results were checked on real hardware.