This blog is to teach how to store the PNG image (converted to RGB 565) file into the external QSPI flash.
Assume all the PNG are 240×320 resolution, I target to use the Adafruit 1947 (ILI9341) board with nRF52840 DK in this demo.
The python script can be found at https://github.com/jimmywong2003/PNG-to-RGB565.
Convert the PNG Image file to C code include file and binary file.
python png2rgb565.py ..\picture\IMAGE_01.png result_output\IMAGE_01.h result_output\IMAGE_01.bin python png2rgb565.py ..\picture\IMAGE_02.png result_output\IMAGE_02.h result_output\IMAGE_02.bin python png2rgb565.py ..\picture\IMAGE_03.png result_output\IMAGE_03.h result_output\IMAGE_03.bin python png2rgb565.py ..\picture\IMAGE_04.png result_output\IMAGE_04.h result_output\IMAGE_04.bin python png2rgb565.py ..\picture\IMAGE_05.png result_output\IMAGE_05.h result_output\IMAGE_05.bin
Use the objcopy file to generate the HEX file assuming each size of image file is smaller than 0x40000 (256KB).
objcopy -v -I binary -O ihex --change-addresses 0x12000000 IMAGE_01.bin IMAGE_01.hex objcopy -v -I binary -O ihex --change-addresses 0x12040000 IMAGE_02.bin IMAGE_02.hex objcopy -v -I binary -O ihex --change-addresses 0x12080000 IMAGE_03.bin IMAGE_03.hex objcopy -v -I binary -O ihex --change-addresses 0x120C0000 IMAGE_04.bin IMAGE_04.hex objcopy -v -I binary -O ihex --change-addresses 0x12100000 IMAGE_05.bin IMAGE_05.hex
Erase the QSPI flash content on nRF52840 DK
if you need to use the qspi on the NRF52840 DK board, you need to include the
It would call the qspidefault.ini (red color) instruction.
; Custom instructions to send to the external memory after initialization. Only used if –qspicustominit option is given in the call to nrfjprog. Format is ; instruction code plus data to send in between optional brakets. Numbers can be given in decimal, hex (starting with either 0x or 0X) and binary (starting ; with either 0b or 0B) formats. The custom instructions will be executed in the order found. ; This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) enabling the Quad Operation and the High Performance ; mode for the MX25R6435F memory present in the nRF52840 DK. InitializationCustomInstruction = 0x06 InitializationCustomInstruction = 0x01, [0x40, 0, 0x2]
nrfjprog -f nrf52 --qspicustominit --qspieraseall
Write the IMAGE (Hex) files on the QSPI flash
nrfjprog -f nrf52 --qspicustominit --program ..\result_output\IMAGE_01.hex --sectorerase nrfjprog -f nrf52 --qspicustominit --program ..\result_output\IMAGE_02.hex --sectorerase nrfjprog -f nrf52 --qspicustominit --program ..\result_output\IMAGE_03.hex --sectorerase nrfjprog -f nrf52 --qspicustominit --program ..\result_output\IMAGE_04.hex --sectorerase nrfjprog -f nrf52 --qspicustominit --program ..\result_output\IMAGE_05.hex --sectorerase
Loading the image from QSPI flash
Initialize the QSPI
Define the IMAGE address
Loading image into the frame buffer RAM
i have a tftp display 2.4″ 320×240 and i have to display 30 types of animated emotion(emoji) on these display,also some of the emotion will be moving/dancing also,how much qspi flash memory will be require to keep all these image.
for any moving/dancing display will i require more than one frame.
It depends whether you would like to use any GUI or not. If you need to upgrade the full screen, you need to store 150KB per frame.
Nordic SDK has the GFX example. You may have a look on such demo code for your reference.
Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking.