lvgl: bump version to v8.1.0
This updates the lvgl in-tree glue code to work with version v8.1.0 and bumps the west manifest accordingly. The following are the most significant changes: - The logging callback has changes in lvgl and no longer provides the caller with an integer log level code. We now need to parse the log string's prefix to determine the level. - Several Kconfig options (mostly for default values of various settings) have been removed because these values are no longer configurable in lvgl. - The library no longer performs a deep copy of the display and input device driver structs, so these must no longer be allocated on the stack in the init func. Other than that it's mostly about renaming of various structures and functions and adjusting the calls if function's signatures have changed. This patch allows all in-tree users to work correctly but it's likely it doesn't support all new widgets and layouts added in lvgl v8. These however can be added gradually once this is upstream. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
This commit is contained in:
parent
1e80d5a954
commit
1244a89a21
15 changed files with 99 additions and 251 deletions
|
@ -112,12 +112,6 @@ config LVGL_ANTIALIAS
|
|||
help
|
||||
Enable anti-aliasing
|
||||
|
||||
config LVGL_DISP_DEF_REFR_PERIOD
|
||||
int "Screen refresh period"
|
||||
default 30
|
||||
help
|
||||
Screen refresh period in milliseconds
|
||||
|
||||
config LVGL_DPI
|
||||
int "DPI"
|
||||
default 130
|
||||
|
|
|
@ -44,49 +44,4 @@ config LVGL_POINTER_KSCAN_INVERT_Y
|
|||
|
||||
endif # LVGL_POINTER_KSCAN
|
||||
|
||||
config LVGL_INDEV_DEF_READ_PERIOD
|
||||
int "Input device refresh period"
|
||||
default 30
|
||||
help
|
||||
Refresh period for input devices in milliseconds
|
||||
|
||||
config LVGL_INDEV_DEF_DRAG_LIMIT
|
||||
int "Drag Threshold"
|
||||
default 10
|
||||
help
|
||||
Threshold in pixels before entering drag mode
|
||||
|
||||
config LVGL_INDEV_DEF_DRAG_THROW
|
||||
int "Drag throw slow-down"
|
||||
default 10
|
||||
range 0 100
|
||||
help
|
||||
Percentage of slow down of a throw following a drag.
|
||||
Greater percentage means faster slow-down.
|
||||
|
||||
config LVGL_INDEV_DEF_LONG_PRESS_TIME
|
||||
int "Long press time"
|
||||
default 400
|
||||
help
|
||||
Period in milliseconds before a press is seen as a long press
|
||||
|
||||
config LVGL_INDEV_DEF_LONG_PRESS_REP_TIME
|
||||
int "Long press repeat time"
|
||||
default 100
|
||||
help
|
||||
Period in milliseconds after which a new trigger is generated
|
||||
for a long press
|
||||
|
||||
config LVGL_INDEV_DEF_GESTURE_LIMIT
|
||||
int "Gesture threshold"
|
||||
default 50
|
||||
help
|
||||
Gesture threshold in pixels
|
||||
|
||||
config LVGL_INDEV_DEF_GESTURE_MIN_VELOCITY
|
||||
int "Gesture minimum velocity"
|
||||
default 3
|
||||
help
|
||||
Gesture min velocity at release before swipe (pixels)
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -138,23 +138,11 @@ config LVGL_USE_LABEL
|
|||
|
||||
if LVGL_USE_LABEL
|
||||
|
||||
config LVGL_LABEL_DEF_SCROLL_SPEED
|
||||
int "Label scroll speed"
|
||||
default 25
|
||||
help
|
||||
Scroll speed in pixels per second if scroll mode is enabled for a label
|
||||
|
||||
config LVGL_LABEL_TEXT_SEL
|
||||
bool "Enable label text selection"
|
||||
help
|
||||
Enable label text selection
|
||||
|
||||
config LVGL_LABEL_WAIT_CHAR_COUNT
|
||||
int "Waiting period for label animation"
|
||||
default 3
|
||||
help
|
||||
Waiting period at beginning/end of the label animation cycle
|
||||
|
||||
config LVGL_LABEL_LONG_TXT_HINT
|
||||
bool "Enable long text hint for labels"
|
||||
help
|
||||
|
|
|
@ -49,8 +49,6 @@
|
|||
|
||||
#define LV_ANTIALIAS IS_ENABLED(CONFIG_LVGL_ANTIALIAS)
|
||||
|
||||
#define LV_DISP_DEF_REFR_PERIOD CONFIG_LVGL_DISP_DEF_REFR_PERIOD
|
||||
|
||||
#define LV_DPI CONFIG_LVGL_DPI
|
||||
|
||||
#define LV_DISP_SMALL_LIMIT CONFIG_LVGL_DISP_SMALL_LIMIT
|
||||
|
@ -69,34 +67,20 @@ typedef short lv_coord_t;
|
|||
|
||||
#define LV_MEM_CUSTOM_INCLUDE "stdlib.h"
|
||||
#define LV_MEM_CUSTOM_ALLOC malloc
|
||||
#define LV_MEM_CUSTOM_REALLOC realloc
|
||||
#define LV_MEM_CUSTOM_FREE free
|
||||
|
||||
#else
|
||||
|
||||
#define LV_MEM_CUSTOM_INCLUDE "lvgl_mem.h"
|
||||
#define LV_MEM_CUSTOM_ALLOC lvgl_malloc
|
||||
#define LV_MEM_CUSTOM_REALLOC lvgl_realloc
|
||||
#define LV_MEM_CUSTOM_FREE lvgl_free
|
||||
|
||||
#endif
|
||||
|
||||
#define LV_ENABLE_GC 0
|
||||
|
||||
/* Input device settings */
|
||||
|
||||
#define LV_INDEV_DEF_READ_PERIOD CONFIG_LVGL_INDEV_DEF_READ_PERIOD
|
||||
|
||||
#define LV_INDEV_DEF_DRAG_LIMIT CONFIG_LVGL_INDEV_DEF_DRAG_LIMIT
|
||||
|
||||
#define LV_INDEV_DEF_DRAG_THROW CONFIG_LVGL_INDEV_DEF_DRAG_THROW
|
||||
|
||||
#define LV_INDEV_DEF_LONG_PRESS_TIME CONFIG_LVGL_INDEV_DEF_LONG_PRESS_TIME
|
||||
|
||||
#define LV_INDEV_DEF_LONG_PRESS_REP_TIME CONFIG_LVGL_INDEV_DEF_LONG_PRESS_REP_TIME
|
||||
|
||||
#define LV_INDEV_DEF_GESTURE_LIMIT CONFIG_LVGL_INDEV_DEF_GESTURE_LIMIT
|
||||
|
||||
#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY CONFIG_LVGL_INDEV_DEF_GESTURE_MIN_VELOCITY
|
||||
|
||||
/* Feature usage */
|
||||
|
||||
#define LV_USE_ANIMATION IS_ENABLED(CONFIG_LVGL_USE_ANIMATION)
|
||||
|
@ -695,11 +679,11 @@ typedef void *lv_font_user_data_t;
|
|||
#if LV_USE_BIDI
|
||||
|
||||
#ifdef CONFIG_LVGL_BIDI_DIR_LTR
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_LTR
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_LTR
|
||||
#elif defined(CONFIG_LVGL_BIDI_DIR_RTL)
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_RTL
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_RTL
|
||||
#else
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -776,9 +760,6 @@ typedef void *lv_obj_user_data_t;
|
|||
|
||||
#define LV_USE_LABEL IS_ENABLED(CONFIG_LVGL_USE_LABEL)
|
||||
#if LV_USE_LABEL
|
||||
#define LV_LABEL_DEF_SCROLL_SPEED CONFIG_LVGL_LABEL_DEF_SCROLL_SPEED
|
||||
#define LV_LABEL_WAIT_CHAR_COUNT \
|
||||
CONFIG_LVGL_LABEL_WAIT_CHAR_COUNT
|
||||
#define LV_LABEL_TEXT_SEL IS_ENABLED(CONFIG_LVGL_LABEL_TEXT_SEL)
|
||||
#define LV_LABEL_LONG_TXT_HINT IS_ENABLED(CONFIG_LVGL_LABEL_LONG_TXT_HINT)
|
||||
#endif
|
||||
|
|
|
@ -20,9 +20,14 @@
|
|||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(lvgl);
|
||||
|
||||
static lv_disp_drv_t disp_drv;
|
||||
#ifdef CONFIG_LVGL_POINTER_KSCAN
|
||||
static lv_indev_drv_t indev_drv;
|
||||
#endif /* CONFIG_LVGL_POINTER_KSCAN */
|
||||
|
||||
#ifdef CONFIG_LVGL_BUFFER_ALLOC_STATIC
|
||||
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
|
||||
#define BUFFER_SIZE (CONFIG_LVGL_BITS_PER_PIXEL * ((CONFIG_LVGL_VDB_SIZE * \
|
||||
CONFIG_LVGL_HOR_RES_MAX * CONFIG_LVGL_VER_RES_MAX) / 100) / 8)
|
||||
|
@ -41,43 +46,34 @@ static uint8_t buf1[BUFFER_SIZE] __aligned(4);
|
|||
#endif /* CONFIG_LVGL_BUFFER_ALLOC_STATIC */
|
||||
|
||||
#if CONFIG_LVGL_LOG_LEVEL != 0
|
||||
static void lvgl_log(lv_log_level_t level, const char *file, uint32_t line,
|
||||
const char *func, const char *dsc)
|
||||
/*
|
||||
* In LVGLv8 the signature of the logging callback has changes and it no longer
|
||||
* takes the log level as an integer argument. Instead, the log level is now
|
||||
* already part of the buffer passed to the logging callback. It's not optimal
|
||||
* but we need to live with it and parse the buffer manually to determine the
|
||||
* level and then truncate the string we actually pass to the logging framework.
|
||||
*/
|
||||
static void lvgl_log(const char *buf)
|
||||
{
|
||||
/* Convert LVGL log level to Zephyr log level
|
||||
/*
|
||||
* This is ugly and should be done in a loop or something but as it
|
||||
* turned out, Z_LOG()'s first argument (that specifies the log level)
|
||||
* cannot be an l-value...
|
||||
*
|
||||
* LVGL log level mapping:
|
||||
* * LV_LOG_LEVEL_TRACE 0
|
||||
* * LV_LOG_LEVEL_INFO 1
|
||||
* * LV_LOG_LEVEL_WARN 2
|
||||
* * LV_LOG_LEVEL_ERROR 3
|
||||
* * LV_LOG_LEVEL_NUM 4
|
||||
*
|
||||
* Zephyr log level mapping:
|
||||
* * LOG_LEVEL_NONE 0
|
||||
* * LOG_LEVEL_ERR 1
|
||||
* * LOG_LEVEL_WRN 2
|
||||
* * LOG_LEVEL_INF 3
|
||||
* * LOG_LEVEL_DBG 4
|
||||
* We also assume lvgl is sane and always supplies the level string.
|
||||
*/
|
||||
char *dupdsc = log_strdup(dsc);
|
||||
|
||||
ARG_UNUSED(file);
|
||||
ARG_UNUSED(line);
|
||||
ARG_UNUSED(func);
|
||||
|
||||
switch (level) {
|
||||
case LV_LOG_LEVEL_TRACE:
|
||||
Z_LOG(LOG_LEVEL_DBG, "%s", dupdsc);
|
||||
switch (buf[1]) {
|
||||
case 'E':
|
||||
LOG_ERR("%s", log_strdup(buf + strlen("[Error] ")));
|
||||
break;
|
||||
case LV_LOG_LEVEL_INFO:
|
||||
Z_LOG(LOG_LEVEL_INF, "%s", dupdsc);
|
||||
case 'W':
|
||||
LOG_WRN("%s", log_strdup(buf + strlen("Warn] ")));
|
||||
break;
|
||||
case LV_LOG_LEVEL_WARN:
|
||||
Z_LOG(LOG_LEVEL_WRN, "%s", dupdsc);
|
||||
case 'I':
|
||||
LOG_INF("%s", log_strdup(buf + strlen("[Info] ")));
|
||||
break;
|
||||
case LV_LOG_LEVEL_ERROR:
|
||||
Z_LOG(LOG_LEVEL_ERR, "%s", dupdsc);
|
||||
case 'T':
|
||||
LOG_DBG("%s", log_strdup(buf + strlen("[Trace] ")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -107,11 +103,11 @@ static int lvgl_allocate_rendering_buffers(lv_disp_drv_t *disp_drv)
|
|||
err = -ENOTSUP;
|
||||
}
|
||||
|
||||
disp_drv->buffer = &disp_buf;
|
||||
disp_drv->draw_buf = &disp_buf;
|
||||
#ifdef CONFIG_LVGL_DOUBLE_VDB
|
||||
lv_disp_buf_init(disp_drv->buffer, &buf0, &buf1, NBR_PIXELS_IN_BUFFER);
|
||||
lv_disp_draw_buf_init(disp_drv->draw_buf, &buf0, &buf1, NBR_PIXELS_IN_BUFFER);
|
||||
#else
|
||||
lv_disp_buf_init(disp_drv->buffer, &buf0, NULL, NBR_PIXELS_IN_BUFFER);
|
||||
lv_disp_draw_buf_init(disp_drv->draw_buf, &buf0, NULL, NBR_PIXELS_IN_BUFFER);
|
||||
#endif /* CONFIG_LVGL_DOUBLE_VDB */
|
||||
|
||||
return err;
|
||||
|
@ -174,15 +170,15 @@ static int lvgl_allocate_rendering_buffers(lv_disp_drv_t *disp_drv)
|
|||
}
|
||||
#endif
|
||||
|
||||
disp_drv->buffer = LV_MEM_CUSTOM_ALLOC(sizeof(lv_disp_buf_t));
|
||||
if (disp_drv->buffer == NULL) {
|
||||
disp_drv->draw_buf = LV_MEM_CUSTOM_ALLOC(sizeof(lv_disp_draw_buf_t));
|
||||
if (disp_drv->draw_buf == NULL) {
|
||||
LV_MEM_CUSTOM_FREE(buf0);
|
||||
LV_MEM_CUSTOM_FREE(buf1);
|
||||
LOG_ERR("Failed to allocate memory to store rendering buffers");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
lv_disp_buf_init(disp_drv->buffer, buf0, buf1, buf_nbr_pixels);
|
||||
lv_disp_draw_buf_init(disp_drv->draw_buf, buf0, buf1, buf_nbr_pixels);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_LVGL_BUFFER_ALLOC_STATIC */
|
||||
|
@ -206,7 +202,7 @@ static void lvgl_pointer_kscan_callback(const struct device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
static bool lvgl_pointer_kscan_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
static void lvgl_pointer_kscan_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
{
|
||||
lv_disp_t *disp;
|
||||
const struct device *disp_dev;
|
||||
|
@ -226,7 +222,7 @@ static bool lvgl_pointer_kscan_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
|||
prev = curr;
|
||||
|
||||
disp = lv_disp_get_default();
|
||||
disp_dev = disp->driver.user_data;
|
||||
disp_dev = disp->driver->user_data;
|
||||
|
||||
display_get_capabilities(disp_dev, &cap);
|
||||
|
||||
|
@ -278,7 +274,7 @@ static bool lvgl_pointer_kscan_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
|||
set_and_release:
|
||||
*data = prev;
|
||||
|
||||
return k_msgq_num_used_get(&kscan_msgq) > 0;
|
||||
k_msgq_num_used_get(&kscan_msgq);
|
||||
}
|
||||
|
||||
static int lvgl_pointer_kscan_init(void)
|
||||
|
@ -286,8 +282,6 @@ static int lvgl_pointer_kscan_init(void)
|
|||
const struct device *kscan_dev =
|
||||
device_get_binding(CONFIG_LVGL_POINTER_KSCAN_DEV_NAME);
|
||||
|
||||
lv_indev_drv_t indev_drv;
|
||||
|
||||
if (kscan_dev == NULL) {
|
||||
LOG_ERR("Keyboard scan device not found.");
|
||||
return -ENODEV;
|
||||
|
@ -320,7 +314,6 @@ static int lvgl_init(const struct device *dev)
|
|||
const struct device *display_dev =
|
||||
device_get_binding(CONFIG_LVGL_DISPLAY_DEV_NAME);
|
||||
int err = 0;
|
||||
lv_disp_drv_t disp_drv;
|
||||
|
||||
if (display_dev == NULL) {
|
||||
LOG_ERR("Display device not found.");
|
||||
|
|
|
@ -14,29 +14,29 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lvgl_flush_cb_mono(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_mono(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p);
|
||||
void lvgl_flush_cb_16bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_16bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p);
|
||||
void lvgl_flush_cb_24bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_24bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p);
|
||||
void lvgl_flush_cb_32bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_32bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p);
|
||||
|
||||
void lvgl_set_px_cb_mono(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_mono(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void lvgl_set_px_cb_16bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_16bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void lvgl_set_px_cb_24bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_24bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void lvgl_set_px_cb_32bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_32bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
void lvgl_rounder_cb_mono(struct _disp_drv_t *disp_drv, lv_area_t *area);
|
||||
void lvgl_rounder_cb_mono(lv_disp_drv_t *disp_drv, lv_area_t *area);
|
||||
|
||||
int set_lvgl_rendering_cb(lv_disp_drv_t *disp_drv);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <lvgl.h>
|
||||
#include "lvgl_display.h"
|
||||
|
||||
void lvgl_flush_cb_16bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_16bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
const struct device *display_dev = (const struct device *)disp_drv->user_data;
|
||||
|
@ -26,7 +26,7 @@ void lvgl_flush_cb_16bit(struct _disp_drv_t *disp_drv,
|
|||
}
|
||||
|
||||
#ifndef CONFIG_LVGL_COLOR_DEPTH_16
|
||||
void lvgl_set_px_cb_16bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_16bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <lvgl.h>
|
||||
#include "lvgl_display.h"
|
||||
|
||||
void lvgl_flush_cb_24bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_24bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
const struct device *display_dev = (const struct device *)disp_drv->user_data;
|
||||
|
@ -25,7 +25,7 @@ void lvgl_flush_cb_24bit(struct _disp_drv_t *disp_drv,
|
|||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
void lvgl_set_px_cb_24bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_24bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <lvgl.h>
|
||||
#include "lvgl_display.h"
|
||||
|
||||
void lvgl_flush_cb_32bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_32bit(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
const struct device *display_dev = (const struct device *)disp_drv->user_data;
|
||||
|
@ -26,7 +26,7 @@ void lvgl_flush_cb_32bit(struct _disp_drv_t *disp_drv,
|
|||
}
|
||||
|
||||
#ifndef CONFIG_LVGL_COLOR_DEPTH_32
|
||||
void lvgl_set_px_cb_32bit(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_32bit(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <lvgl.h>
|
||||
#include "lvgl_display.h"
|
||||
|
||||
void lvgl_flush_cb_mono(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_flush_cb_mono(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
uint16_t w = area->x2 - area->x1 + 1;
|
||||
|
@ -33,7 +33,7 @@ void lvgl_flush_cb_mono(struct _disp_drv_t *disp_drv,
|
|||
}
|
||||
|
||||
|
||||
void lvgl_set_px_cb_mono(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_set_px_cb_mono(lv_disp_drv_t *disp_drv,
|
||||
uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ void lvgl_set_px_cb_mono(struct _disp_drv_t *disp_drv,
|
|||
}
|
||||
}
|
||||
|
||||
void lvgl_rounder_cb_mono(struct _disp_drv_t *disp_drv,
|
||||
void lvgl_rounder_cb_mono(lv_disp_drv_t *disp_drv,
|
||||
lv_area_t *area)
|
||||
{
|
||||
const struct device *display_dev = (const struct device *)disp_drv->user_data;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <lvgl.h>
|
||||
#include <zephyr.h>
|
||||
#include <fs/fs.h>
|
||||
#include <stdlib.h>
|
||||
#include "lvgl_fs.h"
|
||||
|
||||
static bool lvgl_fs_ready(struct _lv_fs_drv_t *drv)
|
||||
|
@ -48,11 +49,12 @@ static lv_fs_res_t errno_to_lv_fs_res(int err)
|
|||
}
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_open(struct _lv_fs_drv_t *drv, void *file,
|
||||
const char *path, lv_fs_mode_t mode)
|
||||
static void *lvgl_fs_open(struct _lv_fs_drv_t *drv, const char *path,
|
||||
lv_fs_mode_t mode)
|
||||
{
|
||||
int err;
|
||||
int zmode = FS_O_CREATE;
|
||||
void *file;
|
||||
|
||||
/* LVGL is passing absolute paths without the root slash add it back
|
||||
* by decrementing the path pointer.
|
||||
|
@ -62,8 +64,15 @@ static lv_fs_res_t lvgl_fs_open(struct _lv_fs_drv_t *drv, void *file,
|
|||
zmode |= (mode & LV_FS_MODE_WR) ? FS_O_WRITE : 0;
|
||||
zmode |= (mode & LV_FS_MODE_RD) ? FS_O_READ : 0;
|
||||
|
||||
file = malloc(sizeof(struct fs_file_t));
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
err = fs_open((struct fs_file_t *)file, path, zmode);
|
||||
return errno_to_lv_fs_res(err);
|
||||
if (err)
|
||||
return NULL;
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_close(struct _lv_fs_drv_t *drv, void *file)
|
||||
|
@ -74,19 +83,6 @@ static lv_fs_res_t lvgl_fs_close(struct _lv_fs_drv_t *drv, void *file)
|
|||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_remove(struct _lv_fs_drv_t *drv, const char *path)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* LVGL is passing absolute paths without the root slash add it back
|
||||
* by decrementing the path pointer.
|
||||
*/
|
||||
path--;
|
||||
|
||||
err = fs_unlink(path);
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_read(struct _lv_fs_drv_t *drv, void *file,
|
||||
void *buf, uint32_t btr, uint32_t *br)
|
||||
{
|
||||
|
@ -128,7 +124,8 @@ static lv_fs_res_t lvgl_fs_write(struct _lv_fs_drv_t *drv, void *file,
|
|||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_seek(struct _lv_fs_drv_t *drv, void *file, uint32_t pos)
|
||||
static lv_fs_res_t lvgl_fs_seek(struct _lv_fs_drv_t *drv, void *file,
|
||||
uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -143,70 +140,9 @@ static lv_fs_res_t lvgl_fs_tell(struct _lv_fs_drv_t *drv, void *file,
|
|||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_trunc(struct _lv_fs_drv_t *drv, void *file)
|
||||
{
|
||||
int err;
|
||||
off_t length;
|
||||
|
||||
length = fs_tell((struct fs_file_t *) file);
|
||||
++length;
|
||||
err = fs_truncate((struct fs_file_t *)file, length);
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_size(struct _lv_fs_drv_t *drv, void *file,
|
||||
uint32_t *fsize)
|
||||
{
|
||||
int err;
|
||||
off_t org_pos;
|
||||
|
||||
/* LVGL does not provided path but pointer to file struct as such
|
||||
* we can not use fs_stat, instead use a combination of fs_tell and
|
||||
* fs_seek to get the files size.
|
||||
*/
|
||||
|
||||
org_pos = fs_tell((struct fs_file_t *) file);
|
||||
|
||||
err = fs_seek((struct fs_file_t *) file, 0, FS_SEEK_END);
|
||||
if (err != 0) {
|
||||
*fsize = 0U;
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
*fsize = fs_tell((struct fs_file_t *) file) + 1;
|
||||
|
||||
err = fs_seek((struct fs_file_t *) file, org_pos, FS_SEEK_SET);
|
||||
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_rename(struct _lv_fs_drv_t *drv, const char *from,
|
||||
const char *to)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* LVGL is passing absolute paths without the root slash add it back
|
||||
* by decrementing the path pointer.
|
||||
*/
|
||||
from--;
|
||||
to--;
|
||||
|
||||
err = fs_rename(from, to);
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_free(struct _lv_fs_drv_t *drv, uint32_t *total_p,
|
||||
uint32_t *free_p)
|
||||
{
|
||||
/* We have no easy way of telling the total file system size.
|
||||
* Zephyr can only return this information per mount point.
|
||||
*/
|
||||
return LV_FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_dir_open(struct _lv_fs_drv_t *drv, void *dir,
|
||||
const char *path)
|
||||
static void *lvgl_fs_dir_open(struct _lv_fs_drv_t *drv, const char *path)
|
||||
{
|
||||
void *dir;
|
||||
int err;
|
||||
|
||||
/* LVGL is passing absolute paths without the root slash add it back
|
||||
|
@ -214,9 +150,16 @@ static lv_fs_res_t lvgl_fs_dir_open(struct _lv_fs_drv_t *drv, void *dir,
|
|||
*/
|
||||
path--;
|
||||
|
||||
dir = malloc(sizeof(struct fs_dir_t));
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
fs_dir_t_init((struct fs_dir_t *)dir);
|
||||
err = fs_opendir((struct fs_dir_t *)dir, path);
|
||||
return errno_to_lv_fs_res(err);
|
||||
if (err)
|
||||
return NULL;
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
static lv_fs_res_t lvgl_fs_dir_read(struct _lv_fs_drv_t *drv, void *dir,
|
||||
|
@ -233,16 +176,16 @@ static lv_fs_res_t lvgl_fs_dir_close(struct _lv_fs_drv_t *drv, void *dir)
|
|||
int err;
|
||||
|
||||
err = fs_closedir((struct fs_dir_t *)dir);
|
||||
free(dir);
|
||||
return errno_to_lv_fs_res(err);
|
||||
}
|
||||
|
||||
static lv_fs_drv_t fs_drv;
|
||||
|
||||
void lvgl_fs_init(void)
|
||||
{
|
||||
lv_fs_drv_t fs_drv;
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
fs_drv.file_size = sizeof(struct fs_file_t);
|
||||
fs_drv.rddir_size = sizeof(struct fs_dir_t);
|
||||
/* LVGL uses letter based mount points, just pass the root slash as a
|
||||
* letter. Note that LVGL will remove the drive letter, or in this case
|
||||
* the root slash, from the path passed via the FS callbacks.
|
||||
|
@ -254,15 +197,10 @@ void lvgl_fs_init(void)
|
|||
|
||||
fs_drv.open_cb = lvgl_fs_open;
|
||||
fs_drv.close_cb = lvgl_fs_close;
|
||||
fs_drv.remove_cb = lvgl_fs_remove;
|
||||
fs_drv.read_cb = lvgl_fs_read;
|
||||
fs_drv.write_cb = lvgl_fs_write;
|
||||
fs_drv.seek_cb = lvgl_fs_seek;
|
||||
fs_drv.tell_cb = lvgl_fs_tell;
|
||||
fs_drv.trunc_cb = lvgl_fs_trunc;
|
||||
fs_drv.size_cb = lvgl_fs_size;
|
||||
fs_drv.rename_cb = lvgl_fs_rename;
|
||||
fs_drv.free_space_cb = lvgl_fs_free;
|
||||
|
||||
fs_drv.dir_open_cb = lvgl_fs_dir_open;
|
||||
fs_drv.dir_read_cb = lvgl_fs_dir_read;
|
||||
|
|
|
@ -32,19 +32,18 @@ void main(void)
|
|||
if (IS_ENABLED(CONFIG_LVGL_POINTER_KSCAN)) {
|
||||
lv_obj_t *hello_world_button;
|
||||
|
||||
hello_world_button = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(hello_world_button, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_btn_set_fit(hello_world_button, LV_FIT_TIGHT);
|
||||
hello_world_label = lv_label_create(hello_world_button, NULL);
|
||||
hello_world_button = lv_btn_create(lv_scr_act());
|
||||
lv_obj_align(hello_world_button, LV_ALIGN_CENTER, 0, 0);
|
||||
hello_world_label = lv_label_create(hello_world_button);
|
||||
} else {
|
||||
hello_world_label = lv_label_create(lv_scr_act(), NULL);
|
||||
hello_world_label = lv_label_create(lv_scr_act());
|
||||
}
|
||||
|
||||
lv_label_set_text(hello_world_label, "Hello world!");
|
||||
lv_obj_align(hello_world_label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_align(hello_world_label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
count_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(count_label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
count_label = lv_label_create(lv_scr_act());
|
||||
lv_obj_align(count_label, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
|
||||
lv_task_handler();
|
||||
display_blanking_off(display_dev);
|
||||
|
|
|
@ -14,7 +14,7 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y
|
|||
CONFIG_LVGL=y
|
||||
# Make sure that the rendering task is always executed if we call
|
||||
# lv_task_handler by setting the refresh period to zero
|
||||
CONFIG_LVGL_DISP_DEF_REFR_PERIOD=0
|
||||
CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS=8
|
||||
CONFIG_LVGL_COLOR_SCREEN_TRANSP=y
|
||||
CONFIG_LVGL_ANTIALIAS=y
|
||||
CONFIG_LVGL_USE_ANIMATION=y
|
||||
|
|
|
@ -36,7 +36,7 @@ void test_add_delete_screen(void)
|
|||
|
||||
zassert_not_null(default_screen, "No default screen");
|
||||
|
||||
lv_obj_t *new_screen = lv_obj_create(NULL, NULL);
|
||||
lv_obj_t *new_screen = lv_obj_create(NULL);
|
||||
|
||||
zassert_not_null(new_screen, "Failed to create new screen");
|
||||
|
||||
|
@ -61,12 +61,12 @@ void test_add_delete_screen(void)
|
|||
}
|
||||
void test_add_img(void)
|
||||
{
|
||||
lv_obj_t *img = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t *img = lv_img_create(lv_scr_act());
|
||||
|
||||
zassert_not_null(img, "Failed to create image");
|
||||
|
||||
lv_img_set_src(img, IMG_FILE_PATH);
|
||||
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_task_handler();
|
||||
}
|
||||
|
|
2
west.yml
2
west.yml
|
@ -162,7 +162,7 @@ manifest:
|
|||
revision: 12019623bbad9eb54fe51066847a7cbd4b4eac57
|
||||
path: modules/lib/loramac-node
|
||||
- name: lvgl
|
||||
revision: 783c1f78c8e39751fe89d0883c8bce7336f55e94
|
||||
revision: aae1c11102138cf596687e662c0d54b72f72bf9b
|
||||
path: modules/lib/gui/lvgl
|
||||
- name: lz4
|
||||
revision: 8e303c264fc21c2116dc612658003a22e933124d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue