Repository navigation
fix(lcd_rgb): fold frames into 12-bit-wide lines; keep RMT RX gap bits (#4669) - #4678
Conversation
#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.
|
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
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe 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. ChangesLCD_CAM RGB frame handling
RMT gap-symbol decoding
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue remains; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
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 ofnumLeds * 96pixels. 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, andtotalTests=0follows; 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 ...(theL4050was taken with diagnostic padding in place).rmt_rx_5/rmt_rx_4decodeRmtSymbols()treated a symbol whose LOW exceedst0l_maxbut fits withingap_toleranceas 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: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 ish_res × v_res. Under one LED of data is rejected instead of dividing by zero (found by/code-review).LcdRgbPeripheralEsp:drawFrame()drawsh_res × (size / line)rather than one line, andhsync_front_porch = 1.rmt_rx_5/rmt_rx_4:decodeGapBit()keeps the gap symbol's bit.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):
After (this branch alone):
LED-count sweep across line boundaries, plus other drivers through the changed RMT decoder. All passed:
--allwith this PR plus #4677, on current master:Notes
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 lintpasses, andbash test channel_driver_lcd_rgbpasses.Summary by CodeRabbit