LVGL in Zephyr application using ST7789 display and nRF52832

Description

I’m trying to use LVGL to display simple text and background color in a zephyr app with nRF52832. The app compiles and runs, but nothing is displayed on the screen. I’ve tried configuring the board file (.dts) and the prj.conf file. What am I missing? Is there any setting I need to make in the board file?

What MCU/Processor/Board and compiler are you using?

MCU: nRF52832, Framework: Zephyr

What do you want to achieve?

Use LVGL in Zephyr application and nRF52832 to display simple text.

What have you tried so far?

  1. Added configuration in prj.conf
CONFIG_LV_Z_MEM_POOL_SIZE=16384
CONFIG_LV_Z_SHELL=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_DISPLAY=y
CONFIG_DISPLAY_LOG_LEVEL_ERR=y

CONFIG_LVGL=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_USE_LOG=y
CONFIG_LV_USE_LABEL=y
CONFIG_LV_USE_BTN=y
CONFIG_LV_USE_ARC=y
CONFIG_LV_USE_IMG=y
CONFIG_LV_USE_MONKEY=y
CONFIG_LV_FONT_MONTSERRAT_14=y
  1. Added display node in MIPI-DBI
/ {
	chosen {
        ...
		zephyr,display = &display;
	};

	mipi_dbi {
		compatible = "zephyr,mipi-dbi-spi";
		reset-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
		dc-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
		spi-dev = <&spi0>;
		write-only;
		#address-cells = <1>;
		#size-cells = <0>;

		display: st7789v@0 {
			compatible = "sitronix,st7789v";
			mipi-max-frequency = <8000000>;
			reg = <0>;
			width = <240>;
			height = <240>;
			x-offset = <0>;
			y-offset = <0>;
			vcom = <0x19>;
			gctrl = <0x35>;
			vrhs = <0x12>;
			vdvs = <0x20>;
			mdac = <0x60>;
			gamma = <0x01>;
			colmod = <0x55>;
			lcm = <0x2c>;
			porch-param = [0c 0c 00 33 33];
			cmd2en-param = [5a 69 02 01];
			pwctrl1-param = [a4 a1];
			pvgam-param = [d0 04 0d 11 13 2b 3f 54 4c 18 0d 0b 1f 23];
			nvgam-param = [d0 04 0c 11 13 2c 3f 44 51 2f 1f 1f 20 23];
			ram-param = [00 f0];
			rgb-param = [cd 08 14];
			mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
			status = "okay";
		};
	};
}

&pinctrl {
	...

	spi0_default: spi0_default {
		group1 {
			psels = <NRF_PSEL(SPIM_MOSI, 0, 29)>, <NRF_PSEL(SPIM_SCK, 0, 28)>;
			low-power-enable;
		};
	};
};

&spi0 {
	status = "okay";
	pinctrl-0 = <&spi0_default>;
	pinctrl-names = "default";
	cs-gpios = <&gpio0 30 0>;
};

Code to reproduce

void hello_world()
{
        LOG_INF("Starting LVGL thread");

        char count_str[11] = {0};
        const struct device *display_dev;
        lv_obj_t *hello_world_label;
        lv_obj_t *count_label;

        display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
        if (!device_is_ready(display_dev))
        {
                LOG_ERR("Display device not ready");
                return;
        }

        lv_obj_t *screen = lv_scr_act();
        lv_obj_set_style_bg_color(screen, lv_color_white(), LV_PART_MAIN);
        lv_obj_set_style_bg_opa(screen, LV_OPA_COVER, LV_PART_MAIN);

        hello_world_label = lv_label_create(screen);
        lv_label_set_text(hello_world_label, "Hello world!");
        lv_obj_set_style_text_color(hello_world_label, lv_color_black(), LV_PART_MAIN);
        lv_obj_align(hello_world_label, LV_ALIGN_CENTER, 0, 0);

        count_label = lv_label_create(screen);
        lv_obj_set_style_text_color(count_label, lv_color_black(), LV_PART_MAIN);
        lv_obj_align(count_label, LV_ALIGN_BOTTOM_MID, 0, 0);

        display_blanking_off(display_dev);
        lv_task_handler();

        while (1)
        {
                if ((count % 100) == 0U)
                {
                        sprintf(count_str, "%d", count / 100U);
                        lv_label_set_text(count_label, count_str);
                }
                lv_task_handler();
                ++count;
                k_msleep(10);
        }
}