-
Notifications
You must be signed in to change notification settings - Fork 65
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 function ST7789_Fill_Color not fill correct color #26
Comments
I can confirm that this is a working fix. Had the same issue. To clarify, this fix is only needed if u use DMA. |
I could not get MemsetBuffer to compile using STMCubeIDE so I changed it to:
} |
My non-dma fill function with close to DMA speed.
And fast draw filled rectangle
|
Hello,
function ST7789_Fill_Color is not correct because memset is not working with uint16_t data, and the uint16_t buffer should be swap 2 byte high and low . So, we have to modify this function to working correct:
`void MemsetBuffer(uint16_t buf, uint16_t data, uint32_t size)
{
while(size--)
{
buf++ = data;
}
}
/
*/
void ST7789_Fill_Color(uint16_t color)
{
uint16_t i;
uint16_t convert_color;
ST7789_SetAddressWindow(0, 0, ST7789_WIDTH - 1, ST7789_HEIGHT - 1);
ST7789_Select();
convert_color = ((color & 0xFF) << 8) | ((color & 0xFF00) >> 8);
#ifdef LCD_USE_DMA
for (i = 0; i < ST7789_HEIGHT / HOR_LEN; i++)
{
MemsetBuffer(disp_buf, convert_color, ST7789_WIDTH * HOR_LEN);
ST7789_WriteData((uint8_t *)disp_buf, sizeof(disp_buf));
}
#else
uint16_t j;
for (i = 0; i < ST7789_WIDTH; i++)
for (j = 0; j < ST7789_HEIGHT; j++) {
uint8_t data[] = {color >> 8, color & 0xFF};
ST7789_WriteData(data, sizeof(data));
}
#endif
ST7789_UnSelect();
}`
The text was updated successfully, but these errors were encountered: