Skip to content

Commit

Permalink
Fix broken colors and partial flush for ILI9488 display
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilukichoff committed Jul 4, 2024
1 parent 84cc870 commit adac5aa
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,17 @@ void DisplayDriver::BitBlt(

g_DisplayInterface.SendCommand(1, Memory_Write);

uint32_t numPixels = width * height;
uint32_t count = 0;

CLR_UINT8 *TransferBuffer = Attributes.TransferBuffer;
CLR_UINT32 TransferBufferSize = Attributes.TransferBufferSize;

// only 18/24 bit is supported on SPI
for (uint32_t i = 0; i < numPixels; i++)
for (uint32_t y = srcY; y < srcY + height; y++)
for (uint32_t x = srcX; x < srcX + width; x++)
{
uint32_t i = y * Attributes.Width + x;

uint32_t element = data[i / 2]; // Each uint32 stores 2 pixels
uint16_t color = (i % 2 == 0) ? (element & 0xFFFF) : (element >> 16);

Expand All @@ -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;
TransferBuffer[count++] = g;
TransferBuffer[count++] = b;

// can't fit another 3 bytes
if (count + 3 > TransferBufferSize - 1)
Expand Down

0 comments on commit adac5aa

Please sign in to comment.