Hi all,
I am trying to add a loading image to my project and wanted to add a ‘loading’ screen to it. To do that I took a 320x240 bmp file and converted it using the online converter to both a tru colour and 8bit image.
When I try to use is as true colour I immediately run into an out of memory error as I believe it is trying to load the entire 150kb image into RAM at once while I only have about 100kb total available.
If I instead try to use the 8bit colour version, it does load but seems to permenantly take up the full 77kb of memory and I cannot seem to free it even by setting variables to None an gc.collect() calls. In addition to this the colours are very wrong but that is a secondary issue.
Is there a way to load the image slowly as it is displayed and then removed from memory afterwards?
Boot file:
import machine
import ili9XXX
import lvgl as lv
lv.init()
disp = ili9XXX.ili9341(spihost=2, miso=19, mosi=23, clk=18, cs=2, dc=12, rst=4, rot=ili9XXX.LANDSCAPE, width=320, height=240)
with open('/images/scuba_snake_8bit.bin') as f:
img_data = f.read()
scr = lv.obj()
img = lv.img(scr)
img_dsc = lv.img_dsc_t(
{
"header": {"always_zero": 0, "w": 320, "h": 240, "cf": lv.img.CF.INDEXED_8BIT},
"data_size": len(img_data),
"data": img_data,
}
)
img.set_src(img_dsc)
img.set_drag(False)
# Load the screen and display image
lv.scr_load(scr)
images.zip (65.9 KB)