Description
I am using Zephyr and a PineTime DK (nRF52832) and trying to set and image from an array using lv_img_set_src, but I am doing something wrong as my app is crashing.
What MCU/Processor/Board and compiler are you using?
nRF52832 - PineTime DK - Zephyr - GNU GCC
What LVGL version are you using?
8.3
What do you want to achieve?
Have an array of pixels show in an image widget.
What have you tried so far?
Read this documentation which states I can call lv_img_set_src(img, src) which will take “a variable in code (a C array with the pixels).” I have tried to
Code to reproduce
uint8_t img_src[2049];
lv_obj_t *screen_image;
void screen_init() {
screen_image = lv_img_create(lv_scr_act());
lv_obj_align(screen_image, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_width(screen_image, 32);
lv_obj_set_height(screen_image, 32);
}
void screen_img_set_src() {
lv_img_set_src(screen_image, &img_src);
lv_task_handler();
}
But I did notice when generating a file using the online conversion tool, that the result includes a structure. Does that mean a uint8_t img_src[] can’t be used?
const lv_img_dsc_t A32 = {
.header.cf = LV_IMG_CF_TRUE_COLOR,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 32,
.header.h = 32,
.data_size = 1024 * LV_COLOR_SIZE / 8,
.data = A32_map,
};
I know it could be the content of my array, but wanted to make sure it was possible because I think I have the array being populated correctly.