Description
I am trying to render a simple image on one of my SSD1306. It works when I am passing text or a symbol, but only renders a blank screen when I pass the image as a variable, as described in the tutorial. If it helps, I am using ZMK since the display I am trying to render to is on a keyboard.
What MCU/Processor/Board and compiler are you using?
nRF52840
What LVGL version are you using?
v8.4. This is because ZMK is built with this version.
What do you want to achieve?
Make the screen show a simple 7x7 image. Or any image whatsoever.
What have you tried so far?
I tried passing a symbol or text as the image source: this works. Then, I also tried to pass an image variable as described in the tutorial. I tried different encodings from the converter, but to no avail.
Code to reproduce
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_STUPIDIMAGE
#define LV_ATTRIBUTE_IMG_STUPIDIMAGE
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_STUPIDIMAGE uint8_t stupidimage_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
0xb7, 0xb7, 0xb7, 0xff, 0xb7, 0xb7, 0xb7,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
/*Pixel format: Red: 5 bit, Green: 6 bit, Blue: 5 bit*/
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf,
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xff, 0xdf, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0x96,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
/*Pixel format: Red: 5 bit, Green: 6 bit, Blue: 5 bit BUT the 2 bytes are swapped*/
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf, 0xff, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5,
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf, 0xff, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5,
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf, 0xff, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5,
0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff, 0xdf, 0xff,
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf, 0xff, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5,
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf, 0xff, 0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5,
0x96, 0xa5, 0x96, 0xa5, 0x96, 0xa5, 0xdf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 0xff, 0xa2, 0xae, 0xb2, 0xff,
0xa2, 0xae, 0xb2, 0xff, 0xa2, 0xae, 0xb2, 0xff, 0xa2, 0xae, 0xb2, 0xff, 0xf9, 0xf6, 0xfa, 0xff, 0xa2, 0xae, 0xb2, 0xff, 0xa2, 0xae, 0xb2, 0xff, 0xa2, 0xae, 0xb2, 0xff,
#endif
};
const lv_img_dsc_t stupidimage = {
.header.cf = LV_IMG_CF_TRUE_COLOR,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 7,
.header.h = 7,
.data_size = 49 * LV_COLOR_SIZE / 8,
.data = stupidimage_map,
};
int zmk_widget_image_init(struct zmk_widget_image *widget, lv_obj_t *parent) {
LV_IMG_DECLARE(stupidimage);
widget->obj = lv_img_create(parent);
lv_img_set_src(widget->obj, &stupidimage);
// lv_img_set_src(widget->obj, LV_SYMBOL_DUMMY "Some text");
sys_slist_append(&widgets, &widget->node);
widget_image_init();
return 0;
}
static struct zmk_widget_image image_widget;
lv_obj_t *zmk_display_status_screen() {
lv_obj_t *screen;
screen = lv_obj_create(NULL);
zmk_widget_image_init(&image_widget, screen);
lv_obj_align(zmk_widget_image_obj(&image_widget), LV_ALIGN_CENTER, 0, 0);
lv_obj_set_size(zmk_widget_image_obj(&image_widget), 32, 32);
return screen;
}
Screenshot and/or video
There is just a blank box over the display elements.