I would display a picture on my lcd screen. I use the driver st7735, with PCA10040 and my IDE is segger embedded. I find the documentation of nrf_gfx_bmp565_draw:
I don't find example with it.
I don't understand the last parameter: [in]img_buf Pointer to data from the .bmp file, because I don't know how can I have a pointer to data.
In my code, I opened a picture with fopen, and I read this file with fread. I thought img_buf was the result of fread, but no, it doesn't work or it displays anything. Here is my code
char * img_file ="../../../../../../couleurs.bmp"; char buff_img; uint16_t img_size; FILE * img = fopen(img_file, "r"); img_size = fread(buff_img, sizeof(buff_img), 1, img); APP_ERROR_CHECK(nrf_gfx_bmp565_draw(p_lcd, &rect_img, img_size));
So i would like to have more information about nrf_gfx_bmp565_draw to understand how to use it.
Do you mean you don't know how pointers work on a conceptual level, or that you don't know how to transfer the image data into a buffer?
You mean buff_img and not img_buf I assume?
What I don't understand is where you have stored the couleurs.bmp file?
In order to access a file directly from your code you have to embed the file into the code flash, unless you have some external memory device connected to the nRF52 that you can use for file storage.
The easiest way to store an image in the internal flash is to find some tool to convert the bmp file into a const C array, that you can then declare in your code to store the image. Then you simply refer to this array whenever you want to display the image.
There are various tools available online to convert a bmp file into a C array, but not all of them support the 16-bit 565 format. You could give this one a try: https://www.displaymodule.com/pages/copy-of-displaymodules-image-converter-free-download
Please be aware that you might have to do some small changes to the generated file to integrate it into your code, in case the array uses a type not supported by the Segger compiler etc.
I didn't know how to transfer the image data into a buffer. I try DisplayModule but I can't use it because it converts image into two hexadecimal number. When I try to convert an image which is green, it converts 0x07E0 into 0x7, 0xE0 so the display is wrong because the third parameter is expected to be stored in 2-byte samples. I can't find a converter that works.
Thanks for your answer.
Did you find a solution to this?
I have been on vacation for the last two weeks, which is why I was unable to get back to you.
How the image data is defined in the source code is not critical, as long as the data in memory is correct. You can cast the buffer to a uint16_t buffer before sending it to the display to have the system treat the samples as 2-byte rather than 1-byte.
Hi, thanks for your response.
Yes, I can display an image. But now I want display an image received by Bluetooth. I can receive data in lot of array of 20 so I need to save them. So I have tried with fds library but I can only save one data and not an array, so I don’t know how to save data to display them.
How often will you receive new images?
It is important that the data is retained when you remove power to the nRF52, or would storing the image in RAM also be an option?
If you need to store an entire image to flash I don't think using the fds library is a very good option. If you instead use the sd_flash_... API in the SoftDevice directly you can write any size of buffer into the flash without having to fit it into an fds record.