Skip to content

Commit 44ead5f

Browse files
committed
tests: lib: gui: lvgl: Migrate to version 9.2
With the update to v9.2.0 several Kconfig symbols were renamed or removed. Adjust the test accordingly. Also several constants were renamed, rename those also. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 2f32792 commit 44ead5f

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

tests/lib/gui/lvgl/prj.conf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ CONFIG_FLASH=y
99
CONFIG_FLASH_MAP=y
1010
CONFIG_FILE_SYSTEM=y
1111
CONFIG_FILE_SYSTEM_LITTLEFS=y
12+
CONFIG_LV_Z_AUTO_INIT=n
1213

1314
CONFIG_LVGL=y
1415
CONFIG_LV_Z_MEM_POOL_SIZE=16384
1516
CONFIG_LV_Z_USE_FILESYSTEM=y
16-
CONFIG_LV_MEM_CUSTOM=y
1717
CONFIG_LV_USE_LOG=y
1818
CONFIG_LV_COLOR_DEPTH_32=y
19-
CONFIG_LV_COLOR_SCREEN_TRANSP=y
2019
CONFIG_LV_USE_BIDI=y
2120
CONFIG_LV_USE_ARABIC_PERSIAN_CHARS=y
2221
CONFIG_LV_USE_LABEL=y
2322
CONFIG_LV_LABEL_TEXT_SELECTION=y
2423
CONFIG_LV_LABEL_LONG_TXT_HINT=y
25-
CONFIG_LV_USE_IMG=y
2624
CONFIG_LV_USE_LINE=y
2725
CONFIG_LV_USE_ARC=y
2826
CONFIG_LV_USE_WIN=y
@@ -39,9 +37,6 @@ CONFIG_LV_USE_LED=y
3937
CONFIG_LV_USE_MSGBOX=y
4038
CONFIG_LV_USE_TEXTAREA=y
4139
CONFIG_LV_USE_SPINBOX=y
42-
CONFIG_LV_USE_BTN=y
43-
CONFIG_LV_USE_IMGBTN=y
44-
CONFIG_LV_USE_BTNMATRIX=y
4540
CONFIG_LV_USE_KEYBOARD=y
4641
CONFIG_LV_USE_CHECKBOX=y
4742
CONFIG_LV_USE_LIST=y
@@ -71,10 +66,8 @@ CONFIG_LV_FONT_MONTSERRAT_42=y
7166
CONFIG_LV_FONT_MONTSERRAT_44=y
7267
CONFIG_LV_FONT_MONTSERRAT_46=y
7368
CONFIG_LV_FONT_MONTSERRAT_48=y
74-
CONFIG_LV_FONT_MONTSERRAT_12_SUBPX=y
7569
CONFIG_LV_FONT_MONTSERRAT_28_COMPRESSED=y
7670
CONFIG_LV_FONT_DEJAVU_16_PERSIAN_HEBREW=y
7771
CONFIG_LV_FONT_SIMSUN_16_CJK=y
7872
CONFIG_LV_FONT_UNSCII_8=y
7973
CONFIG_LV_USE_FONT_COMPRESSED=y
80-
CONFIG_LV_USE_FONT_SUBPX=y

tests/lib/gui/lvgl/src/img.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,16 @@ static const uint8_t img_data[] = {
120120
/* 96 */
121121
};
122122

123-
static lv_img_dsc_t img_dsc = {
124-
.header.always_zero = 0,
123+
static lv_image_dsc_t img_dsc = {
125124
.header.w = 96,
126125
.header.h = 96,
127126
.data_size = sizeof(img_data),
128-
.header.cf = LV_IMG_CF_INDEXED_1BIT,
127+
.header.cf = LV_COLOR_FORMAT_I1,
129128
.data = img_data,
130129
};
131130

132131

133-
const lv_img_dsc_t *get_lvgl_img(void)
132+
const lv_image_dsc_t *get_lvgl_img(void)
134133
{
135134
return &img_dsc;
136135
}

tests/lib/gui/lvgl/src/main.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
#include <zephyr/kernel.h>
1111
#include <zephyr/device.h>
12+
#include <zephyr/drivers/display.h>
1213
#include <zephyr/fs/fs.h>
1314
#include <zephyr/fs/littlefs.h>
1415
#include <zephyr/ztest.h>
16+
#include <lvgl_zephyr.h>
1517

1618
#include <lvgl.h>
1719

@@ -54,6 +56,8 @@ static struct fs_mount_t mnt = {
5456
};
5557
#endif /* CONFIG_FS_LITTLEFS_BLK_DEV */
5658

59+
static const struct device *display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
60+
5761
ZTEST(lvgl_screen, test_get_default_screen)
5862
{
5963
zassert_not_null(lv_scr_act(), "No default screen");
@@ -94,13 +98,37 @@ ZTEST_USER(lvgl_fs, test_add_img)
9498
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
9599
}
96100

101+
void *setup_lvgl(void)
102+
{
103+
int ret;
104+
105+
#if CONFIG_LV_COLOR_DEPTH_1 == 1
106+
display_set_pixel_format(display_dev, PIXEL_FORMAT_MONO10);
107+
#elif CONFIG_LV_COLOR_DEPTH_8 == 1 || CONFIG_LV_COLOR_DEPTH_24 == 1
108+
/* No 8bit display pixel format not supported */
109+
display_set_pixel_format(display_dev, PIXEL_FORMAT_RGB_888);
110+
#elif CONFIG_LV_COLOR_DEPTH_16 == 1
111+
display_set_pixel_format(display_dev, PIXEL_FORMAT_RGB_565);
112+
#elif CONFIG_LV_COLOR_DEPTH_32 == 1
113+
display_set_pixel_format(display_dev, PIXEL_FORMAT_ARGB_8888);
114+
#else
115+
#error "No display pixel format defined, is your board supported?"
116+
#endif
117+
118+
ret = lvgl_init();
119+
zassert_equal(ret, 0, "Failed to initialize lvgl");
120+
121+
return NULL;
122+
}
97123

98124
void *setup_fs(void)
99125
{
100126
struct fs_file_t img;
101127
struct fs_dirent info;
102128
int ret;
103-
const lv_img_dsc_t *c_img = get_lvgl_img();
129+
const lv_image_dsc_t *c_img = get_lvgl_img();
130+
131+
setup_lvgl();
104132

105133
ret = fs_mount(&mnt);
106134
if (ret < 0) {
@@ -122,7 +150,7 @@ void *setup_fs(void)
122150
return NULL;
123151
}
124152

125-
ret = fs_write(&img, &c_img->header, sizeof(lv_img_header_t));
153+
ret = fs_write(&img, &c_img->header, sizeof(lv_image_header_t));
126154
if (ret < 0) {
127155
TC_PRINT("Failed to write image file header: %d\n", ret);
128156
ztest_test_fail();
@@ -145,10 +173,10 @@ void *setup_fs(void)
145173
return NULL;
146174
}
147175

148-
void teardown_fs(void *data)
176+
void teardown_lvgl(void *data)
149177
{
150-
return;
178+
lv_deinit();
151179
}
152180

153-
ZTEST_SUITE(lvgl_screen, NULL, NULL, NULL, NULL, NULL);
154-
ZTEST_SUITE(lvgl_fs, NULL, setup_fs, NULL, NULL, teardown_fs);
181+
ZTEST_SUITE(lvgl_screen, NULL, setup_lvgl, NULL, NULL, teardown_lvgl);
182+
ZTEST_SUITE(lvgl_fs, NULL, setup_fs, NULL, NULL, teardown_lvgl);

0 commit comments

Comments
 (0)