HASwitchPlate / openHASP

HomeAutomation Switchplate based on lvgl for ESP32
https://www.openhasp.com
MIT License
660 stars 163 forks source link

Improve lvgl memory #676

Open 1achy opened 3 months ago

1achy commented 3 months ago

i use Sunton ESP32-S3 7" 800*480

Device Memory

Free Heap | 65.80 KiB Free Block | 55.98 KiB Fragmentation | 14% PSRam Free | 7.18 MiB PSRam Size | 7.99 MiB

Total | 64.00 KiB Free | 5.61 KiB Fragmentation | 14%

out of memory ..... block screen...

solution reflash firmware ...

fvanroie commented 3 months ago

Try increasing # define LV_MEM_SIZE (64 * 1024U) // 64Kb on ESP32 with PSram or set #define LV_MEM_CUSTOM 1

1achy commented 3 months ago

I ever used https://nightly.openhasp.com/ precompiled 0.7 FOR SUNTO 7":

image

STEP COMPILING:

1) The file include\user_config_override-template.h for suntun ????

2) CAN I USE : Compiling online with Gitpod (WHAT IS IT LINK FOR 0.7 version)

1achy commented 3 months ago

Where do i found source 0.7?

fvanroie commented 3 months ago

Where do i found source 0.7?

It is here: https://github.com/HASwitchPlate/openHASP

For Gitpod use https://gitpod.io/new/#https://github.com/HASwitchPlate/openHASP/tree/master

1achy commented 3 months ago

Where do i found source 0.7?

It is here: https://github.com/HASwitchPlate/openHASP

For Gitpod use https://gitpod.io/new/#https://github.com/HASwitchPlate/openHASP/tree/master

i cant found 0.7, i need for sutun 7 inch

image

1achy commented 3 months ago

What do u choose for sunton 7 inch :

extra_default_envs = ; Uncomment specific environments or create extra: ; az-touch-mod-esp32_ili9341_4MB ; az-touch-mod-esp32_ili9341_8MB ; d1-mini-esp32_ili9341 ; d1-r32-unoshield_ili9341_adc

And what file define 👍

LV_MEM_CUSTOM.???

1achy commented 3 months ago

COMPILING STEP A copy of platformio_override-template.ini to platformio_override.ini will be readily prepared for you.

Click platformio_override.ini to open it, and to select your firmware flavour for your hardware uncomment in the extra_configs section the platform of your hadware, for example for ESP32:

STEP1 [platformio] extra_configs = ; Uncomment or edit the lines to show more User Setups in the PIO sidebar ; user_setups/darwin_sdl/.ini user_setups/esp32s3/.ini ; user_setups/esp32/.ini ; user_setups/esp8266/.ini ; user_setups/linux_sdl/.ini

If you use customization, remove the comment from the line -DUSE_CONFIG_OVERRIDE and make sure you have your own user_config_override.h in place: (please consider before saving your wifi and mqtt credentials to an online cloud)

STEP2 [override] ; -- Hasp config options -------------------------------------- build_flags = ; -- Uncomment the next line to use the file include/user_config_override.h settings -DUSE_CONFIG_OVERRIDE

And finally select your supported hardware from the extra_default_envs section by uncommenting the corresponding line. For example to build firmware for Lanbon L8, you should remove that comment only:

STEP3 extra_default_envs = ; Comment unneeded environments or create extra ; arduitouch-esp32_ili9341 ; d1-mini-esp32_ili9341 ; d1-mini-esp8266_ili9341 ; d132-unoshield ; esp12e-st7735 ; esp32dev-mrb3511 ; esp32dev-ili9488 ; lanbon_l8 sunton-8048s070c_16MB ; lolin-d32-pro_ili9341 ; my_custom_build ; nodemcu32s-raspi ; wt32-sc01 ; ttgo_esp32_poe-ili9341

Save the file by pressing Ctrl + S or selecting Save from the top-left menu.

Note You can of course uncomment multiple lines, the system will make builds for each. Note that these environments rely on the platforms above so double-check that your hardware has the correct platform enabled in the extra_configs section!

STEP 4 Customization The file include\user_config_override-template.h lists the options you have to customize your build. Settings applied here will act as factory defaults in the firmware. REname in : user_config_override.h Check the file for the self-explanatory options. Some of the available possibilities are: • WiFi Settings • MQTT Settings • OTA Server Settings • Syslog Settings • Timezone • Interface Language • Web interface coloring • Built-in fonts choice • GPIO Templates Copy it to include\user_config_override.h and change the settins per your needs. Uncomment -DUSE_CONFIG_OVERRIDE in platformio_override.ini to ensure that the config overrides are taken into account during the compilation process.

STEP 5 Parameters lvgl is in file : include\user_config_override-template.h row 150

define LV_MEM_SIZE (64 * 1024U) // 64Kb on ESP32 with PSram define LV_MEM_CUSTOM 1 // completely remove the specific LVGL heap and use the ESP32 heap

image

1achy commented 3 months ago

The problen is rename: include\user_config_override-template.h to include\user_config_override.h

NOW where can found :

STEP 5 Parameters lvgl is in file : include\user_config_override-template.h row 150

define LV_MEM_SIZE (64 * 1024U) // 64Kb on ESP32 with PSram define LV_MEM_CUSTOM 1

1achy commented 3 months ago

image

now i need try

1achy commented 3 months ago

i use : define LV_MEM_SIZE (64 * 1024U)

BEFORE

i use Sunton ESP32-S3 7" 800*480

Device Memory

Free Heap | 65.80 KiB Free Block | 55.98 KiB Fragmentation | 14% PSRam Free | 7.18 MiB PSRam Size | 7.99 MiB

LVGL Memory Total | 64.00 KiB Free | 5.61 KiB Fragmentation | 14%

out of memory ..... block screen...

solution reflash firmware ...

AFTER Now i have :

Device Memory

Free Heap | 75.34 KiB Free Block | 63.98 KiB Fragmentation | 15% PSRam Free | 7.20 MiB PSRam Size | 7.99 MiB

LVGL Memory Total | 64.00 KiB Free | 11.19 KiB Fragmentation | 4%

free lgvl INCREASE 5Kib free heap increase 10kib

1achy commented 3 months ago

is it better use define LV_MEM_CUSTOM 1 ?

marsman7 commented 3 months ago

is it better use define LV_MEM_CUSTOM 1 ?

I don't think that's a good idea for you, you would have to programme your own memory management.

fvanroie commented 3 months ago

LV_MEM_CUSTOM 1 just means to use the default heap memory pool instead of the reserved LVGL block. It uses the standard C memory management of malloc/free/etc. It has been used and should work fine... the only downside I can think of is a higher fragmentation, which should be compensated by the larger pool.

When you start customizing the firmware, it is up to you to test it and tweak where needed.

1achy commented 3 months ago

LV_MEM_CUSTOM 1 just means to use the default heap memory pool instead of the reserved LVGL block. It uses the standard C memory management of malloc/free/etc. It has been used and should work fine... the only downside I can think of is a higher fragmentation, which should be compensated by the larger pool.

When you start customizing the firmware, it is up to you to test it and tweak where needed.

Di u have same guide for improve this mem allocaror?

fvanroie commented 3 months ago

Just change #define LV_MEM_CUSTOM 0 to #define LV_MEM_CUSTOM 1 in include\lv_conf_v7.h and then recompile.

1achy commented 3 months ago

i try : image

lvgl memory dont change :

image

1achy commented 3 months ago

Just change #define LV_MEM_CUSTOM 0 to #define LV_MEM_CUSTOM 1 in include\lv_conf_v7.h and then recompile.

so i do

hb020 commented 2 months ago

Just created a PR that will allow avoiding to have to modify lv_conf_v7.h or lv_conf_v8.h, and will allow control from user_config_override.h, as is expected.

Not that LV_MEM_CUSTOM 1 is really recommended: To be tested. It made my sc01plus lose WiFi randomly.

edit: the PR is accepted. One no longer needs to modify lv_conf_v7.h or lv_conf_v8.h. Just user_config_override.h will do.

fvanroie commented 2 months ago

You'll need to keep an eye on the memory fragmentation on the info page. I doubt the WiFi signal issue has anything to do with the LVGL memory option, but please let me know if you find anything conclusive.

MrEcosse commented 2 months ago

I've used this method too to overcome an issue with both the Sunton and Guition screen crashing due to lack of available LVGL memory. Forgive my ignorance here (my first program was input via paper tape on an acoustic coupler telephone line) but with these higher resolution screens would it be possible for the default LVGL allocation to be higher? I am not able to create as many screens or use as many objects as I do on my Lanbon screens without having to do a custom compile.

fvanroie commented 2 months ago

What settings did you change? Were there any adverse effects? If there needs to be a different limit, please propose a change or PR.

I can't know what number of pages and objects are being used by everybody, so your feedback is needed to come up with a reasonable default value. The current default have been in place for quite a while and are quite stable. We can increase the LVGL memory, but the change needs to be justified and stable. What limit do you suggest?

fvanroie commented 1 month ago

No suggestions?

MrEcosse commented 1 month ago

Sorry been travelling again. I changed LV_MEM_CUSTOM 1 as noted in a previous thread. So far no noticeable problems in the past 3 weeks. Fragmentation had increased to 70%. I just rebooted one of the panels and fragmentation now 45%. I'll add notes if anything changes/goes wrong!