LVGL nRF9160 lv_task_handler hanging

I am having issues getting the LVGL library working with my nRF9160 Feather. I am using SDK version 2.5.0.

I have narrowed it down to the call to: `lv_task_handler()` not returning. I cannot figure out why.

I am using a 128 x 32 SSD1306 board from Amazon.

Can anyone see anything obvious that I am missing?

My .overlay file:

 / {
     chosen {
         zephyr,display = &display;
     };
 };

 &i2c1 {
     compatible = "nordic,nrf-twim";
     zephyr,concat-buf-size = <1024>;
     clock-frequency = <I2C_BITRATE_FAST>;
     display: ssd1306@3c {
         compatible = "solomon,ssd1306fb";
         reg = <0x3c>; //0x3c is the i2c address of the SSD1306 aIC.
         width = <128>;
         height = <32>; // Change to '64' when using the 128x64 pixel version.
         segment-offset = <0>;
         page-offset = <0>;
         display-offset = <0>;
         multiplex-ratio = <31>; //change to '63' when using the 128x64 pixel version
         segment-remap;
         com-invdir;
         com-sequential;
         prechargep = <0x22>;
     };
 };

My prj.conf file:

# Heap and stacks
CONFIG_INIT_STACKS=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=4092

# GPIO
CONFIG_GPIO=y

# Logging
CONFIG_LOG=y
CONFIG_CONSOLE=y

# Sensors
CONFIG_I2C=y
CONFIG_SENSOR=y

# Enable MCUboot bootloader
# CONFIG_BOOTLOADER_MCUBOOT=y

# Newlibc
CONFIG_NEWLIB_LIBC=y 

# Display
CONFIG_DISPLAY=y
# CONFIG_DISPLAY_LOG_LEVEL_DBG=y
CONFIG_SSD1306=y
# CONFIG_SSD1306_SH1106_COMPATIBLE=y
CONFIG_SSD1306_REVERSE_MODE=y

CONFIG_LVGL=y
CONFIG_LV_MEM_CUSTOM=y
CONFIG_LV_USE_LABEL=y
CONFIG_LV_USE_CANVAS=y
CONFIG_LV_USE_LOG=y
# CONFIG_LV_LOG_LEVEL_INFO=y

CONFIG_LV_DPI_DEF=148
CONFIG_LV_Z_BITS_PER_PIXEL=1
CONFIG_LV_COLOR_DEPTH_1=y
CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12=y

CONFIG_LV_Z_MEM_POOL_NUMBER_BLOCKS=8

# CONFIG_SENSOR_LOG_LEVEL_DBG=y
# CONFIG_AQW_LOG_LEVEL_DBG=y

My CMakeLists.txt:

# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(lock-alert)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})

And main.c:

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/drivers/display.h>
#include <zephyr/devicetree.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(aqw_basic_with_display_demo);

#include <lvgl.h>

static lv_obj_t *temp_label, *temp_value_label;

static int display_init(void)
{

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

	temp_label = lv_label_create(lv_scr_act());
	lv_label_set_text(temp_label, "T: (C)");
	lv_obj_align(temp_label, LV_ALIGN_TOP_MID, 0, 0);

	lv_task_handler();

	return 0;
}

void main(void)
{
	int err = 0;

	printf("Demo\n");

	/* Get display */
	err = display_init();
	if (err)
		__ASSERT_MSG_INFO("Unable to init display library. Err: %i", err);

	while (1)
	{

		// lv_task_handler();
		printf("here\n");
		k_sleep(K_MSEC(1000));
	}
}

I get output, but it is garbage as shown in the picture below. My while() loop does not seem to execute unless I comment out lv_task_handler on line 27 in main.c. I assume lv_task_handler is needed to properly process the screen updates.

I've attached a zip folder containing the project if helpful.

2526.lvgl.zip

Related