From bab49e520d6ffad84df82a57d7d3bf40c6ff3cd8 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 28 Feb 2022 09:22:36 +0100 Subject: [PATCH] pkg/lv_drivers: initial commit --- pkg/Kconfig | 1 + pkg/lv_drivers/Kconfig | 22 ++++++ pkg/lv_drivers/Makefile | 18 +++++ pkg/lv_drivers/Makefile.dep | 5 ++ pkg/lv_drivers/Makefile.include | 20 ++++++ pkg/lv_drivers/Makefile.lv_drivers_module | 12 ++++ pkg/lv_drivers/doc.txt | 36 ++++++++++ pkg/lv_drivers/include/lv_drv_conf.h | 84 +++++++++++++++++++++++ 8 files changed, 198 insertions(+) create mode 100644 pkg/lv_drivers/Kconfig create mode 100644 pkg/lv_drivers/Makefile create mode 100644 pkg/lv_drivers/Makefile.dep create mode 100644 pkg/lv_drivers/Makefile.include create mode 100644 pkg/lv_drivers/Makefile.lv_drivers_module create mode 100644 pkg/lv_drivers/doc.txt create mode 100644 pkg/lv_drivers/include/lv_drv_conf.h diff --git a/pkg/Kconfig b/pkg/Kconfig index f44e88d899..a033da3e6d 100644 --- a/pkg/Kconfig +++ b/pkg/Kconfig @@ -32,6 +32,7 @@ rsource "libcose/Kconfig" rsource "libfixmath/Kconfig" rsource "libhydrogen/Kconfig" rsource "lora-serialization/Kconfig" +rsource "lv_drivers/Kconfig" rsource "lvgl/Kconfig" rsource "lz4/Kconfig" rsource "mbedtls/Kconfig" diff --git a/pkg/lv_drivers/Kconfig b/pkg/lv_drivers/Kconfig new file mode 100644 index 0000000000..f6c5eee1a8 --- /dev/null +++ b/pkg/lv_drivers/Kconfig @@ -0,0 +1,22 @@ +# Copyright (c) 2022 Inria +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig PACKAGE_LV_DRIVERS + bool "LVGL Drivers Package" + depends on TEST_KCONFIG + depends on PACKAGE_LVGL + +config MODULE_LV_DRIVERS_SDL + bool "Monitor driver" + depends on HAS_ARCH_NATIVE + select PACKAGE_LV_DRIVERS + +config HAVE_SDL + bool + select MODULE_LV_DRIVERS_SDL if PACKAGE_LVGL + help + Indicates a display monitor is present diff --git a/pkg/lv_drivers/Makefile b/pkg/lv_drivers/Makefile new file mode 100644 index 0000000000..6d309fe60c --- /dev/null +++ b/pkg/lv_drivers/Makefile @@ -0,0 +1,18 @@ +PKG_NAME=lv_drivers +PKG_URL=https://github.com/lvgl/lv_drivers.git +PKG_VERSION=49c4b178494625efefb07891d1c8b9c13914edff # 8.2.0 +PKG_LICENSE=MIT + +include $(RIOTBASE)/pkg/pkg.mk + +IGNORE_MODULES := \ + # + +LV_DRIVERS_MODULES := $(filter-out $(IGNORE_MODULES),$(filter lv_drivers_%,$(USEMODULE))) + +.PHONY: lvgl_% + +all: $(LV_DRIVERS_MODULES) + +lv_drivers_sdl: + "$(MAKE)" -C $(PKG_SOURCE_DIR)/sdl -f $(CURDIR)/Makefile.lv_drivers_module MODULE=$@ SRC=sdl.c diff --git a/pkg/lv_drivers/Makefile.dep b/pkg/lv_drivers/Makefile.dep new file mode 100644 index 0000000000..8261359bdb --- /dev/null +++ b/pkg/lv_drivers/Makefile.dep @@ -0,0 +1,5 @@ +USEPKG += lvgl + +ifneq (,$(filter lv_drivers_sdl,$(USEMODULE))) + FEATURES_REQUIRED += arch_native +endif diff --git a/pkg/lv_drivers/Makefile.include b/pkg/lv_drivers/Makefile.include new file mode 100644 index 0000000000..1f192e2d21 --- /dev/null +++ b/pkg/lv_drivers/Makefile.include @@ -0,0 +1,20 @@ +INCLUDES += -I$(PKGDIRBASE)/lv_drivers \ + -I$(RIOTBASE)/pkg/lv_drivers/include \ + # + +# Don't use relative includes in lv_drivers, already set in LVGL package +# CFLAGS += -DLV_CONF_INCLUDE_SIMPLE + +# lv_drivers module is not a concrete module, so declare it as a pseudomodule +PSEUDOMODULES += lv_drivers + +ifneq (,$(filter lv_drivers_sdl,$(USEMODULE))) + SDL_LINKFLAGS = $(call memoized,SDL_LINKFLAGS,$(shell sdl2-config --libs)) + LINKFLAGS += $(SDL_LINKFLAGS) + SDL_CFLAGS = $(call memoized,SDL_CFLAGS,$(shell sdl2-config --cflags)) + CFLAGS += $(SDL_CFLAGS) + # add SDL to the include path + SDL_INCLUDE_PATH = $(call memoized,SDL_INCLUDE_PATH,$(shell \ + sdl2-config --cflags | tr ' ' '\n' | grep '^-I' | cut -c3- | head -n1)) + CFLAGS += -DSDL_INCLUDE_PATH="<$(SDL_INCLUDE_PATH)/SDL.h>" +endif diff --git a/pkg/lv_drivers/Makefile.lv_drivers_module b/pkg/lv_drivers/Makefile.lv_drivers_module new file mode 100644 index 0000000000..fd6be82cba --- /dev/null +++ b/pkg/lv_drivers/Makefile.lv_drivers_module @@ -0,0 +1,12 @@ +CFLAGS += -Wno-unused-parameter +CFLAGS += -Wno-sign-compare +CFLAGS += -Wno-unused-function +CFLAGS += -Wno-maybe-uninitialized + +ifeq (llvm,$(TOOLCHAIN)) + CFLAGS += -Wno-empty-translation-unit + CFLAGS += -Wno-newline-eof + CFLAGS += -Wno-missing-braces +endif + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/lv_drivers/doc.txt b/pkg/lv_drivers/doc.txt new file mode 100644 index 0000000000..d34dece322 --- /dev/null +++ b/pkg/lv_drivers/doc.txt @@ -0,0 +1,36 @@ +/** +@defgroup pkg_lv_drivers LittlevGL Drivers +@ingroup pkg +@brief Display controller and touchpad driver to can be directly used with + LittlevGL. + +@note This package needs the 32bit version of SDL2 + +@see https://github.com/lvgl/lv_drivers + +## Configuration options + +To change the size of the screen `SDL_HOR_RES` and `SDL_VER_RES` can be changed +via `CFLAGS` or in `lv_drv_conf.h`. + +For small screen a zoom factor can be applied through `SDL_ZOOM`, e.g: `SDL_ZOOM=2` +will apply a x2 zoom to the display. + +### SDL Requirements + +To run lvgl inside a simulator (native), SDL2 is required. Install instructions +can be found at https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html#install-sdl-2, +note that the 32bit version is needed. + +On debian/ubuntu this could be as simple as installing the `libsdl2-dev:i386` package. + +Using SDL2 requires more stack so in case you are using it add + +``` +CFLAGS += '-DTHREAD_STACKSIZE_MAIN=48*1024' +``` + +to your makefile. 48kB is enough for the test, other uses may need more or may +need this to be applied to other threads using `THREAD_STACKSIZE_DEFAULT` + + */ diff --git a/pkg/lv_drivers/include/lv_drv_conf.h b/pkg/lv_drivers/include/lv_drv_conf.h new file mode 100644 index 0000000000..e61d9da198 --- /dev/null +++ b/pkg/lv_drivers/include/lv_drv_conf.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2022 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup pkg_lv_drivers + * @brief LittlevGL Drivers SDL2 configuration headers + * + * @note Based on upstream lv_drv_conf_template.h. + * @{ + * + * @author Francisco Molina + */ + +#ifndef LV_DRV_CONF_H +#define LV_DRV_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "kernel_defines.h" +#include "lvgl_riot_conf.h" + +/********************* +* DISPLAY DRIVERS +*********************/ + +/*------------------- + * SDL + *-------------------*/ + +/** + * @brief Internal flag to enable LittlevGL SDL2 based drivers for display, mouse, + * mousewheel and keyboard + */ +#define USE_SDL IS_USED(MODULE_LV_DRIVERS_SDL) +/** + * @brief LittlevGL SDL2 display horizontal resolution + */ +#ifndef SDL_HOR_RES +#define SDL_HOR_RES 320 +#endif +/** + * @brief LittlevGL SDL2 display vertical resolution + */ +#ifndef SDL_VER_RES +#define SDL_VER_RES 240 +#endif +/** + * @brief LittlevGL display horizontal resolution + */ +#define LV_HOR_RES SDL_HOR_RES +/** + * @brief LittlevGL display vertical resolution + */ +#define LV_VER_RES SDL_VER_RES +/** + * @brief Enable Scale window by this factor (useful when simulating small screens) + */ +#ifndef SDL_ZOOM +#define SDL_ZOOM 1 +#endif +/** + * @brief Used to test true double buffering with only address changing. + * Use 2 draw buffers, both with SDL_HOR_RES x SDL_VER_RES size + */ +#define SDL_DOUBLE_BUFFERED 0 +/** + * @brief Open two windows to test multi display support + */ +#define SDL_DUAL_DISPLAY 0 + +#ifdef __cplusplus +} +#endif + +#endif /* LV_DRV_CONF_H */ +/** @} */