Is it possible to set the screen resolution at runtime?
The issue we have is that we build LittlevGL as a common library which our projects link to and dynamically create the objects that need. However we now need to target a different size resolution and from what I can tell his is only defined in the lv_conf.h which is part of the pre-build library. Unless anyone can suggest another way of doing this?
/*Set the resolution of the display*/
disp_drv.hor_res = 160;
disp_drv.ver_res = 128;
EDIT:
So I re-read the link above, and it specifically mentioned it uses lv_conf.h for the resolution by default. But if you don’t use the defines then you can pass it as an argument?
I am just trying this in the V6 Visual Studio Simulation but not sure where to put it. I assume is should go in the hal_init function where the disp_drv is initialised. But if I put it just after the lv_disp_buf_init() then it crashes. If I put it after the lv_disp_drv_register() it does not crash, but the resolution does not change.
Yes this is what I have but mines using the Windows, Visual Studio version. It actually crashes in the Monitor.c file, so I think this is an issue specifically with the Windows version.
I get the exception below within the flush function.
Exception thrown at 0x00007FFFFD44127E (vcruntime140d.dll) in visual_studio_2017_sdl_x64.exe: 0xC0000005: Access violation writing location 0x00007FF6811E7000.
This appears to be a conflict between the default resolution as set in the lv_conf file and the value you set using the disp_drv.hor_res & disp_drv.ver_res calls. It also appears that the Windows form that gets created is created using the default values.
Therefore the current work around is to set the default value to something bigger than you will be using (800x640 for example) and then the dynamically set it to something you want… as long as its no greater than this.
It just means its a bit nasty to look as as you get black padding to the right and left.
I have tested mine on the actual device though. It’s a nanopi neo2 with a 128x160 LCD attached to spi.
I am not able to get the demos run on this since I don’t have a need for all the features it uses.
@TheGrovesy While LittlevGL itself supports dynamically changing the resolution, I’m not sure that the SDL driver was updated to accommodate that yet. I think that is why you are having issues.