Some objects display not right,how this happen?

Description

When I tested some objects, I found that some of the objects could not be displayed normally, and a lot of stripes appeared on the screen. I am not sure what the reason is, because some controls are not problematic.

What MCU/Processor/Board and compiler are you using?

STM32F746

What do you experience?

For example, when I tested lv_calendar, there was no problem at all. All the displays were normal and the touch could be controlled normally, but when I tested lv_sw, many stripes appeared on the right half of the screen.

What do you expect?

No stripes appear on the screen, and all objects can be displayed normally.

Code to reproduce

Add a code snippet to reproduce the issue in the simulator. It should contain only the relevant code which can be compiled. Bug reports without code snippets or with erroneous code snippets will not be reviewed.

lv_calendar

static void calender_event_handler(lv_obj_t * obj, lv_event_t event)
{
    if(event == LV_EVENT_CLICKED) {
        lv_calendar_date_t * date = lv_calendar_get_pressed_date(obj);
        if(date) {
            lv_calendar_set_today_date(obj, date);
        }
    }
}

static void calendar_test(void)
{
    lv_obj_t  * calendar = lv_calendar_create(lv_scr_act(), NULL);
    lv_obj_set_size(calendar, 460, 460);
    lv_obj_align(calendar, NULL, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_event_cb(calendar, calender_event_handler);

    /*Set the today*/
    lv_calendar_date_t today;
    today.year = 2020;
    today.month = 3;
    today.day = 18;

    lv_calendar_set_today_date(calendar, &today);
    lv_calendar_set_showed_date(calendar, &today);

    /*Highlight some days*/
    static lv_calendar_date_t highlihted_days[1];       /*Only it's pointer will be saved so should be static*/
    highlihted_days[0].year = 2020;
    highlihted_days[0].month = 3;
    highlihted_days[0].day = 28;

    lv_calendar_set_highlighted_dates(calendar, highlihted_days, 1);
}

lv_sw

static void sw_event_handler(lv_obj_t * obj, lv_event_t event)
{
    if(event == LV_EVENT_VALUE_CHANGED) {
        printf("State: %s\n", lv_sw_get_state(obj) ? "On" : "Off");
    }
}

static void sw_test(void)
{
    /*Create styles for the switch*/
    static lv_style_t bg_style;
    static lv_style_t indic_style;
    static lv_style_t knob_on_style;
    static lv_style_t knob_off_style;

    lv_style_copy(&bg_style, &lv_style_pretty);
    bg_style.body.radius = LV_RADIUS_CIRCLE;
    bg_style.body.padding.top = 6;
    bg_style.body.padding.bottom = 6;

    lv_style_copy(&indic_style, &lv_style_pretty_color);
    indic_style.body.radius = LV_RADIUS_CIRCLE;
    indic_style.body.main_color = LV_COLOR_BLUE;
    indic_style.body.grad_color = LV_COLOR_NAVY;
    indic_style.body.padding.left = 0;
    indic_style.body.padding.right = 0;
    indic_style.body.padding.top = 0;
    indic_style.body.padding.bottom = 0;

    lv_style_copy(&knob_off_style, &lv_style_pretty);
    knob_off_style.body.radius = LV_RADIUS_CIRCLE;
    knob_off_style.body.shadow.width = 4;
    knob_off_style.body.shadow.type = LV_SHADOW_BOTTOM;

    lv_style_copy(&knob_on_style, &lv_style_pretty_color);
    knob_on_style.body.radius = LV_RADIUS_CIRCLE;
    knob_on_style.body.shadow.width = 4;
    knob_on_style.body.shadow.type = LV_SHADOW_BOTTOM;

    /*Create a switch and apply the styles*/
    lv_obj_t *sw1 = lv_sw_create(lv_scr_act(), NULL);
    lv_sw_set_style(sw1, LV_SW_STYLE_BG, &bg_style);
    lv_sw_set_style(sw1, LV_SW_STYLE_INDIC, &indic_style);
    lv_sw_set_style(sw1, LV_SW_STYLE_KNOB_ON, &knob_on_style);
    lv_sw_set_style(sw1, LV_SW_STYLE_KNOB_OFF, &knob_off_style);
    lv_obj_align(sw1, NULL, LV_ALIGN_CENTER, -400, -50);
    lv_obj_set_event_cb(sw1, sw_event_handler);

    /*Copy the first switch and turn it ON*/
    lv_obj_t *sw2 = lv_sw_create(lv_scr_act(), sw1);
    lv_sw_on(sw2, LV_ANIM_ON);
    lv_obj_align(sw2, NULL, LV_ALIGN_CENTER, -400, 50);
}

The code is based on the routine, there should be no problem, I think there should be no problem with the display driver, because not all objects are displayed abnormally.

This project can be found at my Github

Screenshot and/or video

lv_sw

Can you show us the code for your flush_cb function?

Hi,
here is the code:

static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
//    /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/

//    int32_t x;
//    int32_t y;
//    for(y = area->y1; y <= area->y2; y++) {
//        for(x = area->x1; x <= area->x2; x++) {
//            /* Put a pixel to the display. For example: */
//            /* put_px(x, y, *color_p)*/
//						BSP_LCD_PutPixel(x, y, color_p->full);
//            color_p++;
//        }
//    }
//		
//    /* IMPORTANT!!!
//     * Inform the graphics library that you are ready with the flushing*/
//    lv_disp_flush_ready(disp_drv);
	
		int32_t x1 = area->x1;
		int32_t x2 = area->x2;
		int32_t y1 = area->y1;
		int32_t y2 = area->y2;
			/*Return if the area is out the screen*/

		if(x2 < 0) return;
		if(y2 < 0) return;
		if(x1 > 1024 - 1) return;
		if(y1 > 600 - 1) return;

		/*Truncate the area to the screen*/
		int32_t act_x1 = x1 < 0 ? 0 : x1;
		int32_t act_y1 = y1 < 0 ? 0 : y1;
		int32_t act_x2 = x2 > 1024 - 1 ? 1024 - 1 : x2;
		int32_t act_y2 = y2 > 600 - 1 ? 600 - 1 : y2;

		x1_flush = act_x1;
//		y1_flush = act_y1;
		x2_flush = act_x2;
		y2_fill = act_y2;
		y_fill_act = act_y1;
		buf_to_flush = color_p;

		/*##-7- Start the DMA transfer using the interrupt mode #*/
		/* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
		/* Enable All the DMA interrupts */
		HAL_StatusTypeDef err;
		uint32_t length = (x2_flush - x1_flush + 1);
#if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
		length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */
#endif
		err = HAL_DMA_Start_IT(&hdma_memtomem_dma2_stream0,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * 1024 + x1_flush],
						 length);
		if(err != HAL_OK)
		{
				while(1);	/*Halt on error*/
		}
}

and the DMAtransfer cpmplete funciton code:

static void DMA_TransferComplete(DMA_HandleTypeDef *han)
{
    y_fill_act ++;

    if(y_fill_act > y2_fill) {
			
        lv_disp_flush_ready(&our_disp->driver);
			
    } else {
    	uint32_t length = (x2_flush - x1_flush + 1);
        buf_to_flush += x2_flush - x1_flush + 1;
        /*##-7- Start the DMA transfer using the interrupt mode ####################*/
        /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
        /* Enable All the DMA interrupts */
#if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
        length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */
#endif
        if(HAL_DMA_Start_IT(han,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * 1024 + x1_flush],
                            length) != HAL_OK)
        {
            while(1);	/*Halt on error*/
        }
    }
}

Any suggestion?

HAve you enabled caching? (SCB_EnableICache() and SCB_EnabeDCache())

Hi @kisvegabor,
Thanks for reply me.
I had enable caching in main.c file:

  /* Enable I-Cache---------------------------------------------------------*/
  SCB_EnableICache();

  /* Enable D-Cache---------------------------------------------------------*/
  SCB_EnableDCache();

Most objects display right,just fews display not well,but the problem is same.There is a horizontal line near the right side or the upper right side.

Than you should call SCB_CleanInvalidateDCache(); at the beginning of your flush function.

Hi @kisvegabor
You are right, I need to call this function first. Recently, I suffered a leg injury and failed to test it in time. I just tested it. Now it shows no problem. Thank you for helping me.

Glad to hear it works!

I hope your leg will get better soon! :slight_smile:

Hi @kisvegabor,
Thank you for your concern, I am much better.But I got new problem.


Just like the picture above, when I touch the display to change the content on the screen, a lot of vertical lines appear on the screen. What caused this? Is it related to my display driver?

PS: I have encountered a lot of problems recently. In fact, I wrote the Chinese tutorial of littleVGL in Waveshare Study. It is officially because of your excellent work that many enthusiasts can use such an excellent GUI framework. Thank you very much for your efforts and efforts.:blush:

STM32 littlevGL Chinese tutorial

Raspberry Pi littlevGL Chinese tutorial

Glad to hear that!

Yes, it should be related to the driver. But it’s strange because LVGL refreshes in lines. If the whole screen moves full lines are refreshed. So I have no idea why there are vertical artifacts.

Thank you for the compliment but it’s not only my work! :slight_smile:

Also thank you for sharing the tutorials. Wow, there are a lot. Congratulation!

Would you be interested in translating LVGL’s documentation to Chinese?

OK, I will check it, I think it may be related to the synchronization mode of the display.

Can I?I will check the process,and hope I can contribute my strength.

Can I?I will check the process,and hope I can contribute my strength.

Right now there are some issues with the crowd-translating site, but I’m working on it.