Resize the simulator screen in codeblock

Description

I am trying to rescale the size of simulator screen in Code blocks from 480x320 px to 320x240 px

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

I am using latest Code block windows simulator

What do you want to achieve?

I have already fully designed a project using 480x320 px screen size on the Codeblocks simulator. However, my client wanted it to be in 320x240 px screen size.

What have you tried so far?

I’ve tried to change the LV_HOR_RES and LV_VER_RES in lv_conf.h but to no luck. I’ve also tried to change the resolution in lv_drv_conf.h but still displayed the default size. I’ve cleaned the workspace and rebuild the project, but it still shows 480x320 screen size.

Code to reproduce

void lv_demo_try(void)
{

static lv_style_t style;
lv_style_init(&style);

/*Set a background color and a radius*/
lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_OFFICIAL_COLOR);
lv_style_set_border_width(&style, LV_STATE_DEFAULT, 0);

lv_obj_t * win = lv_win_create(lv_scr_act(), NULL);
lv_obj_set_size(win, 480, 500);
lv_obj_align(win, NULL, LV_ALIGN_CENTER, 0,-50);
lv_obj_add_style(win, LV_STATE_DEFAULT, &style);

lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
lv_img_set_src(img, &official_logo);
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);

lv_obj_t * label;

lv_obj_t * obj1 = lv_obj_create(lv_disp_get_scr_act(NULL), NULL);
lv_obj_align(obj1, NULL, LV_ALIGN_IN_BOTTOM_MID, 10 ,0);
lv_obj_add_style(obj1, LV_STATE_DEFAULT, &style);


label = lv_label_create(obj1, NULL);
lv_label_set_recolor(label, true);
lv_label_set_text(label, "#ffffff CLICK HERE#");
lv_obj_set_event_cb(obj1, login_page);

}

Screenshot and/or video

In the lv_drv_conf.h line 118.

1 Like

in visual studio, i just change
/* Maximal horizontal and vertical resolution to support by the library.*/
#define LV_HOR_RES_MAX (440)
#define LV_VER_RES_MAX (440)

in lv_conf.h and rebuild.

may need clean before build?

1 Like

The codeblocks project that I am using has a hard coded value for Windows while most of the other display drivers use the 2 defines you posted. I think I saw 1 other display driver that uses hard coded values. Don’t know if that is left over from an old version or there is some reason for it. I think there was some problem with the windows simulator because embeddet had said he used a different graphics lib.

Please confirm that the following lines have been changed to your desired resolution:

After that, a clean and rebuild should pick up on the new settings.

I designed the Windows driver to use Windows APIs directly to avoid needing another dependency like SDL. The two defines approach is cloned from the standard SDL driver. In practice, I could have set it up to use LV_HOR_RES_MAX and LV_VER_RES_MAX, but for consistency I wanted to keep it the same as other drivers.