This reports total memory, including SPI-RAM which is not DMAable.
The display driver uses DMA and requires DMAable memory as large as the display buffers.
You can decrease the size of the display buffers by setting the factor argument in ili9341 constructor.
(try 2,4,8,16,32,64, choose the lowest value that works for you.
Setting factor to 8 means that the buffer will be 1/8 of the display and the entire display will be updated in 8 steps. So lower factor values mean faster and smoother display updates, higher values mean lower DMAable memory requirement.
Setting factor=16 does mostly get rid of the memory error (though I do still get them sometimes.)
Also, I sometimes get
RuntimeError: Failed initializing SPI bus
It seems the driver is unstable.
I have never managed to draw anything to the screen. Can you check my test code above? It is taken from the docs.
I have checked the hardware. The pins are all valid outputs, there is nothing else connected to them, the wiring is correct, and the display is definitely an ILI9341. I have had it working with micro-gui on the same hardware, but I want the more powerful LVGL.
I would very much appreciate any suggestions you may have,
gc.mem_free reports all available memory, not just DMA memory. if you have an esp32 and not an esp32s3 then you only have a small amount of memory that is DMA memory. When you initialize the display driver add the argument factor=x where x is a multiple of 4.The absolute first thing that needs to be done is that display needs to be initialized.
It’s because of the additional memory use from the repl. If you put the code into a script called main.py and upload that script to the ESP32 you will have no issues with the memory allocation portion so long as you set the driver up first thing.