Skip to content

16-bit pallets and something like CRGB16 #2168

Closed

Description

@coryking

Hey I'm working on a project where i want a "16-bit clean" workflow and i'm running up against not having 16-bit color palette blends and stuff. Also there doesn't seem to be a CRGB16 type to compliment the CRGB one.

Before I go off and let my helper buddy Claude write a bunch of stuff, I'm wondering if any of that is on your roadmap and if I was to eventually submit a PR what "shape" should my stuff be in? Like I see that there is HSV16 and a lot of the lib8tion noise-y stuff has 16-bit clean functions but there is no CRGB16.

Just wondering where you are on this.

Activity

  1. zackees commented on Feb 9, 2026

    @zackees
    Member

    Historically, when this question has come up, my answer has been simple: if RGB8 is sufficient for modern games, it is sufficient for FastLED.

    In most cases, perceived color limitations are not caused by bit depth, but by operating outside of a proper gamma-corrected pipeline. Earlier versions of the engine made this harder to address because the system architecture was tightly coupled, limiting flexibility.

    That constraint no longer applies.

    The current Channels API, which is already in active use (see the issue tracker for real-world examples), fundamentally restructures the engine by separating concerns. Framebuffers, encoders, and output drivers are now fully orthogonal components.

    Concretely:

    • The framebuffer is no longer coupled to the encoding format.
    • The encoder is independent of the physical transport.
    • The output driver has no awareness of color order (RGB, RGBW, etc.), preambles required by newer chipsets, or pixel layout.

    Instead, the driver’s responsibility is strictly defined: it consumes encoded data, groups it appropriately, applies padding as required, and transmits it across N parallel outputs. All color semantics and transformations occur upstream.

    This architecture enables experimentation without destabilizing the system. If you want to explore higher-precision formats such as CRGB16, including AI-driven or perceptual pipelines, that work should be implemented against the Channels API, not the legacy path.

    👉 Channels API documentation:
    https://github.com/FastLED/FastLED/blob/master/src/fl/channels/README.md

    The hypothetical pipeline looks like this:

    fl::span<CRGB16> -> ChannelConfig -> fl::shared_ptr<Channel> -> encoder -> output bytes -> "LED Engine" (parlio/rmt/spi/uart/etc...)

    That's it in a nutshell.

    There's some legacy cruft in the ChannelPtr and the legacy clockless controller + FastLED, but nothing a determined engineer with claude code can't tackle over a few days.

  2. reopened this on Feb 9, 2026
  3. coryking commented on Feb 11, 2026

    @coryking
    ContributorAuthor

    Thanks for the pointer to the Channels API — I'll keep an eye on it as it stabilizes. My question is less about the transport/driver layer and more about the color math side of FastLED — lib8tion, palettes, blending, HSV, and friends.

    I'm driving HD107S LEDs (8-bit RGB + 5-bit brightness) on a POV display spinning at 700-2800 RPM. The real issue isn't the output format — it's that I need to keep precision through the math pipeline so the final output gets downsampled to 8+5 bit rather than upsampling from 8-bit into 8+5. If my render pipeline isn't 16-bit, I get a ton of banding and stairstepping that you'd never notice on a stationary display. (remember, I'm taking 40 physical LEDS and drawing a display with an effective resolution of around 720x40.... and the "color quality" of these led strips are.... not so great so every single bit of brightness change in those leds matter a ton...)

    I've got a working CRGB16 type and 16-bit palette interpolation built for this project:

    • CRGB16 type — mirrors CRGB's API, uses existing FastLED math primitives (eg: scale16by8, lerp16by16)
    • ColorFromPalette16 — 16-bit interpolation between 8-bit palette stops

    Working in 16-bit internally lets me use ColorFromPalette16 with lerp16by16() to get 65K interpolation levels instead of 256, and brightness scaling in 16-bit space doesn't crush low-brightness detail before the final five_bit_bitshift() downscale. The 8+5 output format is clean since five_bit_bitshift() already accepts u16 inputs.

    My actual question: is there any appetite for CRGB16 variants of the color math primitives — palette lookup, blending, HSV conversion? Those are the functions I use heavily and where the 16-bit precision matters most. The transport side is less of a concern for me — I'm currently using NeoPixelBus for SPI output on ESP32-S3 due to #1609.

    Happy to contribute what I've built if there's interest.

  4. zackees commented on Feb 12, 2026

    @zackees
    Member

    There is 100% enthusiastic support for CRGB16, provided it's in the channels api only.

    What's going to be easy to commit is the math stuff, CRGB16, ColorFromPalette16, lerp16by16. I think this will be trivial to add. Each file will need a unit test. This is pretty straight forward, so I won't talk more about this.

    Let's talk about core integration

    What's going to be hard to add is the core driver integration, without going into to much detail, you'll see that the Channel class inherits from that weirdo controller class, this is for legacy purposes and to integrate to the linked list of controllers so that legacy pixel pipeline works when you call FastLED.show().

    There's an alternative hook you can use for CRGB16 color draw pipeline which is EngineEvents onBeforeShow() and onEndShow().

    Also important: SKETCH_HAS_LOTS_OF_MEMORY, all new CRGB16 code should be protected from compilation for legacy memory constrained platforms.

    Here's some notable things

    • EngineEvents onBeforeShow() and onEndShow()
      • completely compiled out unless SKETCH_HAS_LOTS_OF_MEMORY
      • if you put your draw computations here then platform memory constraints go away for your implement
    • FastLED.show()
      • If you put your stuff here then you will need #if SKETCH_HAS_LOTS_OF_MEMORY interleaved throughout

    How to run unit tests

    I don't know if the instructions are up to date, but it's bash test. All dependencies will be auto installed setup for you. Please run bash lint periodically to make sure your code conforms to the style guide. If you run claude code it will know to do this because, unlike 'Nam, this repo has rules.

    Claude is intrinsically instructed to run everything via CLAUDE.md and it will do so via hooks and instructions.

    After you get the math in, let's work on the pixel pipeline, if your running with claude, it might just be easier to ask it to just try an implementation and have me review your draft PR. It's hard for me to guide you on how to do it right, but I definitely know when it's NOT right.

    Of course your contributions will be noted in the next release. I'd love to get this in for the next release, which I've recently decided will be FastLED 4.0.

  5. zackees commented on Feb 21, 2026

    @zackees
    Member

    So i just did something similar for gamma correction and I now know how CRGB16 should be structured.

    using FP = fl::fixed_point<8,8>
    struct CRGB16 {
    FP r;
    FP g;
    FP b;
    };

    We use fixed point and keep the high level values. This is easier to code and think about than raw values.

    This keeps the number values on 0-255 range but also keeps the decimal at 1/255 steps

  6. added
    area: core
    status: triage
    on Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corestatus: triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions