Skip to content

HUB75: all six color orders (fixes green/blue-swapped panels), saved across reboots - #8

Open
Bunton33 wants to merge 2 commits into
mainfrom
feat/hub75-color-order
Open

Bunton33 wants to merge 2 commits into
mainfrom
feat/hub75-color-order

Conversation

@Bunton33

@Bunton33 Bunton33 commented Oct 23, 2026 •

Copy link
Copy Markdown

Adds all six HUB75 color orders to the M-1 firmware, so a panel with swapped color lines (the customer's green/blue panel needs RBG) can be fixed from Config > LED & Hardware. Same gap as wled#5723 (nothing is posted upstream).

What was wrong (b8 / upstream 16.0.1)

  • Only RGB and BGR were applied; GRB, BRG, RBG and GBR were silent no-ops.
  • The LED settings page hid the Color Order select for HUB75.
  • BusHub75Matrix did not report its order, so any config save wrote RGB back.

What this does

  • All six orders are applied by permuting the driver's r/g/b GPIO roles once, before the driver is created (the mechanism the old BGR case already used). No per-pixel cost; covers the buffered and the direct-draw paths. Meaning matches WLED's PolyBus orders and WLED-MM Effect Request: Random Pixel Strobe "Overlay" wled/WLED#349: "RBG" = the panel's G input lights blue and its B input lights green.
  • Shipped units are unaffected. The factory cfg.json stores "order":0 and any saved config stores 1; both have always meant "no swap" on HUB75 and still do. Real GRB on HUB75 uses a new HUB75-only value 6. BGR (4) gives exactly the old pins.
  • Persists: getColorOrder() override, so the choice survives save and reboot.
  • Settings page (Config > LED & Hardware): Color Order shown for HUB75 with RGB, BRG, RBG, BGR, GBR, GRB. Switching a bus type to HUB75 and back keeps its order.
Order Panel inputs R / G / B carry M-1 pins r1,g1,b1 / r2,g2,b2
RGB (stored 0 or 1) R / G / B 1,5,6 / 7,13,9 (unchanged)
BRG B / R / G 5,6,1 / 13,9,7
RBG R / B / G 1,6,5 / 7,9,13
BGR B / G / R 6,5,1 / 9,13,7 (same as before)
GBR G / B / R 6,1,5 / 9,7,13
GRB (6) G / R / B 5,1,6 / 13,7,9

Verified (no hardware)

  • apollo/hub75-color-order-test.js (runs in npm test): reads the table and the 0-is-RGB rule straight from the C++ and checks permutations, unchanged pins for stored 0/1/7-15, BGR = old swap, agreement with PolyBus and WLED-MM Effect Request: Random Pixel Strobe "Overlay" wled/WLED#349 on both panel halves. Five deliberate mutations of the C++ are all caught. npm test: 24/24.
  • Settings page: 13 scenarios run on the real page script (load 0/1/3/6, both type round trips, manual choices, idempotence): all pass.
  • Builds: apollo_m1 (+224 bytes vs b8), esp32s3dev_16MB_opi_hub75, esp32dev (non-HUB75, helpers compile out): all succeed, no new warnings.
  • Independent review (shipped-unit safety, settings page, C++): no functional defects; its one UX finding (type round trip) is fixed in the second commit.

Bench check before merging (about 2 minutes per order)

  1. Config > LED & Hardware > HUB75 output > Color Order = X, Save, reboot.
  2. Solid red, green, blue (e.g. {"seg":[{"fx":0,"col":[[255,0,0]]}]}); top and bottom halves must match.
    On a standard panel: RGB = red/green/blue; RBG = red/blue/green; BGR = blue/green/red; GRB = green/red/blue; BRG = green/blue/red; GBR = blue/red/green.
  3. Regression: OTA an untouched b8 unit (raw /cfg.json shows "order":0) without touching settings; colors must be unchanged and the page shows RGB.
  4. On the customer's G/B-swapped panel, RBG must give correct colors.

Notes

  • Applies to the whole HUB75 output (one set of color lines for a chain). On S3 the new order takes effect after the reboot WLED already asks for.
  • Safari/iOS may show the disabled duplicate "GRB" entry greyed out; it cannot be selected.
  • The b8 release does not have this; it ships with the next bundle (gates and apollo/RELEASE_CHECKLIST.md).
  • Customer instruction once released: Config > LED & Hardware > Color Order: RBG > Save > reboot.
  • With M-1: honour the launch preset without WiFi (setup card no longer forced at every boot) #9: saving LED & Hardware on a unit without WiFi also counts as choosing its launch preset, so the setup card stops appearing at power-on (it stays available as preset 5 "Setup").

Credits: troyhacks (MoonModules#349, order semantics and UI idea), softhack007 (pin-swap suggestion in that review), jsenecal (analysis in wled#5723). All EUPL-1.2; no code copied.

🤖 Generated with Claude Code

Bunton33 and others added 2 commits October 23, 2026 16:07
Fixes the gap described in wled#5723 for the M-1: only RGB and BGR were applied, the other four orders were silent no-ops, the LED settings page hid the Color Order select for HUB75, and BusHub75Matrix never reported its order so a config save always wrote RGB.

- Every order is applied by permuting the driver's r/g/b GPIO roles once before the driver is created (same mechanism as the old BGR case): no per-pixel cost, covers the buffered and direct-draw paths. Order meaning matches PolyBus and WLED-MM wled#349: "RBG" fixes a panel whose G and B inputs are swapped.
- Backward compatible: a stored 0 (WLED's GRB default, and what the M-1 factory cfg.json ships) has always meant no swap on HUB75 and still does; a real red/green swap on HUB75 uses the new value 6. Stored 1 (any saved config) and BGR (4) produce exactly the same pins as before.
- BusHub75Matrix::getColorOrder() returns the order, so cfg.json and the settings page keep it.
- Settings: Color Order shown for HUB75 with RGB, BRG, RBG, BGR, GBR, GRB.
- apollo/hub75-color-order-test.js (npm test) checks the table and normalisation read from the C++ source.

Credits: troyhacks (MoonModules#349), softhack007 (pin-swap suggestion in that review), jsenecal (analysis in wled#5723).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd back

GRB is value 0 on strips but 6 on HUB75 (where a stored 0 is the legacy no-swap RGB). The page now remembers the value a conversion replaced, so WS281x GRB -> HUB75 -> WS281x stays GRB and HUB75 GRB -> strip -> HUB75 stays GRB; a manual choice clears the memory. Found in review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant