Setting rotated option in lv_disp_drv_t causes hard fault

Description

stm32f746_discovery_no_os demo program hard faults when i try to rotate the display.

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

STM32 F746 discovery board + SW4STM32 IDE

What do you want to achieve?

I want to rotate the display clock wise by 90 Deg.

What have you tried so far?

I tested this feature in the simulator and it works fine. I changed the following things in the simulator.
in win_drv.c
disp_drv.rotated = 1;

in lv_drv_conf.h

define WINDOW_HOR_RES 272

define WINDOW_VER_RES 480

in lv_conf.h
#define LV_HOR_RES_MAX (272)
#define LV_VER_RES_MAX (480)

When i make similar changes in the STM32 program, i get a hard fault.

What could be the issue?

Thanks

2 Likes

LV_HOR_RES_MAX is used as size of a line buffer. After rotation the line length is 480, so either use landscape as default orientation or use 480 for both HOR and RES

The rotated option requires additional logic in the driver which I haven’t implemented yet, so it’s not going to work at the moment. Sorry about that.

@beppone: @polmon already mentioned that he has changed the appropriate defines to the correct values.

Can i rotate the buf_to_flush array while copying to my_fb?

You can, just read buf_to_flush column-by-column instead of it’s row-by-row.

I have tried the following code to read col by col. But i cant seem to find the issue.

I made the screen into a 272 x 272 square.

for (x_fill_act = x1_flush ; x_fill_act <= x2_flush; x_fill_act++)
{
for(y_fill_act = act_y1; y_fill_act <= y2_fill; y_fill_act ++)
{
memcpy((uint32_t)&my_fb[(271 - x_fill_act) * 272 + y_fill_act], (uint32_t)(buf_to_flush + (272*y_fill_act + x_fill_act)),2);
}
}

I managed to get it ALMOST working with the following code.

  for (x_fill_act = x2_flush ; x_fill_act >= x1_flush; x_fill_act--)
{
	  for(y_fill_act = act_y1; y_fill_act <= y2_fill; y_fill_act ++)
	{
       memcpy((uint32_t)&my_fb[(271 - x_fill_act) * (272) + y_fill_act], (uint32_t)(buf_to_flush + x_fill_act + (y_fill_act - act_y1)*(x2_flush - x1_flush + 1)),2);
	}
}

However there is still some issue with the copying algorithm. I get the following issue in the attached picture.

Later today I’ll create an an example rotate function.

1 Like

Here is the code which worked me in the simulator:


void get_col(const lv_color_t * src, const lv_area_t * area, lv_coord_t y, lv_color_t * dest)
{
    lv_coord_t w = lv_area_get_width(area);
    lv_coord_t h = lv_area_get_height(area);

    lv_coord_t i;
    for(i = 0; i < h; i++) {
        dest[i].full = src[y].full;
        src += w ;
    }
}

void monitor_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) 
{
    lv_coord_t x2 = area->x2;
    if(x2 >= disp_drv->ver_res) x2 = MONITOR_VER_RES - 1;

    lv_color_t * dest = (lv_color_t *)monitor.tft_fb;
    dest +=  MONITOR_HOR_RES * (MONITOR_VER_RES - 1);
    dest -= MONITOR_HOR_RES * area->x1;

    lv_coord_t x;
    for(x = area->x1; x <= x2; x++) {
          get_col(color_p, area, (x - area->x1), dest + area->y1);
          dest -= MONITOR_HOR_RES;
    }
}

image

1 Like

Works like a charm! Thank you!

Great! :slight_smile:
It was already asked a lot times. Good to know that there is a working reference code now.

polmon can you post your results?