Context:
I am working on an LVGL-based project and facing an issue when using the disp_flush
function to render the display. I have implemented two variations of the function, but they produce different results. I have attached two images to demonstrate the issue.
1. Issue with Two Variations of disp_flush
:
- Image 1 (Correct Output): This image shows the expected output when I use hardcoded colors (red, green, blue) in the
disp_flush
function. The display correctly shows three vertical color bands. - Image 2 (Distorted Output): This image shows the result when I use the pixel data from the
px_map
buffer. The display shows distorted horizontal lines and unexpected colors.
What could be causing the difference between the hardcoded colors and the buffer data when rendering?
2. Buffer Configuration:
- The buffers are defined as:
static uint8_t buf_2_1[MY_DISP_HOR_RES * 40 * BYTE_PER_PIXEL];
static uint8_t buf_2_2[MY_DISP_HOR_RES * 40 * BYTE_PER_PIXEL];
And configured in lv_port_disp_init()
as:
lv_display_set_buffers(disp, buf_2_1, buf_2_2, sizeof(buf_2_1), LV_DISPLAY_RENDER_MODE_PARTIAL);
- Is there a mistake in how I define or set up the buffers for RGB565 format?
- Could the use of
uint8_t
instead oflv_color_t
in buffer definition cause this issue?
3. Pixel Mapping in disp_flush
:
- The flush function casts the buffer as follows:
uint16_t * buf16 = (uint16_t *)px_map;
uint16_t color = *buf16++;
LCD_Write_DATA_VL(color);
- Could the issue be related to how
px_map
is interpreted or aligned asuint16_t
? - Is there a potential problem with the byte order (endianness) when interpreting the color data?
4. Additional Considerations:
- Could the way I initialize the LVGL object and set the background color in the main function be affecting the buffer data?
- Is there any recommended method to verify the content of
px_map
during the flush operation to ensure the data is correct?
Your insights on why the display behaves differently between hardcoded colors and buffer data would be greatly appreciated!