Description
When I try to manually set an image from a variable I am getting errors.
What MCU/Processor/Board and compiler are you using?
nRF5340 dk and Zephyr
What LVGL version are you using?
8.3
What do you want to achieve?
Manually create an image and display it.
What have you tried so far?
Displaying the image using the c file from the Online Image Converter, which worked.
Using the same array values to manually create an image, as outlined here, which does not work with the same array data.
Code to reproduce
uint8_t src_test[] = {
0x00, 0x02, 0x00, 0x00, /*Color of index 0*/
0x29, 0xa5, 0x40, 0xf9, /*Color of index 1*/
....
};
void img_set_src() {
printf("img_set_src\n");
//un-cache image
printf("lv_img_cache_invalidate_src\n");
lv_img_cache_invalidate_src(NULL);
printf("lv_img_set_src\n");
const lv_img_dsc_t img_dsc = {
.header.cf = LV_IMG_CF_INDEXED_1BIT,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 150,
.header.h = 150,
.data_size = 2858,
.data = src_test,
};
printf("lv_img_set_src\n");
lv_img_set_src(ui_test_image, &img_dsc);
printf("done\n");
}
In my main I have this:
while (1) {
lv_timer_handler();
k_sleep(K_MSEC(10));
}
I see a “No Data” placeholder on the screen (150x150 gray or white) and these are the messages and errors:
lv_img_cache_invalidate_src
lv_img_set_src
lv_img_set_src
done
[00:00:21.327,545] <wrn> lvgl: (21.327, +13) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
--- 4 messages dropped ---
[00:00:21.327,728] <wrn> lvgl: (21.327, +0) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[00:00:21.340,515] <wrn> lvgl: (21.340, +13) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[00:00:21.340,698] <wrn> lvgl: (21.340, +0) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[00:00:21.353,485] <wrn> lvgl: (21.353, +13) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[00:00:21.353,668] <wrn> lvgl: (21.353, +0) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
[00:00:21.366,424] <wrn> lvgl: (21.366, +13) _lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)
[00:00:21.366,607] <wrn> lvgl: (21.366, +0) lv_draw_img: Image draw error (in lv_draw_img.c line #81)
I read this post but I have tried with CONFIG_LV_MEM_CUSTOM=y
in my prj.conf.
I also tried with a 50x50 image array and got the same result.