Description
I need to display icons in my GUI. I am using a monochrome display and already have said icon codified as C arrays (1 byte = 8 pixels on one line). I guess it would be pointless to convert them as images for lvgl as they would require at least 8 times more RAM.
I think (but I am not sure) the best way to display those icons is by using a canvas object. I have thus far failed at changing single pixels on a canvas: everything remains constantly black.
What MCU/Processor/Board and compiler are you using?
For now I’m working on the SDL simulator.
What do you want to achieve?
Changing single pixels on a canvas
What have you tried so far?
Using the lv_canvas_set_px function
Code to reproduce
lv_theme_t *th = lv_theme_mono_init(0, NULL);
lv_theme_set_current(th);
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(48,48)];
lv_obj_t *canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_canvas_set_buffer(canvas, cbuf, 48, 48, LV_IMG_CF_INDEXED_1BIT);
lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0);
for(int i = 0; i < 48; i++) {
for (int j = 0; j < 48; j++) {
lv_color_t px;
px.full = j % 2;
lv_canvas_set_px(canvas, i, j, px);
}
}
Screenshot and/or video
I would expect the canvas to display a grid of full/empty pixels, but it ends up being entirely black.