During the development process when using Quecpython LVGL, you may encounter many problems. This chapter summarizes some common issues.
Note: Image decoding consumes RAM resources!
Images are inevitably used in the project GUI. Quecpython LVGL supports three image formats: PNG, JPG, and SJPG.
Pros
Cons
Pros
Cons
SJPG is a custom format based on the regular "JPG" format, which stands for split-JPEG. It is a small JPEG segment data with an SJPG header, which is almost the same size as a JPG file, or maybe slightly larger.
Pros
Cons
First, consider the transparency requirement. If transparency is required, select the PNG format directly.
Next, consider the following two scenarios.
In this case, the flash access speed is fast, and the decoding speed difference is not significant. There is not much difference for you in the speed of loading the three image formats in the UI.
Please choose a format based on the requirements for image quality and resource allocation.
Generally, if image quality is not a high priority, SJPG can be chosen first, followed by JPG, and finally PNG.
If the module has sufficient RAM resources, PNG can be chosen first, followed by JPG, and finally SJPG.
Find a balance based on the actual situation of the project.
In this case, the access speed of the external 4-wire flash is slow, and when there are many UI images, you will perceive a significant lag.
In this case, you need to enable the image caching mechanism and choose JPG or PNG. Please do not choose SJPG.
As mentioned earlier, the file system reading speed of the external 4-wire flash is relatively slow, and LVGL image decoding consumes much time, resulting in GUI display lag. The image caching mechanism of LVGL needs to be used to solve this problem.
For JPG or PNG images, perform the following two steps before switching screens:
lv.img.cache_invalidate_src(None)
lv.img.cache_set_size(cache_num)
cache_num
- The number of images to be cached. Maximum value: 16.
Note:
- SJPG is not compatible with the image caching mechanism. This is because SJPG is essentially many small split images.
- The imgbtn widget cannot use the image caching mechanism. Do not use the imgbtn widget!
- Cached images will occupy RAM.
First, when entering sleep mode, make sure that the peripherals have stopped interacting, the USB is disconnected, and the threads are blocked or suspended. Otherwise, it will not be possible to enter sleep mode.
Under the condition that the above conditions are met, the module generally follows the process below to enter sleep mode. Please correspondingly turn off the backlight according to the hardware design.
import pm
import lvgl as lv
# Allow the module to enter sleep mode in idle state
pm.autosleep(1)
# Allow LVGL to enter sleep mode in idle state
lv.autoSleep(1)
# LCD enters sleep state
lcd.lcd_display_off()
# Touchpad enters sleep state if exists
tp.suspend()
# Close LCD backlight if it can be controlled
To exit sleep mode, perform the opposite operations as follows.
import pm
import lvgl as lv
# Module exits from sleep mode
pm.autosleep(0)
# LVGL exits from sleep mode
lv.autoSleep(0)
# Wake LCD up
lcd.lcd_display_on()
# Wake touchpad up
tp.resume()
# Open LCD backlight if it can be controlled
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。