Skip to content

fix(lcd_rgb): fold frames into 12-bit-wide lines; keep RMT RX gap bits (#4669) - #4678

Merged
zackees merged 1 commit into
masterfrom
fix/lcd-rgb-12bit-line-width-4669
Oct 3, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/lcd-rgb-12bit-line-width-4669

Conversation

@zackees

@zackees zackees commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Fixes the LCD_RGB half of #4669 (class=decode_mismatch, capture stops at 44 of 300 bytes on ESP32-P4). Companion to #4677 (PARLIO).

Root causes

1. The frame was truncated by the hardware. LCD_CAM's horizontal active width (lcd_ha_width, bits 19:8) is a 12-bit field on both ESP32-S3 and ESP32-P4, so a line holds at most 4096 pixels. The driver drew the whole frame as a single line of numLeds * 96 pixels. For 100 LEDs that is 9600 px, and the hardware kept 9600 mod 4096 = 1408 px = 352 bits = exactly the 44 bytes captured. A core-0 sampler on the RX pad confirmed that the wire simply goes quiet after that point; there is no mid-frame gap. More than 42 LEDs per lane never left the chip, with no error.

The "exactly 256 raw edges" in the issue is not a limit on the wire. collectRawEdgeDiagnostics() caps its own snapshot at 256.

2. Multi-line frames need a front porch. With hsync_front_porch = 0, an ESP32-P4 never completes a frame that spans more than one line: no VSYNC arrives, the driver stays busy, and totalTests=0 follows; a later call tripped the watchdog. One pixel of front porch fixes it.

3. RMT RX dropped the bit inside a "gap" symbol. The line blank stretches the LOW phase of each line's last bit by about 625 ns. Raw edges at the boundary are clean: ... H325 L925 H625 L625 H325 L4050 H625 ... (the L4050 was taken with diagnostic padding in place). rmt_rx_5/rmt_rx_4 decodeRmtSymbols() treated a symbol whose LOW exceeds t0l_max but fits within gap_tolerance as a gap and skipped the whole symbol. That threw away the bit carried by its HIGH half and shifted the rest of the frame by one bit:

LED[41] expected (0xF0,0x0F,0xAA) got (0xF0,0x0F,0xAB)
LED[42] expected (0xF0,0x0F,0xAA) got (0xE0,0x1F,0x55)

The shared decodeWs2812Edges() already classifies such a bit by its HIGH time. The RMT decoders now do the same. A gap whose long LOW comes first is still skipped.

Changes

  • ChannelEngineLcdRgb: fold the frame into lines of whole LEDs (≤ 4096 px, at most 42 LEDs per line). The last line is padded idle-low. The buffer is h_res × v_res. Under one LED of data is rejected instead of dividing by zero (found by /code-review).
  • LcdRgbPeripheralEsp: drawFrame() draws h_res × (size / line) rather than one line, and hsync_front_porch = 1.
  • rmt_rx_5 / rmt_rx_4: decodeGapBit() keeps the gap symbol's bit.
  • New host test, frame lines fit the 12-bit active width. It was RED on master (9600 <= 4096) and is GREEN now. The existing 1-LED encoding tests are unchanged, since one line still uses 96×1.

Evidence (ESP32-P4, 80:F1:B2:D1:DF:B1, fbuild 2.5.31)

Before (current master + #4677):

TEST LCD_RGB lanes=1 leds=100 FAIL 1026ms class=decode_mismatch
    Decode status:    ok=1 error=-1 bytes=44/96100

After (this branch alone):

TEST LCD_RGB lanes=1 leds=100 PASS 1093ms

LED-count sweep across line boundaries, plus other drivers through the changed RMT decoder. All passed:

LCD_RGB [1] 4/4, [42] 4/4, [43] 4/4, [85] 4/4, [300] 8/8, [100] 4/4
PARLIO [300] 4/4, RMT [100] 4/4, SPI [100] 4/4, UART [100] 4/4

--all with this PR plus #4677, on current master:

--all: skipping drivers this firmware does not register: LCD_CLOCKLESS, LCD_SPI, OBJECT_FLED, FLEX_IO
TEST PARLIO  lanes=1 leds=100 PASS 1073ms
TEST RMT     lanes=1 leds=100 PASS 1055ms
TEST SPI     lanes=1 leds=100 PASS 2057ms
TEST UART    lanes=1 leds=100 PASS 1031ms
TEST LCD_RGB lanes=1 leds=100 PASS 1057ms
AUTORESEARCH SUCCEEDED

Notes

  • The ESP32-S3 has the same 12-bit field and gets the same folding. It compiles (bash compile esp32s3 --examples Blink), but no S3 was on the bench, so it is not hardware-verified.
  • rmt_rx_4 (IDF 4) gets the same decoder fix to keep the duplicated decoders in sync. No IDF-4 target was built or run here.
  • bash lint passes, and bash test channel_driver_lcd_rgb passes.

Summary by CodeRabbit

  • Bug Fixes
    • Improved transmission of long LED frames by splitting them into supported display lines, helping prevent truncation.
    • Improved RGB display frame handling for multi-row images and invalid dimensions.
    • Improved signal decoding by recovering valid bits from stretched-low gap symbols instead of discarding every gap.
    • Rejected LED transmissions that are too short to contain a complete LED, preventing empty frames.

#4669)

LCD_CAM's horizontal active width (lcd_ha_width) is a 12-bit field on
ESP32-S3 and ESP32-P4. The driver drew the whole frame as one line of
numLeds*96 pixels, so anything past 42 LEDs was silently cut to
h_res mod 4096: 100 LEDs (9600 px) went out as 1408 px, the 44 of 300
bytes the P4 loopback captured (class=decode_mismatch).

- Fold the frame into lines of whole LEDs (<= 4096 px, 42 LEDs), last
  line padded idle-low; drawFrame() draws h_res x v_res.
- Give the panel a 1-pixel HSYNC front porch: with 0 an ESP32-P4 never
  completes a multi-line frame (no VSYNC, driver stays busy). The line
  blank only stretches the low phase of each line's last bit (~625 ns).
- RMT RX (rmt_rx_4/rmt_rx_5) skipped a whole "gap" symbol, dropping the
  bit carried by its HIGH half and shifting the rest of the frame by one
  bit. Classify it by HIGH time, as the shared decodeWs2812Edges() does.
- Reject frames of under one LED instead of dividing by zero.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: feb5123f-8952-4945-8201-d06f0fc1b276
📥 Commits

Reviewing files that changed from the base of the PR and between 221626d and b695601.

📒 Files selected for processing (5)
  • src/platforms/esp/32/drivers/lcd_cam/channel_driver_lcd_rgb.cpp.hpp
  • src/platforms/esp/32/drivers/lcd_cam/lcd_rgb_peripheral_esp.cpp.hpp
  • src/platforms/esp/32/drivers/rmt_rx/rmt_rx_4/rmt_rx_channel_4.cpp.hpp
  • src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
  • tests/platforms/esp/32/drivers/lcd_cam/channel_driver_lcd_rgb.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The ESP32 LCD_CAM RGB driver now splits long LED frames into bounded rows and submits buffers using their configured dimensions. The RMT receivers on channels 4 and 5 now decode valid bits from gap-symbol high phases.

Changes

LCD_CAM RGB frame handling

Layer / File(s) Summary
Bounded frame layout and validation
src/platforms/esp/32/drivers/lcd_cam/channel_driver_lcd_rgb.cpp.hpp, tests/platforms/esp/32/drivers/lcd_cam/channel_driver_lcd_rgb.cpp
Transmission setup rejects inputs smaller than three bytes and divides LEDs into whole-LED rows capped at 4096 pixels. Framebuffer size uses the configured dimensions. The 100-LED test checks row widths, capacity, starting pixels, and padding.
Peripheral row submission
src/platforms/esp/32/drivers/lcd_cam/lcd_rgb_peripheral_esp.cpp.hpp
Initialization sets the horizontal front porch to one pixel. drawFrame derives height from the configured width, rejects invalid dimensions, and submits valid buffers using the configured width and derived height.

RMT gap-symbol decoding

Layer / File(s) Summary
Gap-bit recovery on channels 4 and 5
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_4/rmt_rx_channel_4.cpp.hpp, src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Both decoders classify gap-symbol high durations against the configured bit timing ranges. Valid gap bits enter normal accumulation; invalid gaps are skipped. Non-gap symbols continue through the existing decoder.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b6956

No actionable merge-blocking issue remains; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the two main changes: folding LCD_RGB frames into 12-bit-wide lines and preserving RMT RX gap bits.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@zackees
zackees merged commit 84aa047 into master Oct 3, 2026
120 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Oct 3, 2026
@zackees
zackees deleted the fix/lcd-rgb-12bit-line-width-4669 branch November 5, 2026 05:52
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