How to сreate a simple bar on a monochrome display?


OLED Display SSD1306

LVGL version 8.2

Is it possible to create a simple bar on a monochrome display?
I’m creating a frame.
Text with animation is printed.
But the bar is not created.

void lv_example(void)
	lv_obj_t *frame = lv_obj_create(lv_scr_act());
	lv_obj_set_size(frame, 128, 64);

	lv_obj_t *label2 = lv_label_create(frame);
	lv_obj_set_width(label2, 128);
	lv_obj_align(label2, LV_ALIGN_BOTTOM_MID, 0, 0);
	lv_label_set_text(label2, "It is a circularly scrolling text. ");
	lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR);

	lv_obj_t *bar = lv_bar_create(frame);
	lv_bar_set_mode(bar, LV_BAR_MODE_NORMAL);
	lv_obj_set_size(bar, 128, 10);
	lv_obj_set_align(bar, LV_ALIGN_CENTER);
	lv_bar_set_value(bar, 50, LV_ANIM_OFF);


Display OLED 128x64 SSD1306
To see the bar on the display, need to change the opacity value of its indicator.


static lv_style_t styleIndicatorBar;
lv_style_set_bg_opa(&styleIndicatorBar, LV_OPA_COVER);
lv_style_set_bg_color(&styleIndicatorBar, lv_color_black());
lv_obj_t *bar = lv_bar_create(NULL);
lv_obj_add_style(bar, &styleIndicatorBar, LV_PART_INDICATOR);