Repository navigation
Description
I'd like to implement the UCS7604 protocol in FastLED. Unfortunately, the manufacturers don't display any protocol info their datasheets. I have UCS2904 and UCS7604 LEDs, and a closed-source driver than can drive both. The UCS2904 can be driven with FastLED using the TM1804 protocol, as they have similar (probably identical timings).
The UCS7604 one has two major differences from the hardware protocol perspective:
- There is a two-chunk preamble that sets things like max current per channel, speed of data section (800k vs. 1.6M), etc. First chunk is 8 bytes, second is 7, they are separated from each other and the main color data by ~260uS.
- There are 16 bits per R, G, B, and W channel instead of 8 (this should be changeable according to the data sheet, but I have to reverse engineer the proper bits to change in the preamble)
Difference #2 is not a huge deal for me right now, I can scale the incoming 1-byte data into 2-byte data in my firmware. Difference #1 is what I need to patch into FastLED. I'm not sure the best place to do this, however. I don't think I can just shove an extra few bytes into the front of the color data frame before transmitting to act as the config bytes because of the 260uS spacing. I will give it a try though, in case the IC doesn't actually care about the spacing and it's just counting bytes.
The clockless implementation I'm currently using is an ARM chip, which has its output written in the assembly loops. I think I would have to adapt the ASM loop in the m0clockless.h file to add two more loops before the color data, with an appropriate delay in between them. Any other ideas as an easier first way to implement this as a proof of concept?
Here are some labelled screenshots of the output for UCS7604, also with the Saleae capture file attached (Saleae's Logic app is free to download if you want to look through it). I've been able to figure out a couple of the config bits by toggling my driver's settings, but it doesn't have a setting for data width. My guess is that it's in the first two nibbles of the second preamble chunk, but I can't test it until I have a base implementation working from FastLED.
Not looking for anyone to do the work for me, just looking for guidance on the best architecture/implementation by those more familiar with the repo
Activity
zackees commentedon Sep 22, 2025
This one is hard. You need a pause in the middle of your transmission, therefore the generic clockless controller won't work out of the box.
My suggestion is to create a wrapper that takes in a clockless controller type so you can bit bang, wait, bit bang.
This type of wrapper has been implemented via the RGBWEmulated controller. My suggestion is look how that class is implemented and adapt for your own use.
Good luck!
second-string commentedon Sep 22, 2025
RGBW was one that I was poking around it, I'll go a little deeper and check it out.
The bitbang wrapper solution you've mentioned was one of the first things I was thinking of, but I wasn't sure if I could bitbang fast enough and tight enough to adhere to the timing requirements. The RGBWEmulated controller just has to do pre-processing on the data, then can shove it in the normal implementation-specific
showfunction to blast it out as efficiently as possible.Do you know off the top of your head if that's possible (or if it has been done in the repo already) for port/pin register-based control? I'll give it a try regardless if the non-spaced hackier version doesn't work, but will take any prior knowledge I can get.
zackees commentedon Sep 22, 2025
FastLED has fast pin manipulation at it's heart. That's what this library was original designed around and the name before "FastLED" was "FastSPI" because it implemented fast software spi.
One thing I'm now unclear about is whether that preamble chunk + reset is just once for the whole strip or before one each pixel?
If you need a reset time before every pixel then you're in trouble and will have to do manual software bit banging on everything.
second-string commentedon Sep 23, 2025
Ah yes okay I've already worked a bit in the fastpin implementation when I ported a chip so hopefully that shouldn't be too much trouble, thanks.
Just once for the whole strip, thankfully. The color data section is identical timing to UCS2904 (which can be driven by the FastLED-supported TM1804). So once I get the preamble sorted, I just need to figure out which bit to flip to switch from 16-bit to 8-bit data
zackees commentedon Sep 27, 2025
Checking in: how's it going?
second-string commentedon Sep 29, 2025
On holiday at the moment but luckily enough the ICs do not need the spacing pre-data - I was able to get it working by just shoving the 13 bytes at the front of the data payload and driving it all out of the pin with the normal
showPixelscode.I'm still working on getting all the bits figured out for changing the parameters (RGB vs RGBW, 800k vs. 1.6M, etc), but will ideally continue that work a bit late next week
second-string commentedon Oct 6, 2025
Here's what I have figured out and successfully demonstrated on my LEDs
Chunk 1
This seems more of a framing header or clock sync so I don't think there's anything to tweak there. I tried changing the last byte between 0x02, 0x03, and 0x00 but the LEDs didn't respond to anything besides 0x02. I've left this at the default values shown in the screenshots above.
Chunk 2
5 out of the 8 bits here control parameters. Not sure what the other 3 do (if anything) but they had no reaction no matter what combination they were changed in. As listed in the first post, the next 4 bytes are current control for each channel. Bits listed most significant to least significant (i.e. bit 7 is first on the wire), this is different from how the screenshots are labelled above (sorry).
Byte 0
Bit 7: Bit depth per IC (works with bit 3, see Bit Depth note below)
Bit 6: Unknown but causes no visible changes
Bit 5: Unknown but causes no visible changes
Bit 4: High speed (1, 1.6MHz) or standard speed (0, 800kHz) (note this is for the data bytes only, preamble chunks always 800k)
Bit 3: Bit depth per IC (works with bit 7, see Bit Depth note below)
Bit 2: Unknown but causes no visible changes
Bit 1: Field mode high bit (see Field Mode note below)
Bit 0: Field mode low bit (see Field Mode note below)
Bytes 1-4
Software current control per-channel. The driver I have only output up to 0x0F for each of these bytes, I don't know if that's the max or not. I also don't know how this works together with the hardware ILIM resistor, data sheet is unclear.
Bytes 5-6
Unknown, I didn't touch them, all zeroes works.
Data
Standard data output, RGBW ordering
Notes
Bit depth
This one was a pain to figure. The data sheet says there are 4 modes, 8, 12, 14, and 16 bit. For 16 bit depth (i.e. you send two full bytes for red, two full bytes for blue, and so on) both of these bits must be set to 1. For 8 bit depth, both of these bits must be set to 0.
When they are set to different values, the behaviour didn't seem correct for 12 or 14 bit depth. The very first byte of data would control the first pixel red, but then it would revert to what seemed like full 16 bit depth for every remaining channel. For example, second byte of data would control the high values of green brightness, third byte the low values, fourth byte high values of blue, and so on. I don't care about anything other than 8 and 16 bit though, so I didn't dive any deeper into this.
Field mode
The data sheet lists this fairly clearly: you can address each IC as 4 channels of color (R, G, B, and W), 3 channels (R, G, B, and W is never used), 2 channels (first channel is RG, then BW), or 1 channel (each 1 or 2 byte channel depending on bit depth controls all 4 channels of one IC simultaneously). There are two bits for this in the packet, so values 0-3, but the datasheet lists them as 1-4. An actual bit value of 3 corresponds to the standard mode 4: R, G, B, and W individual control. They decrease in the same order of the datasheet.
So as an example, if you wanted 8-bit RGBW data instead of 16-bit, the first byte of chunk 2 would be 0x03 or 0x07 (doesn't matter) instead of the 0x8B shown in the screenshot above.
I do not have the time right now to fully build this out into a mergeable PR (i.e. with the generic wrapper controller to prefix the necessary bits/bytes), I was doing my testing by adding code directly into the
showRGBInternalfunction specifically for m0 chipsets. You can see a diff here (disregard most of the changes it's just auto-formatting).zackees commentedon Oct 7, 2025
Implement UCS7604 Protocol for FastLED
Overview
The UCS7604 is a 4-channel LED driver IC with 16-bit color resolution, configurable bit depth (8/12/14/16-bit), dual data rates (800kHz/1.6MHz), and RGBW support. This task implements FastLED controller support for UCS7604 chipsets using a generic preamble wrapper architecture.
Datasheets & References
Technical Specifications
Hardware
Protocol Structure
Chunk 1 - Framing Header (8 bytes, always 800kHz)
Fixed values for clock sync. Last byte must be
0x02.Chunk 2 - Configuration (7 bytes, always 800kHz)
Configuration Byte (bits 7-0):
00=8-bit,11=16-bit)1=1.6MHz,0=800kHz) - applies to pixel data only11=RGBW,10=RGB,01=RG+BW,00=all channels together)Current Control (bytes 1-4): Per-channel current limit
0x00-0x0F(interacts with hardware ILIM resistor)Examples:
0x8B= 16-bit, 800kHz, RGBW0x9B= 16-bit, 1.6MHz, RGBW0x03= 8-bit, 800kHz, RGBWPixel Data
Implementation Architecture: Generic Preamble Wrapper
Key Insight
UCS7604 requires three transmissions with delays, which conflicts with FastLED's single-transmission model. Solution: Create a platform-agnostic wrapper that sends preambles, then delegates to existing clockless controllers.
Architecture
Advantages
sendPreamble()is platform-specificImplementation Plan
Phase 1: ARM M0 Reference Implementation (WORKING PROTOTYPE EXISTS)
src/platforms/arm/common/preamble_m0clockless.hsendPreamble()using ARM'sshowLedData<>()functionPhase 2: Generic Wrapper Infrastructure
src/chipsets/preamble_controller.hsendPreamble()methodsrc/chipsets/ucs7604.hPhase 3: ESP32 RMT Implementation
src/platforms/esp/32/rmt_5/preamble_rmt_esp32.hsendPreamble()using RMT symbols[chunk1][gap][chunk2][gap][pixels]Phase 4: Additional Platforms (As Needed)
Phase 5: Testing & Documentation
File Structure
Usage Example
Next Steps
Open Questions
0x0Ftruly the maximum? Can higher values be used?Design Decisions
Why ARM M0 First?
Why Wrapper Pattern?
showLedData<>()assemblyPlatform-Specific Reality
Different platforms have fundamentally different transmission models:
showLedData<>()assemblyThe wrapper pattern provides unified API while allowing platform-appropriate implementations.
Reference: Working ARM M0 Prototype
This prototype code successfully drives UCS7604 LEDs on ARM D21/D51 platforms. It demonstrates the key pattern: calling
showLedData<>()three times (chunk1, chunk2, pixels) with 260µs delays.Key Insights from Prototype
showLedData<>()function - Same ARM assembly routine for preambles and pixels0x8B- 16-bit mode, 800kHz, RGBW, max current on all channelsThis pattern must be abstracted into the generic wrapper while maintaining platform-specific transmission methods.
zackees commentedon Oct 7, 2025
See the readme for instructions on how to run this chipset. Let me know if i got it wrong as literally can't test this.
second-string commentedon Oct 7, 2025
Left a few comments even though you didn't ask for them. I'll test the merged implementation with the delays in the next couple of weeks
zackees commentedon Oct 8, 2025
where did you leave the comments?
second-string commentedon Oct 8, 2025
I thought it was a PR since it let me leave comments but it looks like GitHub lets you comment right on the commit now
zackees commentedon Oct 9, 2025
Can you help me out here?
I got the scaffolding but your the chip expert here.
git clone https://github.com/fastled/fastled
cd fastled
<open in vscode + platformio>
edit platformio.ini
Set to due
compile and upload
If you want to change the sketch, the target is dev/dev.ino
zackees commentedon Oct 18, 2025
This was improved with delayNanos(), now the preample (probably wrong) uses a cpu spinnning generic clockless controller to bit bang out the preample.
This means the general framework to carry out the signal is in, please review and see what the actual bits and wait time are necessary to push this out. Should be pretty simple at this point.
second-string commentedon Oct 29, 2025
I've tried a couple times to integrate the FastLED code into our repo but it has become unmanageable in the last ~year since we first integrated it. Previously, I simply dropped the contents of the
src/file into it's own CMake directory in our repo and did a bit of work stubbing or wrapping a couple things. Now with the whole overriding of the C std library files, etc, it's much more complicated. Also, everything is chaotic and in different places (see all the random files in the top level of the repo alone).It seems the AI use is too heavy, as all of these tens (hundreds?!) of daily commits have different changes with zero explanation in the commit message. Maybe someone else will pick this up to test it in the future but I am not able to.
zackees commentedon Oct 30, 2025
Sketches from a decode ago still compile. That's enforced via machines.
If you are having problems it's because you are riding the master branch, raw dog style. Do don't this... Pin your dependencies.
The only guarantee of stability is on the releases. If you ride master branch, you are one of our alpha testers. It's not for everyone.
A lot of these recent changes are to get this driver into this codebase, including delayNanos() which requires using delayCycles<>, which needed to be implemented on every platform.
Don't worry, I got it from here.
[-]How to add standalone prefix to each output of pixel data[/-][+]UCS7604 impl[/+]fixes FastLED#2088
uzlonewolf commentedon Nov 9, 2025
Are you sure about that? I've been playing around with some of these chips and it seems to me they only look at the pulse width and completely ignore the space, which would make that last byte 0x03.
Setting that last byte to anything 0xF0-0xFF causes them to run the diagnostics where they flash the red LED if the 'data in' pin is working, the green if 'backup in' is working, and both if both are (lighting up yellow).
I believe 0x0F is the max for the 7604, however the nearly identical 7804 has a 6-bit current control and uses a max value of 0x3F. My 7604's seem to accept 0x3F just fine and simply ignore that high nibble.
I suspect these are reserved for a future 6-channel version of this chip. Same with bit 2 in byte 0 (which would allow selecting 6 channels).
These chips operate on bits, not bytes. They extract

num_channels * bit_depthbits from the stream and pass the rest onto the next chip. I.e. if you set it to 1 channel and 14-bit, it will extract the first 14 bits out of the stream and pass bits 15+ on to the next chip. You can see this if you hook the logic analyzer up to both data in and data out:uzlonewolf commentedon Nov 9, 2025
num_channels * bit_depthbits from the stream and pass the rest onto the next chip. I.e. if you set it to 1 channel and 14-bit, it will extract the first 14 bits out of the stream and pass bits 15+ on to the next chip.Low Speed:
High Speed:
addresses timings by using the new calculator #2088
uzlonewolf commentedon Nov 11, 2025
Thinking about it a bit more, to increase reliability we should probably increase the low times a bit to make sure they are not being run right at the edge. Adjusting them so they run at the spec'd 800 kbps would be:
Low Speed:
High Speed:
impliments #2088 with full color resolution and component swapping. 1…
zackees commentedon Nov 11, 2025
All modes now supported. Give it a whirl and let me know if it works for you or if there are any problems