Hi guys,
I have a strange issue that I cannot figure out. I have a function that is rotating and moving/translating some objects, the goal being achieving a landscape design (from portrait) when the user choses to do so.
There are around 17 objects in total that are rotating and moving (translating on x & y axes)
At some point, I get the StoreProhibited error and the ESP is rebooting.
I have commented and uncommented various parts of these objects, starting with only modifying one, then 2, then 3, etc.
At first it worked good until like 8 objects, then failed on 9th. After some more tries, it started failing after rotating/translating only 3-4, so it seems kinda random. Might be a memory issue? I have a 16MB ESP32-S3 however… and using the Huge App partition 4MB currently.
Here is how I rotate & translate an object:
lv_obj_set_style_transform_angle(ui_myLabel1, 900, 0);
lv_obj_set_style_translate_x(ui_myLabel1, 200, 0);
lv_obj_set_style_translate_y(ui_myLabel1, -35, 0);
Here are the logs:
Here is the backtrace decoded
Any feedback is highly appreciated, thank you!
Marius
To rotate the whole screen you can use LVGL’s screen rotation feature:
https://docs.lvgl.io/master/porting/display.html#rotation
Hi kisvegabor,
Thank you for your reply. Using lv_disp_set_rotation(disp, rot) does not help me much.
Please see the picture attached, that’s how I need the objects to rotate. Basically the objects should rotate on their own axis.
Thoughts?
Thank you very much.
Marius
In this case what you need is a new layout + rotation.
Let’s say it’s a 240x320 screen by default and you arranged the items below each other.
On rotation you should enable sw_rotation
to get a 320x240 landscape screen. However now the widget’s position is not correct - as you mentioned - so you should rearrange them. The layouts of LVGL can help a lot with it.
I see, thank you. I will take a look into layouts and try to redesign everything.
Will get back with feedback.
Marius
Hi Gabor,
I have added 2 panel objects: Top Panel (with the 4 numbers) and Bottom Panel (with the square image). The parent is the screen object itself.
I set the flex like this:
lv_obj_set_flex_flow(ui_MainScreen, LV_FLEX_FLOW_COLUMN);
This works so far, however once I do:
lv_disp_set_rotation(disp, LV_DISP_ROT_90);
Everything disappears. I have tried to rotate the Panel with transform
lv_obj_set_style_transform_angle(ui_TopPanel, 900, 0);
But no luck, the whole panel disappears. Also, even if I use lv_disp_set_rotation without any flex settings, I get the same behaviour, nothing appears. This happens now, with panels as parents of my elements, because before, the screen was rotating as I drew above in this thread.
Not sure what I am doing wrong. Do you guys offer paid help? I feel bad for keep asking for help.
Looking forward to your thoughts, thank you! @kisvegabor
Marius
Could you send a a code snippet to reproduce the issue? Just create some boxes with LVGL, set flex, and set the display rotation.
Sure, I will try that and come back with feedback
Hi @kisvegabor,
I managed to work on this again and it seems whenever I use
lv_disp_set_rotation(disp, LV_DISP_ROT_90);
The display is just black… nothing happens. Cannot go forward with the flex part since there is nothing rendering. I created a parent panel with 2 child panels, but yea…
Any ideas?
Thank you!
Marius
Please enable logging in LVGL to see if there are any internal issues.
Hi @kisvegabor,
I have enabled LV_USE_LOG and LV_LOG_PRINTF and also created a callback like this, because I’m not sure ESP32 can printf the logs by default:
void my_log_cb(const char * buf) {
//serial_send(buf, strlen(buf));
Serial.println("\n\nLVGL LOGS: ");
Serial.print(buf);
}
And registered it inside setup()
lv_log_register_print_cb(my_log_cb);
However, when the ESP is crashing due to rotations or whatever, nothing is printed in the serial console.
Am I doing something wrong?
EDIT:
When I do:
lv_disp_set_rotation(NULL, LV_DISP_ROT_90);
I am getting:
|[Error]|(3.002, +3002)| lv_mem_realloc: couldn't allocate memory |(in lv_mem.c line #211)|
|---|---|---|---|
|[Error]|(3.003, +1)| lv_mem_buf_get: Asserted at expression: buf != NULL (Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size)) |(in lv_mem.c line #312)|
EDIT2:
Setting
#define LV_MEM_CUSTOM 1
in lv_conf.h
seems to help, it rotates everything 90 degrees. I will go ahead and play with Flex, see if I can get the desired effect.
Marius
Hi guys,
It seems the issue was indeed due to not enough memory, that’s why the esp32 was also crashing when I first started this topic.
There is no need for sw_rotate=1 or flex in my case, I just use the transform/translate stuff and it’s doing the job just fine. I ended up improving the code, wrapping half of the screen (my buttons) inside a panel, which I am rotating - this improves the code a lot as I don’t have to move individual buttons or behaviours around, based on orientation. The top part is a bit different so I ended up rotating each element (it can be a bit improved, from 8 rotations to 4, but I will leave it for now)
#define LV_MEM_CUSTOM 1
in lv_conf.h solved everything.
@kisvegabor is this fine if I go forward like this?
Thank you as always!
Marius
Happy top hear that you found the root of the problem.
Yes, seems fine 
1 Like