-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken colors and partial flush for ILI9488 display #2976
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes involve modifying the Changes
Sequence Diagram(s)sequenceDiagram
participant ClientApp
participant DisplayDriver
participant TransferBuffer
ClientApp->>DisplayDriver: Call BitBlt(srcX, srcY, width, height)
loop For each y from srcY to srcY + height
loop For each x from srcX to srcX + width
DisplayDriver->>DisplayDriver: Calculate index i
DisplayDriver->>TransferBuffer: Store r, g, b values in order
end
end
Note over TransferBuffer: Buffer filled with pixel data
DisplayDriver-->>ClientApp: BitBlt operation complete
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@dotnet-policy-service agree |
Automated fixes for code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp (1)
298-299
: Correctness: Ensure proper nesting of loops.The nested loops should be properly indented for better readability and to avoid confusion.
- for (uint32_t y = srcY; y < srcY + height; y++) - for (uint32_t x = srcX; x < srcX + width; x++) + for (uint32_t y = srcY; y < srcY + height; y++) { + for (uint32_t x = srcX; x < srcX + width; x++) {
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp (2 hunks)
Additional comments not posted (2)
src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp (2)
315-317
: LGTM! Ensure correct order of storing color values.The order of storing
r
,g
, andb
values inTransferBuffer
looks good. Ensure that this order is consistent with the expected format.
301-301
: Correctness: Ensurei
calculation is accurate.The index
i
is calculated based onx
andy
coordinates. Ensure thatAttributes.Width
is correctly defined and used.Verification successful
Verification Successful: The calculation of
i
is accurate.The index
i
is correctly calculated based on thex
andy
coordinates, withAttributes.Width
being properly defined and assigned based on the display orientation.
ILI9488_480x320_SPI.cpp
:
- Lines 173, 179, 185, 191:
Attributes.Width
is assigned based on the display orientation.- Line 301:
i
calculation usesAttributes.Width
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `Attributes.Width` is correctly defined and used. # Test: Search for the definition and usage of `Attributes.Width`. Expect: Proper definition and usage. rg --type cpp $'Attributes.Width'Length of output: 9375
Script:
#!/bin/bash # Extract lines from ILI9488_480x320_SPI.cpp where Attributes.Width is defined or assigned values rg --type cpp --line-number 'Attributes.Width' src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cppLength of output: 720
Script:
#!/bin/bash # Extract lines around the assignments of Attributes.Width in ILI9488_480x320_SPI.cpp to understand the context rg --type cpp --context 5 --line-number 'Attributes.Width' src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cppLength of output: 3361
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! Looks good all up, you should have a code style PR to merge.
src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp
Outdated
Show resolved
Hide resolved
@@ -309,9 +311,9 @@ void DisplayDriver::BitBlt( | |||
g = (g << 2) | (g >> 4); | |||
r = (r << 3) | (r >> 2); | |||
|
|||
TransferBuffer[count++] = b; | |||
TransferBuffer[count++] = g; | |||
TransferBuffer[count++] = r; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about the order? I remember the color order is configurable and depends on the driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver only supports SPI and Ili9488 only supports 3-byte color in RGB order in SPI mode. I suppose thats why the order was hardcoded initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this flag alters the output signal for panels with different order, while the buffer always uses RGB. If this is the case, we should substitute the hardcoded MADCTL_BGR constant in DisplayDriver::ChangeOrientation with a variable that may be either MADCTL_BGR or 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test it out without flipping the RGB values in code?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it and it works exactly as I expected. It displays incorrect colors with RGB buffer and 0 value instead of MADCTL_BGR, and correct colors with MADCTL_BGR value. And vice versa with BGR buffer.
So my panel utilizes BGR pixels obviously.
I suppose the buffer should always remain RGB since there is no other option mentioned in the datasheet. See page 122.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different manufacturer uses different panel with same controller. As far as I know there are two types RGB and BGR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and controller uses RGB for buffer and flag to alter signal for different panels. I don't see why buffer should not be RGB in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be you want to check with this change and if that is inline with this driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/nanoFramework.Graphics/Graphics/Displays/ILI9488_480x320_SPI.cpp
Any further developments on this? |
288fd6f
to
c6dee33
Compare
f1c86c5
to
449142a
Compare
Description
Fixed bugs in native Ili9488 display driver:
How Has This Been Tested?
Screenshots
Left: corrupted colors, Right: fixed
Left: corrupted partial flush, Right: fixed
Types of changes
Checklist
BitBlt test app:
Summary by CodeRabbit
x
andy
coordinates directly, rather than using a single index.TransferBuffer
for better efficiency.