I try to use two buffer mode to display a picture , but when enter disp_flush function and print the color_p buffer data ,the data is not match the image buffer data, I can’t find the reason,can you give some suggestions to check?
Code
The code block(s) should be between ```c
and ```
tags:
/*You code here*/
void App_ui_init(void)
{
App_setup_ui(ui);
setup_scr_screen_switching();
}
static void App_setup_ui(lv_obj_t* gui)
{
gui = lv_obj_create(NULL);
//Write style state: LV_STATE_DEFAULT for style_screen_altitude_main_main_default
static lv_style_t style_screen_altitude_main_main_default;
if (style_screen_altitude_main_main_default.prop_cnt > 1)
lv_style_reset(&style_screen_altitude_main_main_default);
else
lv_style_init(&style_screen_altitude_main_main_default);
lv_style_set_bg_color(&style_screen_altitude_main_main_default, lv_color_make(0xFF, 0xFF, 0xFF));
lv_style_set_bg_opa(&style_screen_altitude_main_main_default, 0);
lv_obj_add_style(gui, &style_screen_altitude_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);
}
void setup_scr_screen_switching(void)
{
//
lv_obj_t * bg_top;
bg_top = lv_img_create(ui);
lv_obj_set_pos(bg_top, 0, 0);
lv_obj_set_size(bg_top, 96, 32);
lv_img_set_src(bg_top, &bingdundun );
}
Below is the display init function
void lv_port_disp_init(void)
{
/*-------------------------
* Initialize your display
* -----------------------*/
disp_init();
/*-----------------------------
* Create a buffer for drawing
*----------------------------*/
/**
* LVGL requires a buffer where it internally draws the widgets.
* Later this buffer will passed to your display driver's `flush_cb` to copy its content to your display.
* The buffer has to be greater than 1 display row
*
* There are 3 buffering configurations:
* 1. Create ONE buffer:
* LVGL will draw the display's content here and writes it to your display
*
* 2. Create TWO buffer:
* LVGL will draw the display's content to a buffer and writes it your display.
* You should use DMA to write the buffer's content to the display.
* It will enable LVGL to draw the next part of the screen to the other buffer while
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
*
* 3. Double buffering
* Set 2 screens sized buffers and set disp_drv.full_refresh = 1.
* This way LVGL will always provide the whole rendered screen in `flush_cb`
* and you only need to change the frame buffer's address.
*/
// /* Example for 1) */
// static lv_disp_draw_buf_t draw_buf_dsc_1;
// static lv_color_t buf_1[MY_DISP_HOR_RES*10]; /*A buffer for 10 rows*/
// lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
/* Example for 2) */
// static lv_disp_draw_buf_t draw_buf_dsc_2;
// static lv_color_t buf_2_1[MY_DISP_HOR_RES *10]; /*A buffer for 10 rows*/
// static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10]; /*An other buffer for 10 rows*/
// lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
//
/* Example for 3) also set disp_drv.full_refresh = 1 below*/
static lv_disp_draw_buf_t draw_buf_dsc_3;
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES] __MEMORY_AT(0x20000000) ; /*A screen sized buffer*/
static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES] __MEMORY_AT(0x200BB800); /*Another screen sized buffer*/
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2,
MY_DISP_VER_RES * MY_DISP_HOR_RES); /*Initialize the display buffer*/
// static lv_disp_draw_buf_t draw_buf_dsc_3;
// static lv_color_t *buf_3_1 = (lv_color_t * )(s_frameBuff[1]); /*A screen sized buffer*/
// static lv_color_t *buf_3_2 = (lv_color_t * )(s_frameBuff[1] + MY_DISP_HOR_RES * MY_DISP_VER_RES*sizeof(lv_color_t));
// lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_HOR_RES * MY_DISP_VER_RES); /*Initialize the display buffer*/
/*-----------------------------------
* Register the display in LVGL
*----------------------------------*/
/*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
/*Set up the functions to access to your display*/
/*Set the resolution of the display*/
disp_drv.hor_res = MY_DISP_HOR_RES;
disp_drv.ver_res = MY_DISP_VER_RES;
/*Used to copy the buffer's content to the display*/
disp_drv.flush_cb = disp_flush;
disp_drv.wait_cb = DEMO_WaitFlush;
/*Set a display buffer*/
disp_drv.draw_buf = &draw_buf_dsc_3;
/*Required for Example 3)*/
disp_drv.full_refresh = 1;
disp_drv.direct_mode =1;
/* Fill a memory array with a color if you have GPU.
* Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
* But if you have a different GPU you can use with this callback.*/
//disp_drv.gpu_fill_cb = gpu_fill;
/*Finally register the driver*/
lv_disp_drv_register(&disp_drv);
lv_disp_set_bg_color(lv_disp_get_default(),lv_color_make(0x00,0x00,0x00));
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.