Skip to content

feat(rx/lpc): WS2812 byte-match loopback plumbing (refs #3021 Phase 2) - #3025

Closed
zackees wants to merge 4 commits into
feat/3021-lpc-sct-rx-phase1from
feat/3021-lpc-sct-rx-phase2
Closed

zackees wants to merge 4 commits into
feat/3021-lpc-sct-rx-phase1from
feat/3021-lpc-sct-rx-phase2

Conversation

@zackees

@zackees zackees commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary

Phase 2 of FastLED #3021 — adds the ws2812SctTest JSON-RPC handler, --ws2812-loopback autoresearch subcommand, and Python orchestrator for the WS2812 byte-match loopback. Stacked on top of #3024 (Phase 1) so the Phase 1 SCT capture path is the substrate.

What ships

Sketch — examples/AutoResearchLpc/AutoResearchLpc.ino

New ws2812SctTest handler gated behind #if defined(FASTLED_LPC_RX_SCT_WS2812) (default OFF; see flash blocker below). Patterns mirror flexioObjectFledTest:

Case LEDs Content
0 1 Red (0xFF, 0x00, 0x00)
1 3 R, G, B chain
2 1 All zeros (T0H/T0L fidelity)
3 1 All ones (T1H/T1L fidelity)
4 100 Alternating R/G/B (watchdog safety)

TX uses the existing bit-bang clockless_arm_lpc.h driver via FastLED.show() (the sync TX driver the issue specifies). RX uses the Phase-1 polling-mode LpcSctRxChannel. Decode goes through the standard fl::make4PhaseTiming + LpcSctRxChannel::decode() path. Returns CSV success,test_case,num_leds,exp_bytes,dec_bytes,matched,mismatched,edges.

Orchestrator — ci/autoresearch/test_lpc_ws2812_loopback.py

Mirrors test_flexio_rx_objectfled.py. Sends each case, parses CSV, asserts mismatched == 0. Final summary prints a polling-vs-DMA reminder when fails are non-zero.

Runner wiring — ci/autoresearch/{args,phases}.py

  • New --ws2812-loopback CLI flag.
  • _run_lpc_ws2812_loopback_tests() dispatcher routing lpc845brk + --ws2812-loopback to the orchestrator.

Two documented blockers for hardware acceptance

Both pre-existing, independent of #3021 itself, and tracked separately:

Blocker 1 — Polling SCT capture can't keep up with 800 kHz WS2812

The Phase-1 LpcSctRxChannel::pollOnce() measures ~2 µs per poll on M0+ @ 30 MHz; WS2812 sub-pulses are 400–850 ns. On real silicon this orchestrator will report mismatched > 0 until the SCT→DMA RX upgrade lands. That upgrade is the right Phase-3 follow-up — out of scope here so the Phase-2 contract can be reviewed and the orchestrator wiring can be verified independently.

Blocker 2 — fl::json flash bloat (FastLED #3002)

#include <FastLED.h> adds 2–4 KB on top of the already-97%-full AutoResearchLpc bring-up sketch. The FASTLED_LPC_RX_SCT_WS2812 flag is therefore default OFF: today's bring-up sketch still fits the budget. When #3002 lands (fl::json soft-FP cleanup), the flag flips on for the lpc845brk fbuild target.

Test plan

Closing #3021

This PR + #3024 land the full Phase 1 + Phase 2 scope from the issue. The remaining hardware-validation step is tracked by the two blockers above. Once both are addressed:

  • bash autoresearch lpc845brk --pin-toggle-rx --upload-port COM10 → Phase 1 PASS
  • bash autoresearch lpc845brk --ws2812-loopback --upload-port COM10 → Phase 2 PASS

#3021 closes at that point.

🤖 Generated with Claude Code

Adds the Phase-2 surface area for FastLED #3021 — the ws2812SctTest
JSON-RPC handler in the LPC845-BRK sketch, an --ws2812-loopback
autoresearch subcommand, and the Python orchestrator that exercises
the 5 fixed WS2812 patterns matching the FlexIO flexioObjectFledTest.

What ships
----------

* `examples/AutoResearchLpc/AutoResearchLpc.ino` — new ws2812SctTest
  handler gated behind `#if defined(FASTLED_LPC_RX_SCT_WS2812)`.
  Default OFF; the include + handler only compile in when the user
  passes `-DFASTLED_LPC_RX_SCT_WS2812=1`. Patterns:
    0 — Red single LED
    1 — RGB three-LED chain
    2 — All zeros (T0H/T0L fidelity)
    3 — All ones (T1H/T1L fidelity)
    4 — 100-LED alternating R/G/B
  Drives TX via `FastLED.show()` through the existing bit-bang
  `clockless_arm_lpc.h` driver (sync TX as the issue specifies),
  captures via the Phase-1 polling-mode `LpcSctRxChannel`,
  decodes 4-phase WS2812 timing, byte-matches against expected.
  Returns CSV
  `success,test_case,num_leds,exp_bytes,dec_bytes,matched,mismatched,edges`.

* `ci/autoresearch/test_lpc_ws2812_loopback.py` — Python orchestrator
  mirroring `test_flexio_rx_objectfled.py` but adapted to the LPC
  sketch's positional-args + CSV-string RPC contract.

* `ci/autoresearch/args.py` — new `--ws2812-loopback` CLI flag.

* `ci/autoresearch/phases.py` — `_run_lpc_ws2812_loopback_tests`
  dispatcher routing lpc845brk + --ws2812-loopback to the orchestrator.

Two documented blockers for hardware acceptance
-----------------------------------------------

Both are PRE-EXISTING (independent of #3021 itself) and tracked
separately so the Phase-2 plumbing can land first and the hardware
gate closes when both blockers are resolved:

1. **Polling-mode SCT capture is too slow for 800 kHz WS2812.**
   Phase 1's `LpcSctRxChannel::pollOnce()` measures one capture
   per ~2 µs on M0+ @ 30 MHz; WS2812 sub-pulses are 400–850 ns.
   `mismatched > 0` is **expected** on real silicon for this
   orchestrator until the SCT→DMA upgrade lands as a follow-up to
   this PR. The orchestrator's final summary prints a reminder.

2. **fl::json soft-FP flash bloat (FastLED #3002) blocks
   `<FastLED.h>` from fitting in the LPC845 64 KB budget alongside
   `fl::Remote`.** The `FASTLED_LPC_RX_SCT_WS2812` flag is therefore
   default OFF — the bring-up sketch keeps fitting today's budget,
   and once #3002 lands the flag flips on for the lpc845brk
   fbuild target.

What this PR does NOT do
------------------------

- Does NOT upgrade the SCT capture path to DMA. That's a follow-up.
- Does NOT optimize the AutoResearchLpc flash footprint. That's #3002.
- Does NOT validate against real LPC845 silicon — no hardware attached
  in this dev environment. Code is bench-ready but un-validated.

Why ship it now
---------------

Mirrors the Phase 1 PR's split-architecture approach: land the
contract and orchestrator first so the hardware gate is a code-free
acceptance step (just flash + run + observe). The polling-vs-DMA gap
+ flash-budget unlock can then be addressed independently without
re-litigating the RPC surface or test plan.

Test plan
---------

- [x] `bash lint` clean on all touched files (C++ + Python).
- [x] Python syntax check via `ast.parse` for all modified .py files.
- [ ] **Hardware bench (blocked on items 1+2 above)** —
      `bash autoresearch lpc845brk --ws2812-loopback --upload-port COM10`
      with FASTLED_LPC_RX_SCT_WS2812=1 in the firmware build.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b5d6e98-3aae-4520-bf46-7475398fc6bd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3021-lpc-sct-rx-phase2

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 and usage tips.

@zackees
zackees deleted the branch feat/3021-lpc-sct-rx-phase1 June 14, 2026 17:45
@zackees zackees closed this Jun 14, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant