How can I convert uint32_t image_buffer so that i could set it as image src into lv_img_set_src(img, src)
What MCU/Processor/Board and compiler are you using?
Kendryte K210 processor, KD233 dev board
What LVGL version are you using?
V7.0
What do you want to achieve?
I’m trying to preview my camera feed in to lv_img object. I hope i have chosen the right UI object for my purpose. basically lv_img_set_src will loop with the camera feed.
Code to reproduce/What have you tried so far?
I have tried below code and various other attempts with no luck. It works fine if I write image_buffer directly to LCD without LVGL.
Looking at your code snippet, I am not sure the image buffer address is being assigned correctly.
If you are passing a uint32_t I assume this is the actual address of the buffer? If so you don’t want to assign the address of this variable to the data part of the structure. I would expect it to be something like:
Thanks for the response. Yes, You are right. this is the actual address of the buffer. I just realized the above struct is not accepted for lv_img_set_src to begin with. Instead, I tried to pass the pixel data directly into lv_img_set_src like below,
lv_img_set_src(img1, (uint8_t*) image_buffer);
However, It did display some gibberish text on the screen(See the attached image). I’m not sure this buffer holds the required correct image data format. How can I check the content of image_buffer in a meaningful way? to make sure it is in an acceptable image data format.
I’m currently looking into how best to get the data into the LVGL image and will try and get back to you about it. In the mean time can you look at the following questions please?
Do you have any information about which image format your camera is delivering the data to the buffer in?
Can you confirm you can show a simple LVGL screen with a button or something to demonstrate your drivers are working correctly with LVGL?
I’m using OV5640 image sensor. I’m pretty new to this camera module, however I believe it outputs 8-bit RGB raw. I’m running their example configuration. I have attached the config file for your reference if required. ov5640cfg.h (8.1 KB)
Also, I can confirm that the LVGL implementation is working perfectly. As I could run any example given in the lv_examples repository.
Okay it looks like the camera buffer should be RGB888 format it may or may not work with LVGL directly but we should try and get at least something to display first and see whether it needs reformatting later…
I think something along these lines should work which is pretty similar to your first posting…
The assumption for the above code is the image buffer is global or a reserved area for dma.
Note also the img_bg & img1 variables need to be static so they are always available and not destroyed when exiting the function. Also lv_img_set_src() function needs the address of the img_bg variable passed hence the ‘&’ prefix in the call.
I would give this a try and see what happens, I would expect something on the screen even if it’s not the correct image.