fix: write both bitplanes for BWR/BWY direct display#82
Open
balloob wants to merge 1 commit into
Open
Conversation
The BLE direct-write path sized 3-colour (BWR/BWY) uploads at a single flat plane and never switched the controller to PLANE_1, so the accent (red/yellow) plane was never written and every 3-colour refresh showed stale accent RAM. The "Big Refactor" (fd0d73a) dropped the plane-switch logic that existed in 5dcb60b. Senders (py-opendisplay, website JS) transmit two concatenated, row-padded 1-bit planes: plane0 = black/white (palette index 1), plane1 = accent (index 2) - byte-for-byte the same layout the GRAY4 path already streams. Route BWR/BWY through the existing two-plane streamer (streamGray4Bytes): - Size the upload at two row-padded planes in handleDirectWriteStart (also makes the compressed decompressed-size check equal the client's 2-plane uncompressed_size, fixing the compressed-BWR START NACK). - Stream bitplanes through the plane-splitter on both the uncompressed and compressed dispatch paths. - Extend the "both planes present before refresh" END guard to bitplanes so a short payload errors instead of refreshing stale RAM. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On 3-colour panels (BWR / BWY colour schemes), the BLE direct-write path only ever wrote the black/white plane. The red/yellow accent plane was never sent to the controller, so every 3-colour refresh committed a new image on the BW layer while showing whatever stale content was left in the accent RAM.
Root cause
handleDirectWriteStartsized a BWR/BWY upload at a single flat plane ((pixels + 7) / 8) and the streamer never issuedbbepStartWrite(&bbep, PLANE_1), so the second (accent) plane was dropped. The auto-END fired as soon as one plane's worth of bytes had arrived. This is a regression from the "Big Refactor" (fd0d73a), which dropped the plane-switch logic that existed in5dcb60b.All senders (py-opendisplay, website JS) already transmit two concatenated, row-padded 1-bit planes:
plane0= black/white (palette index 1) thenplane1= accent (index 2). That is byte-for-byte the same layout the GRAY4 path already streams.Fix
Route BWR/BWY through the existing two-plane streamer (
streamGray4Bytes), which drives the PLANE_0 → PLANE_1 switch off the runningdirectWriteBytesWritten:2 * ((width+7)/8) * height), matching the gray4 formula. This also makes the compressed decompressed-size check equal the client's 2-planeuncompressed_size, fixing the compressed-BWR START NACK for free.{0xFF, 0x72}) instead of refreshing stale RAM.streamGray4Bytesdoc comment to reflect that it now also serves BWR/BWY (identical byte layout).The change is surgical (13 insertions, 11 deletions in one file); no other colour scheme or the partial-update path is touched. The initial
bbepStartWrite(PLANE_0)for bitplanes is harmless —streamGray4Bytesre-issuesbbepStartWrite(PLANE_0)at offset 0, exactly as the tolerated gray4 double-start already does.Testing
Compiled clean with PlatformIO (no source changes needed beyond this file):
pio run -e nrf52840custom→ SUCCESSpio run -e esp32-s3-N16R8→ SUCCESSNot yet smoke-tested on hardware. This still needs a hardware smoke test on a real BWR/BWY panel (uncompressed and compressed direct-write) to confirm the accent plane now renders — I can't run that here.
Related
Web-tool counterpart: OpenDisplay/opendisplay.org#26
🤖 Generated with Claude Code
https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR