Skip to content

Commit 847c75a

Browse files
committed
modules: lvgl: Update gluecode to v9.2
This patch updates the module gluecode to be compatible with LVGL version 9.2. This includes changes done to display and input driver initialization and draw buffer handling. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 7d7498b commit 847c75a

19 files changed

+227
-315
lines changed

modules/lvgl/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ choice LV_COLOR_DEPTH
8686
endchoice
8787

8888
config LV_COLOR_16_SWAP
89-
bool
89+
bool "Swap the 2 bytes of RGB565 color."
9090

9191
config LV_Z_FLUSH_THREAD
9292
bool "Flush LVGL frames in a separate thread"
@@ -127,10 +127,10 @@ config LV_Z_AREA_Y_ALIGNMENT_WIDTH
127127
the current frame dimensions to meet display and/or LCD host
128128
controller requirements. The value must be power of 2.
129129

130-
config LV_USE_GPU_STM32_DMA2D
130+
config LV_USE_DRAW_DMA2D
131131
bool
132132

133-
config LV_GPU_DMA2D_CMSIS_INCLUDE
133+
config LV_DRAW_DMA2D_HAL_INCLUDE
134134
string
135135
help
136136
Must be defined to include path of CMSIS header of target processor

modules/lvgl/include/lv_conf.h

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,31 @@
1212

1313
/* Memory manager settings */
1414

15-
#define LV_MEMCPY_MEMSET_STD 1
16-
#define LV_MEM_CUSTOM 1
15+
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
1716

1817
#if defined(CONFIG_LV_Z_MEM_POOL_HEAP_LIB_C)
19-
20-
#define LV_MEM_CUSTOM_INCLUDE "stdlib.h"
21-
#define LV_MEM_CUSTOM_ALLOC malloc
22-
#define LV_MEM_CUSTOM_REALLOC realloc
23-
#define LV_MEM_CUSTOM_FREE free
24-
18+
#define LV_STDLIB_INCLUDE "stdlib.h"
19+
#define lv_malloc_core malloc
20+
#define lv_realloc_core realloc
21+
#define lv_free_core free
2522
#else
26-
27-
#define LV_MEM_CUSTOM_INCLUDE "lvgl_mem.h"
28-
#define LV_MEM_CUSTOM_ALLOC lvgl_malloc
29-
#define LV_MEM_CUSTOM_REALLOC lvgl_realloc
30-
#define LV_MEM_CUSTOM_FREE lvgl_free
31-
23+
#define LV_STDLIB_INCLUDE "lvgl_mem.h"
24+
#define lv_malloc_core lvgl_malloc
25+
#define lv_realloc_core lvgl_realloc
26+
#define lv_free_core lvgl_free
3227
#endif
3328

34-
/* HAL settings */
35-
36-
#define LV_TICK_CUSTOM 1
37-
#define LV_TICK_CUSTOM_INCLUDE <zephyr/kernel.h>
38-
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (k_uptime_get_32())
39-
4029
/* Misc settings */
41-
42-
#define LV_SPRINTF_CUSTOM 1
43-
#define LV_SPRINTF_INCLUDE "stdio.h"
44-
#define lv_snprintf snprintf
45-
#define lv_vsnprintf vsnprintf
30+
#define lv_snprintf snprintf
31+
#define lv_vsnprintf vsnprintf
4632

4733
/* Provide definition to align LVGL buffers */
4834
#define LV_ATTRIBUTE_MEM_ALIGN __aligned(CONFIG_LV_ATTRIBUTE_MEM_ALIGN_SIZE)
4935

36+
#ifdef CONFIG_LV_COLOR_16_SWAP
37+
#define LV_COLOR_16_SWAP 1
38+
#endif /* CONFIG_LV_COLOR_16_SWAP */
39+
5040
/*
5141
* Needed because of a workaround for a GCC bug,
5242
* see https://github.com/lvgl/lvgl/issues/3078

modules/lvgl/include/lvgl_common_input.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct lvgl_common_input_config {
2020
};
2121

2222
struct lvgl_common_input_data {
23-
lv_indev_drv_t indev_drv;
2423
lv_indev_t *indev;
2524
lv_indev_data_t pending_event;
2625
lv_indev_data_t previous_event;

modules/lvgl/include/lvgl_display.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,28 @@ struct lvgl_disp_data {
2222
};
2323

2424
struct lvgl_display_flush {
25-
lv_disp_drv_t *disp_drv;
25+
lv_display_t *display;
2626
uint16_t x;
2727
uint16_t y;
2828
struct display_buffer_descriptor desc;
2929
void *buf;
3030
};
3131

32-
void lvgl_flush_cb_mono(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
33-
void lvgl_flush_cb_16bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
34-
void lvgl_flush_cb_24bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
35-
void lvgl_flush_cb_32bit(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
32+
void lvgl_flush_cb_mono(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
33+
void lvgl_flush_cb_16bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
34+
void lvgl_flush_cb_24bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
35+
void lvgl_flush_cb_32bit(lv_display_t *display, const lv_area_t *area, uint8_t *px_map);
3636

37-
void lvgl_set_px_cb_mono(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
38-
lv_coord_t y, lv_color_t color, lv_opa_t opa);
39-
void lvgl_set_px_cb_16bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
40-
lv_coord_t y, lv_color_t color, lv_opa_t opa);
41-
void lvgl_set_px_cb_24bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
42-
lv_coord_t y, lv_color_t color, lv_opa_t opa);
43-
void lvgl_set_px_cb_32bit(lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
44-
lv_coord_t y, lv_color_t color, lv_opa_t opa);
37+
void lvgl_set_px_cb_mono(lv_display_t *display, uint8_t *buf, int32_t buf_w, int32_t x, int32_t y,
38+
lv_color_t color, lv_opa_t opa);
39+
void lvgl_rounder_cb_mono(lv_event_t *e);
4540

46-
void lvgl_rounder_cb_mono(lv_disp_drv_t *disp_drv, lv_area_t *area);
47-
48-
int set_lvgl_rendering_cb(lv_disp_drv_t *disp_drv);
41+
int set_lvgl_rendering_cb(lv_display_t *display);
4942

5043
void lvgl_flush_display(struct lvgl_display_flush *request);
5144

5245
#ifdef CONFIG_LV_Z_USE_ROUNDER_CB
53-
void lvgl_rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area);
46+
void lvgl_rounder_cb(lv_event_t *e);
5447
#endif
5548

5649
#ifdef __cplusplus

modules/lvgl/include/lvgl_mem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <stdlib.h>
1111
#include <stdbool.h>
12+
#include <zephyr/sys/mem_stats.h>
1213

1314
#ifdef __cplusplus
1415
extern "C" {
@@ -22,6 +23,8 @@ void lvgl_free(void *ptr);
2223

2324
void lvgl_print_heap_info(bool dump_chunks);
2425

26+
void lvgl_heap_stats(struct sys_memory_stats *stats);
27+
2528
void lvgl_heap_init(void);
2629

2730
#ifdef __cplusplus

modules/lvgl/input/lvgl_button_input.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct lvgl_button_input_config {
1717
struct lvgl_common_input_config common_config; /* Needs to be first member */
1818
const uint16_t *input_codes;
1919
uint8_t num_codes;
20-
const lv_coord_t *coordinates;
20+
const int32_t *coordinates;
2121
};
2222

2323
static void lvgl_button_process_event(struct input_event *evt, void *user_data)
@@ -39,7 +39,7 @@ static void lvgl_button_process_event(struct input_event *evt, void *user_data)
3939
}
4040

4141
data->pending_event.btn_id = i;
42-
data->pending_event.state = evt->value ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
42+
data->pending_event.state = evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
4343

4444
if (k_msgq_put(cfg->common_config.event_msgq, &data->pending_event, K_NO_WAIT) != 0) {
4545
LOG_WRN("Could not put input data into queue");
@@ -72,8 +72,7 @@ int lvgl_button_input_init(const struct device *dev)
7272
LVGL_INPUT_DEFINE(inst, button, CONFIG_LV_Z_BUTTON_INPUT_MSGQ_COUNT, \
7373
lvgl_button_process_event); \
7474
static const uint16_t lvgl_button_input_codes_##inst[] = DT_INST_PROP(inst, input_codes); \
75-
static const lv_coord_t lvgl_button_coordinates_##inst[] = \
76-
DT_INST_PROP(inst, coordinates); \
75+
static const int32_t lvgl_button_coordinates_##inst[] = DT_INST_PROP(inst, coordinates); \
7776
static const struct lvgl_button_input_config lvgl_button_input_config_##inst = { \
7877
.common_config.event_msgq = &LVGL_INPUT_EVENT_MSGQ(inst, button), \
7978
.input_codes = lvgl_button_input_codes_##inst, \

modules/lvgl/input/lvgl_common_input.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ lv_indev_t *lvgl_input_get_indev(const struct device *dev)
2323
return common_data->indev;
2424
}
2525

26-
static void lvgl_input_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data)
26+
static void lvgl_input_read_cb(lv_indev_t *indev, lv_indev_data_t *data)
2727
{
28-
const struct device *dev = drv->user_data;
28+
const struct device *dev = lv_indev_get_user_data(indev);
2929
const struct lvgl_common_input_config *cfg = dev->config;
3030
struct lvgl_common_input_data *common_data = dev->data;
3131

3232
if (k_msgq_get(cfg->event_msgq, data, K_NO_WAIT) != 0) {
3333
memcpy(data, &common_data->previous_event, sizeof(lv_indev_data_t));
34-
if (drv->type == LV_INDEV_TYPE_ENCODER) {
34+
if (lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
3535
data->enc_diff = 0; /* For encoders, clear last movement */
3636
}
3737
data->continue_reading = false;
@@ -54,16 +54,16 @@ int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *
5454
return -EINVAL;
5555
}
5656

57-
lv_indev_drv_init(&common_data->indev_drv);
58-
common_data->indev_drv.type = indev_type;
59-
common_data->indev_drv.read_cb = lvgl_input_read_cb;
60-
common_data->indev_drv.user_data = (void *)dev;
61-
common_data->indev = lv_indev_drv_register(&common_data->indev_drv);
57+
common_data->indev = lv_indev_create();
6258

6359
if (common_data->indev == NULL) {
6460
return -EINVAL;
6561
}
6662

63+
lv_indev_set_type(common_data->indev, indev_type);
64+
lv_indev_set_read_cb(common_data->indev, lvgl_input_read_cb);
65+
lv_indev_set_user_data(common_data->indev, (void *)dev);
66+
6767
return 0;
6868
}
6969

modules/lvgl/input/lvgl_encoder_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static void lvgl_encoder_process_event(struct input_event *evt, void *user_data)
2828
if (evt->code == cfg->rotation_input_code) {
2929
data->pending_event.enc_diff = evt->value;
3030
} else if (evt->code == cfg->button_input_code) {
31-
data->pending_event.state = evt->value ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
31+
data->pending_event.state =
32+
evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
3233
data->pending_event.enc_diff = 0;
3334
data->pending_event.key = LV_KEY_ENTER;
3435
} else {

modules/lvgl/input/lvgl_keypad_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void lvgl_keypad_process_event(struct input_event *evt, void *user_data)
4040
return;
4141
}
4242

43-
data->pending_event.state = evt->value ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
43+
data->pending_event.state = evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
4444
if (k_msgq_put(cfg->common_config.event_msgq, &data->pending_event, K_NO_WAIT) != 0) {
4545
LOG_WRN("Could not put input data into keypad queue");
4646
}

modules/lvgl/input/lvgl_pointer_input.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ static void lvgl_pointer_process_event(struct input_event *evt, void *user_data)
3232
const struct device *dev = user_data;
3333
const struct lvgl_pointer_input_config *cfg = dev->config;
3434
struct lvgl_pointer_input_data *data = dev->data;
35-
lv_disp_t *disp = lv_disp_get_default();
36-
struct lvgl_disp_data *disp_data = disp->driver->user_data;
35+
lv_display_t *disp = lv_display_get_default();
36+
struct lvgl_disp_data *disp_data = (struct lvgl_disp_data *)lv_display_get_user_data(disp);
3737
struct display_capabilities *cap = &disp_data->cap;
3838
lv_point_t *point = &data->common_data.pending_event.point;
3939

@@ -54,7 +54,7 @@ static void lvgl_pointer_process_event(struct input_event *evt, void *user_data)
5454
break;
5555
case INPUT_BTN_TOUCH:
5656
data->common_data.pending_event.state =
57-
evt->value ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
57+
evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
5858
break;
5959
}
6060

0 commit comments

Comments
 (0)