What do you want to achieve?
I want to do image rendering on monochrome display(LV_COLOR_FORMAT_I1) on mimxrt1064-evk with lvgl v9.2.1.
What have you tried so far?
I am geting text rendering properly on console. But image rendering is not coming properly.
I tried to generate c-array file using lvgl image converter for v9. So, I converted using image2cpp . The data obtained is pasted in the file.
After debugging, I get blank screen after image rendering. In the flush function definition, uint8_t* color_p gives same data everytime. So, the console is blank. When i print the c-array directly on console, the data is coming properly.
Code to reproduce
#include “lvgl.h”
#include “fsl_elcdif.h”
#include “board.h”
#include “fsl_cache.h”
#include “defines.h”
#include<stdio.h>
// Display dimensions
#define WIDTH 128
#define HEIGHT 16
// Buffer size for monochrome: width×height bits → /8 bytes
#define BUF_SIZE_MONO ((WIDTH * HEIGHT) / 8 + 8)
// Buffer size for color: width×height×3
#define BUF_SIZE_COLOR (WIDTHHEIGHT3)
// Two buffers for double-buffering (optional for monochrome)
#if DISPLAY_TYPE == DISPLAY_TYPE_MONOCHROME
attribute((section(“.NCACHE_REGION”))) static uint8_t buf1[BUF_SIZE_MONO];
attribute((section(“.NCACHE_REGION”))) static uint8_t buf2[BUF_SIZE_MONO];
#else
attribute((section(“.NCACHE_REGION”))) static uint8_t buf1[BUF_SIZE_COLOR];
attribute((section(“.NCACHE_REGION”))) static uint8_t buf2[BUF_SIZE_COLOR];
#endif
static void flushDisplay(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p)
{
int32_t x, y;
uint32_t width = area->x2 - area->x1 + 1;
uint32_t height = area->y2 - area->y1 + 1;
// printf(“\n=== LVGL Flush Debug ===\n”);
// printf(“Area: x1=%d y1=%d x2=%d y2=%d\n”, area->x1, area->y1, area->x2, area->y2);
// printf(“color_p start = %p\n”, color_p);
//// printf(“one_map start = %p\n”, one_map);
//
// Print first 32 bytes of each
printf(“\nLVGL buffer (color_p):\n”);
for (int i = 0; i < 32; i++) printf(“%02X “, color_p[i]);
printf(”\n\nRaw one_map:\n”);
for (int i = 0; i < 32; i++) printf(“%02X “, one_map[i]);
printf(”\n”);
// Optional header skip detection (LVGL metadata)
bool header_detected = false;
for (int i = 0; i < 8; i++) {
if (color_p[i] != 0x00 && color_p[i] != 0xFF) {
header_detected = true;
break;
}
}
if (header_detected) {
printf("\nHeader-like bytes detected, skipping 8 bytes...\n");
color_p += 8;
}
printf("\nLVGL Monochrome Bitmap (as rendered):\n");
for (int y = area->y1; y <= area->y2; y++) {
for (int x = area->x1; x <= area->x2; x++) {
int px_index = (y - area->y1) * (area->x2 - area->x1 + 1) + (x - area->x1);
int byte_index = px_index / 8;
int bit_index = 7 - (px_index % 8);
uint8_t bit_val = (color_p[byte_index] >> bit_index) & 0x01;
printf("%c", bit_val ? '#' : '.');
}
printf("\n");
}
printf("\nRaw one_map Bitmap:\n");
for (int y = 0; y < one.header.h; y++) {
for (int x = 0; x < one.header.w; x++) {
int byte_index = (y * one.header.w + x) / 8;
int bit_index = 7 - (x % 8);
uint8_t bit = (one_map[byte_index] >> bit_index) & 0x01;
printf("%c", bit ? '#' : '.');
}
printf("\n");
}
printf("=== End Flush ===\n\n");
// Mark flush complete
lv_display_flush_ready(disp_drv);
}
void lv_port_disp_init(void)
{
lv_display_t * disp = lv_display_create(WIDTH, HEIGHT);
#if(DISPLAY_TYPE == DISPLAY_TYPE_MONOCHROME)
// Set color format for monochrome
lv_display_set_color_format(disp, LV_COLOR_FORMAT_I1);
lv_display_set_buffers(disp,
buf1,
buf2,
BUF_SIZE_MONO,
LV_DISPLAY_RENDER_MODE_PARTIAL);
#else
lv_display_set_color_format(disp, LV_COLOR_FORMAT_RGB888);
lv_display_set_buffers(disp,
buf1,
buf2,
BUF_SIZE_COLOR,
LV_DISPLAY_RENDER_MODE_DIRECT);
#endif
lv_display_set_flush_cb(disp, flushDisplay);
// … init hardware, LCD controller, interrupts …
}
/
In main.c,
void main()
{
/* Init board hardware. */
BOARD_InitHardware();
DEMO_SetupTick();
lv_init();
lv_port_disp_init();
lv_obj_t *img = lv_image_create(lv_scr_act());
printf(“img = %p\n”, img);
printf(“spec_attr before set_src = %p\n”, lv_image_get_src(img));
lv_image_set_src(img, &one);
while(1)
{
lv_tick_inc(1);
lv_timer_handler();
}
}
/*You code here*/
Screenshot and/or video
Environment
- MCU/MPU/Board:
- LVGL version: See
lv_version.h