From a610b633d297c806c74e9b6e56ee2fd121aec261 Mon Sep 17 00:00:00 2001 From: pengyiqiang Date: Sat, 8 Oct 2022 17:03:06 +0800 Subject: [PATCH] graphics/lvgl: Upgrade to lvgl v8 version Signed-off-by: pengyiqiang --- examples/lvgldemo/Kconfig | 94 +- examples/lvgldemo/Makefile | 69 +- examples/lvgldemo/fbdev.c | 469 ------- examples/lvgldemo/fbdev.h | 46 - examples/lvgldemo/lcddev.c | 315 ----- examples/lvgldemo/lv_ex_conf.h | 72 -- examples/lvgldemo/lvgldemo.c | 213 ++-- examples/lvgldemo/tp.c | 279 ----- examples/lvgldemo/tp.h | 129 -- examples/lvgldemo/tp_cal.c | 332 ----- graphics/lvgl/Kconfig | 612 +++------ graphics/lvgl/Make.defs | 4 - graphics/lvgl/Makefile | 65 +- graphics/lvgl/lv_conf.h | 1052 ---------------- graphics/lvgl/lv_conf/Kconfig | 1115 +++++++++++++++++ graphics/lvgl/lv_fs_interface.c | 575 --------- graphics/lvgl/port/lv_port.c | 91 ++ .../{lv_fs_interface.h => port/lv_port.h} | 25 +- graphics/lvgl/port/lv_port_button.c | 238 ++++ graphics/lvgl/port/lv_port_button.h | 80 ++ graphics/lvgl/port/lv_port_encoder.c | 162 +++ graphics/lvgl/port/lv_port_encoder.h | 80 ++ graphics/lvgl/port/lv_port_fbdev.c | 673 ++++++++++ graphics/lvgl/port/lv_port_fbdev.h | 80 ++ graphics/lvgl/port/lv_port_keypad.c | 251 ++++ graphics/lvgl/port/lv_port_keypad.h | 76 ++ graphics/lvgl/port/lv_port_lcddev.c | 302 +++++ graphics/lvgl/port/lv_port_lcddev.h | 82 ++ graphics/lvgl/port/lv_port_mem.c | 173 +++ graphics/lvgl/port/lv_port_mem.h | 92 ++ .../lvgl/port/lv_port_syslog.c | 41 +- .../lvgl/port/lv_port_syslog.h | 56 +- .../lv_port_tick.c} | 28 +- .../lv_port_tick.h} | 11 +- graphics/lvgl/port/lv_port_touchpad.c | 178 +++ graphics/lvgl/port/lv_port_touchpad.h | 80 ++ 36 files changed, 4169 insertions(+), 4071 deletions(-) delete mode 100644 examples/lvgldemo/fbdev.c delete mode 100644 examples/lvgldemo/fbdev.h delete mode 100644 examples/lvgldemo/lcddev.c delete mode 100644 examples/lvgldemo/lv_ex_conf.h delete mode 100644 examples/lvgldemo/tp.c delete mode 100644 examples/lvgldemo/tp.h delete mode 100644 examples/lvgldemo/tp_cal.c delete mode 100644 graphics/lvgl/lv_conf.h create mode 100644 graphics/lvgl/lv_conf/Kconfig delete mode 100644 graphics/lvgl/lv_fs_interface.c create mode 100644 graphics/lvgl/port/lv_port.c rename graphics/lvgl/{lv_fs_interface.h => port/lv_port.h} (82%) create mode 100644 graphics/lvgl/port/lv_port_button.c create mode 100644 graphics/lvgl/port/lv_port_button.h create mode 100644 graphics/lvgl/port/lv_port_encoder.c create mode 100644 graphics/lvgl/port/lv_port_encoder.h create mode 100644 graphics/lvgl/port/lv_port_fbdev.c create mode 100644 graphics/lvgl/port/lv_port_fbdev.h create mode 100644 graphics/lvgl/port/lv_port_keypad.c create mode 100644 graphics/lvgl/port/lv_port_keypad.h create mode 100644 graphics/lvgl/port/lv_port_lcddev.c create mode 100644 graphics/lvgl/port/lv_port_lcddev.h create mode 100644 graphics/lvgl/port/lv_port_mem.c create mode 100644 graphics/lvgl/port/lv_port_mem.h rename examples/lvgldemo/lcddev.h => graphics/lvgl/port/lv_port_syslog.c (59%) rename examples/lvgldemo/tp_cal.h => graphics/lvgl/port/lv_port_syslog.h (54%) rename graphics/lvgl/{lv_tick_interface.c => port/lv_port_tick.c} (82%) rename graphics/lvgl/{lv_tick_interface.h => port/lv_port_tick.h} (89%) create mode 100644 graphics/lvgl/port/lv_port_touchpad.c create mode 100644 graphics/lvgl/port/lv_port_touchpad.h diff --git a/examples/lvgldemo/Kconfig b/examples/lvgldemo/Kconfig index cbd642684..00f6b250f 100644 --- a/examples/lvgldemo/Kconfig +++ b/examples/lvgldemo/Kconfig @@ -12,104 +12,12 @@ menuconfig EXAMPLES_LVGLDEMO if EXAMPLES_LVGLDEMO -config EXAMPLES_LVGLDEMO_BUFF_SIZE - int "Display buffer size (in line)" - default 20 - -config EXAMPLES_LVGLDEMO_DOUBLE_BUFFERING - bool "Enable double buffering" - default n - ---help--- - When double buffering is enabled, LVGL expects the size of both - buffers as: - CONFIG_LV_HOR_RES * CONFIG_EXAMPLES_LVGLDEMO_BUFF_SIZE. - True double buffering support is enabled if both buffers have the - same dimensions as the display device resolution. Otherwise, - LVGL will perform a number of partial refreshes according to the - defined buffer size. - -config EXAMPLES_LVGLDEMO_ASYNC_FLUSH - bool "Flush the display buffer asynchronously" - default n - ---help--- - Enable this option to perform an asynchronous write of the buffer - contents to the display device. - -choice - prompt "Select a demo application" - default EXAMPLES_LVGLDEMO_WIDGETS - -config EXAMPLES_LVGLDEMO_BENCHMARK - bool "Benchmark" - -config EXAMPLES_LVGLDEMO_PRINTER - bool "Printer" - ---help--- - This demo is optimized for 800 * 480 resolution - -config EXAMPLES_LVGLDEMO_STRESS - bool "Stress" - -config EXAMPLES_LVGLDEMO_WIDGETS - bool "Widgets" - -endchoice - -if EXAMPLES_LVGLDEMO_WIDGETS - -config EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW - bool "Enable Slideshow mode for Widgets example" - default n - ---help--- - Slideshow mode consists of a non-interactive demonstration of the - Widgets example. - -endif # EXAMPLES_LVGLDEMO_WIDGETS - config EXAMPLES_LVGLDEMO_PRIORITY - int "lvgl task priority" + int "lvgldemo task priority" default 100 config EXAMPLES_LVGLDEMO_STACKSIZE int "lvgldemo stack size" default 16384 -comment "Input configuration options" - depends on INPUT_TOUCHSCREEN || INPUT_MOUSE - -config EXAMPLES_LVGLDEMO_CALIBRATE - bool "Calibrate touchscreen" - default y - depends on INPUT_TOUCHSCREEN || INPUT_MOUSE - ---help--- - Calibrate touchscreen before demo start, but some touchscreen - don't need it, like capacitive touchscreen. - -if INPUT_TOUCHSCREEN - -config EXAMPLES_LVGLDEMO_MINOR - int "Touchscreen minor device number" - default 0 - ---help--- - The minor device number. Minor=N corresponds to touchscreen device - /dev/inputN. Note this value must with EXAMPLES_LVGLDEMO_DEVPATH. - Default 0. - -config EXAMPLES_LVGLDEMO_DEVPATH - string "Touchscreen device path" - default "/dev/input0" - ---help--- - The path to the touchscreen device. This must be consistent with - EXAMPLES_LVGLDEMO_MINOR. Default: "/dev/input0" - -endif # INPUT_TOUCHSCREEN - -config EXAMPLES_LVGLDEMO_MOUSE - bool "Mouse interface" - default n - depends on INPUT_MOUSE - ---help--- - The LittleVGL demo can also be configured to work with a mouse - driver by setting this option. - endif # EXAMPLES_LVGLDEMO diff --git a/examples/lvgldemo/Makefile b/examples/lvgldemo/Makefile index 9a903a468..65e0b5a95 100644 --- a/examples/lvgldemo/Makefile +++ b/examples/lvgldemo/Makefile @@ -20,80 +20,13 @@ include $(APPDIR)/Make.defs -# LittleVGL demo built-in application info - -CONFIG_LV_EXAMPLES_URL ?= https://github.com/lvgl/lv_demos/archive - -LVGL_EXAMPLES_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LVGL_VERSION))) -LVGL_EXAMPLES_TARBALL = v$(LVGL_EXAMPLES_VERSION).zip - -LVGL_EXAMPLES_UNPACKNAME = lv_demos -UNPACK ?= unzip -o - PROGNAME = lvgldemo PRIORITY = $(CONFIG_EXAMPLES_LVGLDEMO_PRIORITY) STACKSIZE = $(CONFIG_EXAMPLES_LVGLDEMO_STACKSIZE) MODULE = $(CONFIG_EXAMPLES_LVGLDEMO) -# LittleVGL demo Example - -CSRCS += fbdev.c lcddev.c - -ifneq ($(CONFIG_INPUT_TOUCHSCREEN)$(CONFIG_INPUT_MOUSE),) -CSRCS += tp.c tp_cal.c -endif - -# static common assets used in multiple examples - -LV_EXAMPLE_ASSETS = $(wildcard ./lv_demos/assets/*.c) -CSRCS += $(notdir $(LV_EXAMPLE_ASSETS)) -VPATH += lv_demos/assets - -ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_BENCHMARK),) -CSRCS += lv_demo_benchmark.c -VPATH += lv_demos/src/lv_demo_benchmark -endif - -ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_PRINTER),) -LV_PRINTER_IMAGES = $(wildcard ./lv_demos/src/lv_demo_printer/images/*.c) -CSRCS += lv_demo_printer.c lv_demo_printer_theme.c -CSRCS += $(notdir $(LV_PRINTER_IMAGES)) -VPATH += lv_demos/src/lv_demo_printer -VPATH += lv_demos/src/lv_demo_printer/images -endif - -ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_STRESS),) -CSRCS += lv_demo_stress.c -VPATH += lv_demos/src/lv_demo_stress -endif - -ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_WIDGETS),) -CSRCS += lv_demo_widgets.c -VPATH += lv_demos/src/lv_demo_widgets -endif +# LVGL demo Example MAINSRC = lvgldemo.c -CFLAGS += ${DEFINE_PREFIX}LV_LVGL_H_INCLUDE_SIMPLE -Wno-format -CXXFLAGS += ${DEFINE_PREFIX}LV_LVGL_H_INCLUDE_SIMPLE -Wno-format - -$(LVGL_EXAMPLES_TARBALL): - $(Q) echo "Downloading: $(LVGL_EXAMPLES_TARBALL)" - $(Q) curl -O -L $(CONFIG_LV_EXAMPLES_URL)/$(LVGL_EXAMPLES_TARBALL) - -$(LVGL_EXAMPLES_UNPACKNAME): $(LVGL_EXAMPLES_TARBALL) - $(Q) echo "Unpacking: $(LVGL_EXAMPLES_TARBALL) -> $(LVGL_EXAMPLES_UNPACKNAME)" - $(Q) $(UNPACK) $(LVGL_EXAMPLES_TARBALL) - $(Q) mv lv_demos-$(LVGL_EXAMPLES_VERSION) $(LVGL_EXAMPLES_UNPACKNAME) - $(Q) touch $(LVGL_EXAMPLES_UNPACKNAME) - -# Download and unpack tarball if no git repo found -ifeq ($(wildcard $(LVGL_EXAMPLES_UNPACKNAME)/.git),) -context:: $(LVGL_EXAMPLES_UNPACKNAME) - -distclean:: - $(call DELDIR, $(LVGL_EXAMPLES_UNPACKNAME)) - $(call DELFILE, $(LVGL_EXAMPLES_TARBALL)) -endif - include $(APPDIR)/Application.mk diff --git a/examples/lvgldemo/fbdev.c b/examples/lvgldemo/fbdev.c deleted file mode 100644 index 811b821f7..000000000 --- a/examples/lvgldemo/fbdev.c +++ /dev/null @@ -1,469 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/fbdev.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include "fbdev.h" - -#include -#include - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef FBDEV_PATH -# define FBDEV_PATH "/dev/fb0" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct fb_state_s -{ - int fd; - struct fb_videoinfo_s vinfo; - struct fb_planeinfo_s pinfo; - FAR void *fbmem; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -struct fb_state_s state; - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH -static pthread_t fb_write_thread; -static sem_t flush_sem; -static sem_t wait_sem; - -static lv_area_t lv_area; -static lv_color_t *lv_color_p; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: fbdev_wait - * - * Description: - * Wait for the flushing operation conclusion to notify LVGL. - * - * Input Parameters: - * disp_drv - LVGL driver interface - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static void fbdev_wait(lv_disp_drv_t *disp_drv) -{ - sem_wait(&wait_sem); - - /* Tell the flushing is ready */ - - lv_disp_flush_ready(disp_drv); -} - -#endif - -/**************************************************************************** - * Name: fbdev_flush_internal - * - * Description: - * Write the buffer to Framebuffer interface. - * - * Input Parameters: - * area - Area of the screen to be flushed - * color_p - A n array of colors - * - * Returned Value: - * None - * - ****************************************************************************/ - -static int fbdev_flush_internal(const lv_area_t *area, lv_color_t *color_p) -{ -#ifdef CONFIG_FB_UPDATE - struct fb_area_s fb_area; -#endif - int32_t x1 = area->x1; - int32_t y1 = area->y1; - int32_t x2 = area->x2; - int32_t y2 = area->y2; - int32_t act_x1; - int32_t act_y1; - int32_t act_x2; - int32_t act_y2; - long int location = 0; - - if (state.fbmem == NULL) - { - return ERROR; - } - - /* Return if the area is out the screen */ - - if (x2 < 0) - { - return ERROR; - } - - if (y2 < 0) - { - return ERROR; - } - - if (x1 > state.vinfo.xres - 1) - { - return ERROR; - } - - if (y1 > state.vinfo.yres - 1) - { - return ERROR; - } - - /* Truncate the area to the screen */ - - act_x1 = x1 < 0 ? 0 : x1; - act_y1 = y1 < 0 ? 0 : y1; - act_x2 = x2 > state.vinfo.xres - 1 ? state.vinfo.xres - 1 : x2; - act_y2 = y2 > state.vinfo.yres - 1 ? state.vinfo.yres - 1 : y2; - - if (state.pinfo.bpp == 8) - { - uint8_t *fbp8 = (uint8_t *)state.fbmem; - uint32_t x; - uint32_t y; - - for (y = act_y1; y <= act_y2; y++) - { - for (x = act_x1; x <= act_x2; x++) - { - location = x + (y * state.vinfo.xres); - fbp8[location] = color_p->full; - color_p++; - } - - color_p += x2 - act_x2; - } - } - - if (state.pinfo.bpp == 16) - { - uint16_t *fbp16 = (uint16_t *)state.fbmem; - uint32_t x; - uint32_t y; - - for (y = act_y1; y <= act_y2; y++) - { - for (x = act_x1; x <= act_x2; x++) - { - location = x + (y * state.vinfo.xres); - fbp16[location] = color_p->full; - color_p++; - } - - color_p += x2 - act_x2; - } - } - - if (state.pinfo.bpp == 24 || state.pinfo.bpp == 32) - { - uint32_t *fbp32 = (uint32_t *)state.fbmem; - uint32_t x; - uint32_t y; - - for (y = act_y1; y <= act_y2; y++) - { - for (x = act_x1; x <= act_x2; x++) - { - location = x + (y * state.vinfo.xres); - fbp32[location] = color_p->full; - color_p++; - } - - color_p += x2 - act_x2; - } - } - -#ifdef CONFIG_FB_UPDATE - fb_area.x = act_x1; - fb_area.y = act_y1; - fb_area.w = act_x2 - act_x1 + 1; - fb_area.h = act_y2 - act_y1 + 1; - ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&fb_area)); -#endif - - return OK; -} - -/**************************************************************************** - * Name: fbdev_async_flush - * - * Description: - * Flush a buffer to the marked area asynchronously. - * - * Input Parameters: - * disp_drv - LVGL driver interface - * area - Area of the screen to be flushed - * color_p - A n array of colors - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static void fbdev_async_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, - lv_color_t *color_p) -{ - UNUSED(disp_drv); - - lv_area.y1 = area->y1; - lv_area.y2 = area->y2; - lv_area.x1 = area->x1; - lv_area.x2 = area->x2; - - lv_color_p = color_p; - - sem_post(&flush_sem); -} - -#endif - -/**************************************************************************** - * Name: fbdev_sync_flush - * - * Description: - * Flush a buffer to the marked area synchronously. - * - * Input Parameters: - * disp_drv - LVGL driver interface - * area - Area of the screen to be flushed - * color_p - A n array of colors - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static void fbdev_sync_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, - lv_color_t *color_p) -{ - fbdev_flush_internal(area, color_p); - - /* Tell the flushing is ready */ - - lv_disp_flush_ready(disp_drv); -} - -#endif - -/**************************************************************************** - * Name: fbdev_write - * - * Description: - * Thread for writing the buffer to Framebuffer interface. - * - * Input Parameters: - * arg - Context data from the parent thread - * - * Returned Value: - * Context data to the parent thread - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static pthread_addr_t fbdev_write(pthread_addr_t arg) -{ - int ret = OK; - - UNUSED(arg); - - while (ret == OK) - { - sem_wait(&flush_sem); - - ret = fbdev_flush_internal(&lv_area, lv_color_p); - - sem_post(&wait_sem); - } - - gerr("Failed to write buffer contents to display device\n"); - - return NULL; -} - -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: fbdev_init - * - * Description: - * - * Input Parameters: - * lv_drvr -- LVGL driver interface - * - * Returned Value: - * None - * - ****************************************************************************/ - -int fbdev_init(lv_disp_drv_t *lv_drvr) -{ - FAR const char *fbdev = "/dev/fb0"; - int ret; - - /* Open the framebuffer driver */ - - state.fd = open(fbdev, O_RDWR); - if (state.fd < 0) - { - int errcode = errno; - gerr("Failed to open %s: %d\n", fbdev, errcode); - return EXIT_FAILURE; - } - - /* Get the characteristics of the framebuffer */ - - ret = ioctl(state.fd, FBIOGET_VIDEOINFO, - (unsigned long)((uintptr_t)&state.vinfo)); - if (ret < 0) - { - int errcode = errno; - - gerr("ioctl(FBIOGET_VIDEOINFO) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - ginfo("VideoInfo:\n\tfmt: %u\n\txres: %u\n\tyres: %u\n\tnplanes: %u\n", - state.vinfo.fmt, state.vinfo.xres, state.vinfo.yres, - state.vinfo.nplanes); - - ret = ioctl(state.fd, FBIOGET_PLANEINFO, - (unsigned long)((uintptr_t)&state.pinfo)); - if (ret < 0) - { - int errcode = errno; - gerr("ioctl(FBIOGET_PLANEINFO) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - ginfo("PlaneInfo (plane 0):\n" - "\tfbmem: %p\n\tfblen: %l\n\tstride: %u\n" - "\tdisplay: %u\n\tbpp: %u\n\t", - state.pinfo.fbmem, (unsigned long)state.pinfo.fblen, - state.pinfo.stride, state.pinfo.display, state.pinfo.bpp); - - lv_drvr->hor_res = state.vinfo.xres; - lv_drvr->ver_res = state.vinfo.yres; -#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - lv_drvr->flush_cb = fbdev_sync_flush; -#else - lv_drvr->flush_cb = fbdev_async_flush; - lv_drvr->wait_cb = fbdev_wait; - - /* Initialize the mutexes for buffer flushing synchronization */ - - sem_init(&flush_sem, 0, 0); - sem_init(&wait_sem, 0, 0); - - /* Initialize the buffer flushing thread */ - - pthread_create(&fb_write_thread, NULL, fbdev_write, NULL); -#endif - - /* Only these pixel depths are supported. viinfo.fmt is ignored, only - * certain color formats are supported. - */ - - if (state.pinfo.bpp != 32 && state.pinfo.bpp != 16 && - state.pinfo.bpp != 8 && state.pinfo.bpp != 1) - { - gerr("bpp=%u not supported\n", state.pinfo.bpp); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - /* mmap() the framebuffer. - * - * NOTE: In the FLAT build the frame buffer address returned by the - * FBIOGET_PLANEINFO IOCTL command will be the same as the framebuffer - * address. mmap(), however, is the preferred way to get the framebuffer - * address because in the KERNEL build, it will perform the necessary - * address mapping to make the memory accessible to the application. - */ - - state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_FILE, state.fd, 0); - if (state.fbmem == MAP_FAILED) - { - int errcode = errno; - gerr("ioctl(FBIOGET_PLANEINFO) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - ginfo("Mapped FB: %p\n", state.fbmem); - - return EXIT_SUCCESS; -} diff --git a/examples/lvgldemo/fbdev.h b/examples/lvgldemo/fbdev.h deleted file mode 100644 index d5d8ef7fe..000000000 --- a/examples/lvgldemo/fbdev.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/fbdev.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __APPS_EXAMPLES_LVGLDEMO_FBDEV_H -#define __APPS_EXAMPLES_LVGLDEMO_FBDEV_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -int fbdev_init(lv_disp_drv_t *lv_drvr); - -#ifdef __cplusplus -} -#endif - -#endif /* __APPS_EXAMPLES_LVGLDEMO_FBDEV_H */ diff --git a/examples/lvgldemo/lcddev.c b/examples/lvgldemo/lcddev.c deleted file mode 100644 index 092410c09..000000000 --- a/examples/lvgldemo/lcddev.c +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/lcddev.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include "lcddev.h" - -#include -#include -#include - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef LCDDEV_PATH -# define LCDDEV_PATH "/dev/lcd0" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -struct lcd_state_s -{ - int fd; - struct fb_videoinfo_s vinfo; - struct lcd_planeinfo_s pinfo; - bool rotated; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct lcd_state_s state; - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH -static pthread_t lcd_write_thread; -static sem_t flush_sem; -static sem_t wait_sem; -static struct lcddev_area_s lcd_area; -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: lcddev_wait - * - * Description: - * Wait for the flushing operation conclusion to notify LVGL. - * - * Input Parameters: - * disp_drv - LVGL driver interface - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static void lcddev_wait(lv_disp_drv_t *disp_drv) -{ - sem_wait(&wait_sem); - - /* Tell the flushing is ready */ - - lv_disp_flush_ready(disp_drv); -} - -#endif - -/**************************************************************************** - * Name: lcddev_flush - * - * Description: - * Flush a buffer to the marked area. - * - * Input Parameters: - * disp_drv - LVGL driver interface - * lv_area_t - Area of the screen to be flushed - * color_p - A n array of colors - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static void lcddev_async_flush(lv_disp_drv_t *disp_drv, - const lv_area_t *area, - lv_color_t *color_p) -{ - UNUSED(disp_drv); - - lcd_area.row_start = area->y1; - lcd_area.row_end = area->y2; - lcd_area.col_start = area->x1; - lcd_area.col_end = area->x2; - - lcd_area.data = (uint8_t *)color_p; - - sem_post(&flush_sem); -} - -#else - -static void lcddev_sync_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, - lv_color_t *color_p) -{ - int ret; - struct lcddev_area_s lcd_area; - - lcd_area.row_start = area->y1; - lcd_area.row_end = area->y2; - lcd_area.col_start = area->x1; - lcd_area.col_end = area->x2; - - lcd_area.data = (uint8_t *)color_p; - - ret = ioctl(state.fd, LCDDEVIO_PUTAREA, - (unsigned long)((uintptr_t)&lcd_area)); - - if (ret < 0) - { - int errcode = errno; - - gerr("ioctl(LCDDEVIO_PUTAREA) failed: %d\n", errcode); - close(state.fd); - return; - } - - /* Tell the flushing is ready */ - - lv_disp_flush_ready(disp_drv); -} - -#endif - -/**************************************************************************** - * Name: lcddev_write - * - * Description: - * Write the buffer to LCD interface. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - -static pthread_addr_t lcddev_write(pthread_addr_t addr) -{ - int ret = OK; - int errcode; - - while (ret == OK) - { - sem_wait(&flush_sem); - ret = ioctl(state.fd, LCDDEVIO_PUTAREA, (unsigned long)&lcd_area); - if (ret < 0) - { - errcode = errno; - } - - sem_post(&wait_sem); - } - - if (ret != OK) - { - gerr("ioctl(LCDDEVIO_PUTAREA) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - } - - return NULL; -} - -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: lcddev_init - * - * Description: - * Initialize LCD device. - * - * Input Parameters: - * lv_drvr -- LVGL driver interface - * - * Returned Value: - * EXIT_SUCCESS on success; EXIT_FAILURE on failure. - * - ****************************************************************************/ - -int lcddev_init(lv_disp_drv_t *lv_drvr) -{ - FAR const char *lcddev = LCDDEV_PATH; - int ret; - - /* Open the framebuffer driver */ - - state.fd = open(lcddev, 0); - if (state.fd < 0) - { - int errcode = errno; - gerr("Failed to open %s: %d\n", state.fd, errcode); - return EXIT_FAILURE; - } - - /* Get the characteristics of the framebuffer */ - - ret = ioctl(state.fd, LCDDEVIO_GETVIDEOINFO, - (unsigned long)((uintptr_t)&state.vinfo)); - if (ret < 0) - { - int errcode = errno; - - gerr("ioctl(LCDDEVIO_GETVIDEOINFO) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - ginfo("VideoInfo:\n\tfmt: %u\n\txres: %u\n\tyres: %u\n\tnplanes: %u\n", - state.vinfo.fmt, state.vinfo.xres, state.vinfo.yres, - state.vinfo.nplanes); - - ret = ioctl(state.fd, LCDDEVIO_GETPLANEINFO, - (unsigned long)((uintptr_t)&state.pinfo)); - if (ret < 0) - { - int errcode = errno; - gerr("ioctl(LCDDEVIO_GETPLANEINFO) failed: %d\n", errcode); - close(state.fd); - state.fd = -1; - return EXIT_FAILURE; - } - - ginfo("PlaneInfo (plane 0):\n\tbpp: %u\n", state.pinfo.bpp); - - if (state.pinfo.bpp != CONFIG_LV_COLOR_DEPTH) - { - /* For the LCD driver we do not have a great way to translate this - * so fail to initialize. - */ - - gerr("Display bpp (%u) did not match CONFIG_LV_COLOR_DEPTH (%u)\n", - state.pinfo.bpp, CONFIG_LV_COLOR_DEPTH); - } - - lv_drvr->hor_res = state.vinfo.xres; - lv_drvr->ver_res = state.vinfo.yres; -#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH - lv_drvr->flush_cb = lcddev_sync_flush; -#else - lv_drvr->flush_cb = lcddev_async_flush; - lv_drvr->wait_cb = lcddev_wait; - - /* Initialize the mutexes for buffer flushing synchronization */ - - sem_init(&flush_sem, 0, 0); - sem_init(&wait_sem, 0, 0); - - /* Initialize the buffer flushing thread */ - - pthread_create(&lcd_write_thread, NULL, lcddev_write, NULL); -#endif - - return EXIT_SUCCESS; -} diff --git a/examples/lvgldemo/lv_ex_conf.h b/examples/lvgldemo/lv_ex_conf.h deleted file mode 100644 index 78cedf96a..000000000 --- a/examples/lvgldemo/lv_ex_conf.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/lv_ex_conf.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H -#define __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Enable printf-ing data in demoes and examples */ - -#define LV_EX_PRINTF 1 - -/* Add PC keyboard support to some examples - * (`lv_drivers` repository is required) - */ - -#define LV_EX_KEYBOARD 0 - -/* Add 'encoder' (mouse wheel) support to some examples - * (`lv_drivers` repository is required) - */ - -#define LV_EX_MOUSEWHEEL 0 - -/* Show some widget */ - -#define LV_USE_DEMO_WIDGETS 1 -#if LV_USE_DEMO_WIDGETS -#ifdef CONFIG_EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW -#define LV_DEMO_WIDGETS_SLIDESHOW CONFIG_EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW -#else -#define LV_DEMO_WIDGETS_SLIDESHOW 0 -#endif -#endif - -/* Printer demo, optimized for 800x480 */ - -#define LV_USE_DEMO_PRINTER 1 - -/* Demonstrate the usage of encoder and keyboard */ - -#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1 - -/* Benchmark your system */ - -#define LV_USE_DEMO_BENCHMARK 1 - -/* Stress test for LVGL */ - -#define LV_USE_DEMO_STRESS 1 - -#endif /* __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H */ - diff --git a/examples/lvgldemo/lvgldemo.c b/examples/lvgldemo/lvgldemo.c index c9dd63a8f..63e26865d 100644 --- a/examples/lvgldemo/lvgldemo.c +++ b/examples/lvgldemo/lvgldemo.c @@ -28,18 +28,13 @@ #include #include #include +#include #include #include #include - -#include "fbdev.h" -#include "lcddev.h" - -#if defined(CONFIG_INPUT_TOUCHSCREEN) || defined(CONFIG_INPUT_MOUSE) -#include "tp.h" -#include "tp_cal.h" -#endif +#include +#include /**************************************************************************** * Pre-processor Definitions @@ -62,46 +57,99 @@ # define NEED_BOARDINIT 1 #endif -#define DISPLAY_BUFFER_SIZE (CONFIG_LV_HOR_RES * \ - CONFIG_EXAMPLES_LVGLDEMO_BUFF_SIZE) - /**************************************************************************** - * Public Functions Prototypes + * Private Type Declarations ****************************************************************************/ -void lv_demo_benchmark(void); -void lv_demo_printer(void); -void lv_demo_stress(void); -void lv_demo_widgets(void); +typedef CODE void (*demo_create_func_t)(void); + +struct func_key_pair_s +{ + FAR const char *name; + demo_create_func_t func; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct func_key_pair_s func_key_pair[] = +{ +#ifdef CONFIG_LV_USE_DEMO_WIDGETS + { "widgets", lv_demo_widgets }, +#endif + +#ifdef CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODER + { "keypad_encoder", lv_demo_keypad_encoder }, +#endif + +#ifdef CONFIG_LV_USE_DEMO_BENCHMARK + { "benchmark", lv_demo_benchmark }, +#endif + +#ifdef CONFIG_LV_USE_DEMO_STRESS + { "stress", lv_demo_stress }, +#endif + +#ifdef CONFIG_LV_USE_DEMO_MUSIC + { "music", lv_demo_music }, +#endif + { "", NULL } +}; /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: monitor_cb - * - * Description: - * Monitoring callback from lvgl every time the screen is flushed. - * + * Name: show_usage ****************************************************************************/ -static void monitor_cb(lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px) +static void show_usage(void) { - ginfo("%" PRIu32 " px refreshed in %" PRIu32 " ms\n", px, time); + int i; + const int len = sizeof(func_key_pair) + / sizeof(struct func_key_pair_s) - 1; + + if (len == 0) + { + printf("lvgldemo: no demo available!\n"); + exit(EXIT_FAILURE); + return; + } + + printf("\nUsage: lvgldemo demo_name\n"); + printf("\ndemo_name:\n"); + + for (i = 0; i < len; i++) + { + printf(" %s\n", func_key_pair[i].name); + } + + exit(EXIT_FAILURE); } /**************************************************************************** - * Private Data + * Name: find_demo_create_func ****************************************************************************/ -static lv_color_t buffer1[DISPLAY_BUFFER_SIZE]; +static demo_create_func_t find_demo_create_func(FAR const char *name) +{ + int i; + const int len = sizeof(func_key_pair) + / sizeof(struct func_key_pair_s) - 1; -#ifdef CONFIG_EXAMPLES_LVGLDEMO_DOUBLE_BUFFERING -static lv_color_t buffer2[DISPLAY_BUFFER_SIZE]; -#else -# define buffer2 NULL -#endif + for (i = 0; i < len; i++) + { + if (strcmp(name, func_key_pair[i].name) == 0) + { + return func_key_pair[i].func; + } + } + + printf("lvgldemo: '%s' not found.\n", name); + return NULL; +} /**************************************************************************** * Public Functions @@ -122,34 +170,21 @@ static lv_color_t buffer2[DISPLAY_BUFFER_SIZE]; int main(int argc, FAR char *argv[]) { - lv_disp_drv_t disp_drv; - lv_disp_buf_t disp_buf; + demo_create_func_t demo_create_func; -#if defined(CONFIG_INPUT_TOUCHSCREEN) || defined(CONFIG_INPUT_MOUSE) -#ifndef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE - lv_point_t p[4]; + if (argc != 2) + { + show_usage(); + return EXIT_FAILURE; + } - /* top left */ + demo_create_func = find_demo_create_func(argv[1]); - p[0].x = 0; - p[0].y = 0; - - /* top right */ - - p[1].x = LV_HOR_RES; - p[1].y = 0; - - /* bottom left */ - - p[2].x = 0; - p[2].y = LV_VER_RES; - - /* bottom right */ - - p[3].x = LV_HOR_RES; - p[3].y = LV_VER_RES; -#endif -#endif + if (demo_create_func == NULL) + { + show_usage(); + return EXIT_FAILURE; + } #ifdef NEED_BOARDINIT /* Perform board-specific driver initialization */ @@ -167,71 +202,25 @@ int main(int argc, FAR char *argv[]) lv_init(); - /* Basic LVGL display driver initialization */ + /* LVGL port initialization */ - lv_disp_buf_init(&disp_buf, buffer1, buffer2, DISPLAY_BUFFER_SIZE); - lv_disp_drv_init(&disp_drv); - disp_drv.buffer = &disp_buf; - disp_drv.monitor_cb = monitor_cb; + lv_port_init(); - /* Display interface initialization */ + /* LVGL demo creation */ - if (fbdev_init(&disp_drv) != EXIT_SUCCESS) - { - /* Failed to use framebuffer falling back to lcd driver */ - - if (lcddev_init(&disp_drv) != EXIT_SUCCESS) - { - /* No possible drivers left, fail */ - - return EXIT_FAILURE; - } - } - - lv_disp_drv_register(&disp_drv); - -#if defined(CONFIG_INPUT_TOUCHSCREEN) || defined(CONFIG_INPUT_MOUSE) - /* Touchpad Initialization */ - - tp_init(); - lv_indev_drv_t indev_drv; - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - - /* This function will be called periodically (by the library) to get the - * mouse position and state. - */ - - indev_drv.read_cb = tp_read; - lv_indev_drv_register(&indev_drv); -#endif - -#if defined(CONFIG_EXAMPLES_LVGLDEMO_BENCHMARK) - lv_demo_benchmark(); -#elif defined(CONFIG_EXAMPLES_LVGLDEMO_PRINTER) - lv_demo_printer(); -#elif defined(CONFIG_EXAMPLES_LVGLDEMO_STRESS) - lv_demo_stress(); -#elif defined(CONFIG_EXAMPLES_LVGLDEMO_WIDGETS) - lv_demo_widgets(); -#endif - -#if defined(CONFIG_INPUT_TOUCHSCREEN) || defined(CONFIG_INPUT_MOUSE) - /* Start TP calibration */ - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE - tp_cal_create(); -#else - tp_set_cal_values(p, p + 1, p + 2, p + 3); -#endif -#endif + demo_create_func(); /* Handle LVGL tasks */ while (1) { - lv_task_handler(); - usleep(10000); + uint32_t idle; + idle = lv_timer_handler(); + + /* Minimum sleep of 1ms */ + + idle = idle ? idle : 1; + usleep(idle * 1000); } return EXIT_SUCCESS; diff --git a/examples/lvgldemo/tp.c b/examples/lvgldemo/tp.c deleted file mode 100644 index 4cc298eac..000000000 --- a/examples/lvgldemo/tp.c +++ /dev/null @@ -1,279 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/tp.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_EXAMPLES_LVGLDEMO_MOUSE -# include -#endif - -#include - -#include "tp.h" - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static int fd; -static bool calibrated = false; -static int x_range; -static int y_range; -static int x_offset; -static int y_offset; -static bool xy_inv; -static bool x_inv; -static bool y_inv; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tp_init - * - * Description: - * Initialize The Touch pad - * - * Input Parameters: - * None - * - * Returned Value: - * Zero (OK) on success; a positive error code on failure. - * - ****************************************************************************/ - -int tp_init(void) -{ - int errval = 0; - - /* Open the touchscreen device for reading */ - - printf("tp_init: Opening %s\n", CONFIG_EXAMPLES_LVGLDEMO_DEVPATH); - fd = open(CONFIG_EXAMPLES_LVGLDEMO_DEVPATH, O_RDONLY | O_NONBLOCK); - if (fd < 0) - { - printf("tp_init: open %s failed: %d\n", - CONFIG_EXAMPLES_LVGLDEMO_DEVPATH, errno); - errval = 2; - goto errout; - } - - return OK; - -errout: - printf("Terminating!\n"); - fflush(stdout); - return errval; -} - -/**************************************************************************** - * Name: tp_read - * - * Description: - * Read a TP data and store in 'data' argument - * - * Input Parameters: - * indev_drv - Input device handler - * data - Store the x, y and state information here - * - * Returned Value: - * false: no more data to read; true: there are more data to read. - * - ****************************************************************************/ - -bool tp_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data) -{ - struct touch_sample_s sample; - int nbytes; - static int last_x = 0; - static int last_y = 0; - static lv_indev_state_t last_state = LV_INDEV_STATE_REL; - - /* Be sure at least the previous state is set */ - - data->point.x = last_x; - data->point.y = last_y; - data->state = last_state; - - /* Read one sample */ - - nbytes = read(fd, &sample, sizeof(struct touch_sample_s)); - - /* Handle unexpected return values */ - - if (nbytes < 0 || nbytes != sizeof(struct touch_sample_s)) - { - return false; - } - - if (sample.point[0].flags & TOUCH_DOWN - || sample.point[0].flags & TOUCH_MOVE) - { - if (calibrated) - { - if (xy_inv) - { - last_x = sample.point[0].y; - last_y = sample.point[0].x; - } - else - { - last_x = sample.point[0].x; - last_y = sample.point[0].y; - } - - /* Remove offset */ - - last_x -= x_offset; - last_y -= y_offset; - - last_x = (int)((int)last_x * LV_HOR_RES) / x_range; - last_y = (int)((int)last_y * LV_VER_RES) / y_range; - - if (x_inv) - { - last_x = LV_HOR_RES - last_x; - } - - if (y_inv) - { - last_y = LV_VER_RES - last_y; - } - } - else - { - last_x = sample.point[0].x; - last_y = sample.point[0].y; - } - - last_state = LV_INDEV_STATE_PR; - } - else if (sample.point[0].flags & TOUCH_UP) - { - last_state = LV_INDEV_STATE_REL; - } - else if (sample.point[0].flags & TOUCH_UP) - { - last_state = LV_INDEV_STATE_REL; - } - - /* Update touchpad data */ - - data->point.x = last_x; - data->point.y = last_y; - data->state = last_state; - - fflush(stdout); - return false; -} - -/**************************************************************************** - * Name: tp_read - * - * Description: - * Set calibration data - * - * Input Parameters: - * ul - Upper left hand corner TP value - * ur - Upper right hand corner TP value - * lr - Lower right hand corner TP value - * ll - Lower left hand corner TP value - * - * Returned Value: - * None - * - ****************************************************************************/ - -void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur, - FAR lv_point_t *lr, FAR lv_point_t *ll) -{ - /* Is x/y inverted? */ - - if (abs(ul->x - ur->x) < LV_HOR_RES / 2) - { - /* No real change in x horizontally */ - - xy_inv = true; - } - - if (xy_inv) - { - /* Is x inverted */ - - if (ur->y < ul->y) - { - x_inv = true; - } - - /* Is y inverted */ - - if (ll->x < ul->x) - { - y_inv = true; - } - - x_range = abs(ul->y - ur->y); - y_range = abs(ul->x - ll->x); - x_offset = x_inv ? ur->y : ul->y; - y_offset = y_inv ? ll->x : ul->x; - } - else - { - /* Is x inverted */ - - if (ur->x < ul->x) - { - x_inv = true; - } - - /* Is y inverted */ - - if (ll->y < ul->y) - { - y_inv = true; - } - - x_range = abs(ul->x - ur->x); - y_range = abs(ul->y - ll->y); - x_offset = x_inv ? ur->x : ul->x; - y_offset = y_inv ? ll->y : ul->y; - } - - calibrated = true; - - printf("tp_cal result\n"); - printf("offset x:%d, y:%d\n", x_offset, y_offset); - printf("range x:%d, y:%d\n", x_range, y_range); - printf("invert x/y:%d, x:%d, y:%d\n\n", xy_inv, x_inv, y_inv); -} diff --git a/examples/lvgldemo/tp.h b/examples/lvgldemo/tp.h deleted file mode 100644 index 1507cb663..000000000 --- a/examples/lvgldemo/tp.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/tp.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __APPS_EXAMPLES_LVGLDEMO_TP_H -#define __APPS_EXAMPLES_LVGLDEMO_TP_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -/* CONFIG_EXAMPLES_LVGLDEMO_MINOR - The minor device number. Minor=N - * corresponds to touchscreen device /dev/input0. Note this value must - * with CONFIG_EXAMPLES_LVGLDEMO_DEVPATH. Default 0. - * CONFIG_EXAMPLES_LVGLDEMO_DEVPATH - The path to the touchscreen - * device. This must be consistent with CONFIG_EXAMPLES_LVGLDEMO_MINOR. - * Default: "/dev/input0" - * CONFIG_EXAMPLES_LVGLDEMO_MOUSE - The touchscreen test can also be - * configured to work with a mouse driver by setting this option. - */ - -#if !defined(CONFIG_INPUT_TOUCHSCREEN) && !defined(CONFIG_INPUT_MOUSE) -# error "Input device support is not enabled (CONFIG_INPUT_TOUCHSCREEN || CONFIG_INPUT_MOUSE)" -#endif - -#ifndef CONFIG_EXAMPLES_LVGLDEMO_MINOR -# undef CONFIG_EXAMPLES_LVGLDEMO_DEVPATH -# define CONFIG_EXAMPLES_LVGLDEMO_MINOR 0 -# ifdef CONFIG_EXAMPLES_LVGLDEMO_MOUSE -# define CONFIG_EXAMPLES_LVGLDEMO_DEVPATH "/dev/mouse0" -# else -# define CONFIG_EXAMPLES_LVGLDEMO_DEVPATH "/dev/input0" -# endif -#endif - -#ifndef CONFIG_EXAMPLES_LVGLDEMO_DEVPATH -# undef CONFIG_EXAMPLES_LVGLDEMO_MINOR -# define CONFIG_EXAMPLES_LVGLDEMO_MINOR 0 -# ifdef CONFIG_EXAMPLES_LVGLDEMO_MOUSE -# define CONFIG_EXAMPLES_LVGLDEMO_DEVPATH "/dev/mouse0" -# else -# define CONFIG_EXAMPLES_LVGLDEMO_DEVPATH "/dev/input0" -# endif -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: tp_init - * - * Description: - * Initialize The Touch pad - * - * Input Parameters: - * None - * - * Returned Value: - * Zero (OK) on success; a positive error code on failure. - * - ****************************************************************************/ - -int tp_init(void); - -/**************************************************************************** - * Name: tp_read - * - * Description: - * Read a TP data and store in 'data' argument - * - * Input Parameters: - * indev_drv - Input device handler - * data - Store the x, y and state information here - * - * Returned Value: - * false: no more data to read; true: there are more data to read. - * - ****************************************************************************/ - -bool tp_read(FAR struct _lv_indev_drv_t *indev_drv, - FAR lv_indev_data_t *data); - -/**************************************************************************** - * Name: tp_read - * - * Description: - * Set calibration data - * - * Input Parameters: - * ul - Upper left hand corner TP value - * ur - Upper right hand corner TP value - * lr - Lower right hand corner TP value - * ll - Lower left hand corner TP value - * - * Returned Value: - * None - * - ****************************************************************************/ - -void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur, - FAR lv_point_t *lr, FAR lv_point_t *ll); - -#endif /* __APPS_EXAMPLES_LVGLDEMO_TP_H */ diff --git a/examples/lvgldemo/tp_cal.c b/examples/lvgldemo/tp_cal.c deleted file mode 100644 index ccb067a14..000000000 --- a/examples/lvgldemo/tp_cal.c +++ /dev/null @@ -1,332 +0,0 @@ -/**************************************************************************** - * apps/examples/lvgldemo/tp_cal.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include "tp.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define CIRCLE_SIZE 20 -#define TP_MAX_VALUE 5000 - -/**************************************************************************** - * Private Type Definitions - ****************************************************************************/ - -enum tp_cal_state_e -{ - TP_CAL_STATE_INIT, - TP_CAL_STATE_WAIT_TOP_LEFT, - TP_CAL_STATE_WAIT_TOP_RIGHT, - TP_CAL_STATE_WAIT_BOTTOM_RIGHT, - TP_CAL_STATE_WAIT_BOTTOM_LEFT, - TP_CAL_STATE_WAIT_LEAVE, - TP_CAL_STATE_READY, -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static enum tp_cal_state_e state; -static lv_point_t p[4]; -static lv_obj_t *prev_scr; -static lv_obj_t *big_btn; -static lv_obj_t *label_main; -static lv_obj_t *circ_area; -static lv_theme_t *prev_theme; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: btn_click_action - * - * Description: - * - * Input Parameters: - * scr - * event - * - * Returned Value: - * ? - * - ****************************************************************************/ - -static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event) -{ - if (event == LV_EVENT_CLICKED) - { - if (state == TP_CAL_STATE_WAIT_TOP_LEFT) - { - lv_indev_t *indev = lv_indev_get_act(); - char buf[64]; -#if LV_USE_ANIMATION - lv_anim_t a; -#endif - - lv_indev_get_point(indev, &p[0]); - - sprintf(buf, "x: %d\ny: %d", p[0].x, p[0].y); - lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text(label_coord, buf); - - lv_label_set_text(label_main, "Click the circle in\n" - "upper right-hand corner"); - - lv_obj_set_pos(label_main, - (LV_HOR_RES - lv_obj_get_width(label_main)) / 2, - (LV_VER_RES - lv_obj_get_height(label_main)) / 2); - -#if LV_USE_ANIMATION - lv_anim_init(&a); - lv_anim_set_var(&a, circ_area); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x); - lv_anim_set_time(&a, 500); - lv_anim_set_values(&a, 0, LV_HOR_RES - CIRCLE_SIZE); - lv_anim_set_delay(&a, 200); - lv_anim_start(&a); -#else - lv_obj_set_pos(circ_area, LV_HOR_RES - CIRCLE_SIZE, 0); -#endif - - state = TP_CAL_STATE_WAIT_TOP_RIGHT; - } - else if (state == TP_CAL_STATE_WAIT_TOP_RIGHT) - { - lv_indev_t *indev = lv_indev_get_act(); - char buf[64]; - -#if LV_USE_ANIMATION - lv_anim_t a; -#endif - - lv_indev_get_point(indev, &p[1]); - - sprintf(buf, "x: %d\ny: %d", p[1].x, p[1].y); - lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text(label_coord, buf); - lv_obj_set_pos(label_coord, - LV_HOR_RES - lv_obj_get_width(label_coord), - 0); - - lv_label_set_text(label_main, "Click the circle in\n" - "lower right-hand corner"); - - lv_obj_set_pos(label_main, - (LV_HOR_RES - lv_obj_get_width(label_main)) / 2, - (LV_VER_RES - lv_obj_get_height(label_main)) / 2); - -#if LV_USE_ANIMATION - lv_anim_init(&a); - lv_anim_set_var(&a, circ_area); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y); - lv_anim_set_time(&a, 500); - lv_anim_set_values(&a, 0, LV_VER_RES - CIRCLE_SIZE); - lv_anim_set_delay(&a, 200); - lv_anim_start(&a); -#else - lv_obj_set_pos(circ_area, - LV_HOR_RES - CIRCLE_SIZE, LV_VER_RES - CIRCLE_SIZE); -#endif - - state = TP_CAL_STATE_WAIT_BOTTOM_RIGHT; - } - else if (state == TP_CAL_STATE_WAIT_BOTTOM_RIGHT) - { - lv_indev_t *indev = lv_indev_get_act(); - char buf[64]; -#if LV_USE_ANIMATION - lv_anim_t a; -#endif - lv_indev_get_point(indev, &p[2]); - - sprintf(buf, "x: %d\ny: %d", p[2].x, p[2].y); - lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text(label_coord, buf); - lv_obj_set_pos(label_coord, - LV_HOR_RES - lv_obj_get_width(label_coord), - LV_VER_RES - lv_obj_get_height(label_coord)); - - lv_label_set_text(label_main, "Click the circle in\n" - "lower left-hand corner"); - - lv_obj_set_pos(label_main, - (LV_HOR_RES - lv_obj_get_width(label_main)) / 2, - (LV_VER_RES - lv_obj_get_height(label_main)) / 2); - -#if LV_USE_ANIMATION - lv_anim_init(&a); - lv_anim_set_var(&a, circ_area); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x); - lv_anim_set_time(&a, 500); - lv_anim_set_values(&a, LV_HOR_RES - CIRCLE_SIZE, 0); - lv_anim_set_delay(&a, 200); - lv_anim_start(&a); -#else - lv_obj_set_pos(circ_area, 0, LV_VER_RES - CIRCLE_SIZE); -#endif - - state = TP_CAL_STATE_WAIT_BOTTOM_LEFT; - } - else if (state == TP_CAL_STATE_WAIT_BOTTOM_LEFT) - { - lv_indev_t *indev = lv_indev_get_act(); - char buf[64]; - - lv_indev_get_point(indev, &p[3]); - - lv_label_set_text(label_main, "Click the screen\n" - "to leave calibration"); - - lv_obj_set_pos(label_main, - (LV_HOR_RES - lv_obj_get_width(label_main)) / 2, - (LV_VER_RES - lv_obj_get_height(label_main)) / 2); - - sprintf(buf, "x: %d\ny: %d", p[3].x, p[3].y); - lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text(label_coord, buf); - lv_obj_set_pos(label_coord, 0, - LV_VER_RES - lv_obj_get_height(label_coord)); - - lv_obj_del(circ_area); - - state = TP_CAL_STATE_WAIT_LEAVE; - } - else if (state == TP_CAL_STATE_WAIT_LEAVE) - { - lv_theme_set_act(prev_theme); - lv_scr_load(prev_scr); - tp_set_cal_values(&p[0], &p[1], &p[2], &p[3]); - state = TP_CAL_STATE_READY; - } - else if (state == TP_CAL_STATE_READY) - { - } - } -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tp_cal_create - * - * Description: - * Create a touchpad calibration screen - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void tp_cal_create(void) -{ - static lv_style_t style_circ; - static lv_style_t style_big_btn; -#if LV_USE_ANIMATION - lv_anim_t a; -#endif - - state = TP_CAL_STATE_INIT; - - prev_scr = lv_scr_act(); - - lv_theme_t *theme = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, - LV_THEME_DEFAULT_COLOR_SECONDARY, - LV_THEME_DEFAULT_FLAG, - LV_THEME_DEFAULT_FONT_SMALL, - LV_THEME_DEFAULT_FONT_NORMAL, - LV_THEME_DEFAULT_FONT_SUBTITLE, - LV_THEME_DEFAULT_FONT_TITLE); - - prev_theme = lv_theme_get_act(); - lv_theme_set_act(theme); - - lv_obj_t *scr = lv_obj_create(NULL, NULL); - lv_obj_set_size(scr, TP_MAX_VALUE, TP_MAX_VALUE); - lv_scr_load(scr); - - /* Create a big transparent button screen to receive clicks */ - - big_btn = lv_btn_create(lv_scr_act(), NULL); - lv_obj_set_size(big_btn, TP_MAX_VALUE, TP_MAX_VALUE); - - lv_style_init(&style_big_btn); - - lv_style_set_bg_opa(&style_big_btn, LV_STATE_DEFAULT | LV_STATE_PRESSED, - LV_OPA_TRANSP); - lv_obj_add_style(big_btn, LV_BTN_PART_MAIN, &style_big_btn); - - lv_obj_set_event_cb(big_btn, btn_click_action); - lv_btn_set_layout(big_btn, LV_LAYOUT_OFF); - - label_main = lv_label_create(lv_scr_act(), NULL); - lv_label_set_text(label_main, "Click the circle in\n" - "upper left-hand corner"); - lv_label_set_align(label_main, LV_LABEL_ALIGN_CENTER); - - lv_obj_set_pos(label_main, (LV_HOR_RES - lv_obj_get_width(label_main)) / 2, - (LV_VER_RES - lv_obj_get_height(label_main)) / 2); - - lv_style_init(&style_circ); - lv_style_set_radius(&style_circ, LV_STATE_DEFAULT, - LV_RADIUS_CIRCLE); - lv_style_set_bg_color(&style_circ, LV_STATE_DEFAULT, - LV_COLOR_BLUE); - circ_area = lv_obj_create(lv_scr_act(), NULL); - lv_obj_set_size(circ_area, CIRCLE_SIZE, CIRCLE_SIZE); - lv_obj_add_style(circ_area, LV_OBJ_PART_MAIN, &style_circ); - lv_obj_set_click(circ_area, false); - -#if LV_USE_ANIMATION - lv_anim_init(&a); - lv_anim_set_var(&a, circ_area); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x); - lv_anim_set_time(&a, 200); - lv_anim_set_values(&a, LV_HOR_RES / 2, 0); - lv_anim_set_delay(&a, 200); - lv_anim_start(&a); - - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y); - lv_anim_set_values(&a, LV_VER_RES / 2, 0); - lv_anim_start(&a); -#endif - state = TP_CAL_STATE_WAIT_TOP_LEFT; -} diff --git a/graphics/lvgl/Kconfig b/graphics/lvgl/Kconfig index 3162c9c41..6046461eb 100644 --- a/graphics/lvgl/Kconfig +++ b/graphics/lvgl/Kconfig @@ -13,481 +13,215 @@ if GRAPHICS_LVGL config LVGL_VERSION string "LVGL Version" - default "7.3.0" + default "8.3.3" -config LV_MEM_SIZE - int "Heap size of the graphics library" - default 32768 - ---help--- - The size of a memory pool where the grapohisc library - dynamically allocates data +source "$APPSDIR/graphics/lvgl/lv_conf/Kconfig" -config LV_USE_USER_DATA - bool "Use user data in driver and objects" - default n - ---help--- - Add a `user_data` to drivers and objects - -config LV_USE_PERF_MONITOR - bool "Show CPU usage and FPS count" - default n - ---help--- - Show CPU usage and FPS count in the right bottom corner - -menu "Graphics settings" - -config LV_HOR_RES - int "Horizontal resolution." - default 320 - ---help--- - Number of pixels in horizontally. - -config LV_VER_RES - int "Vertical resolution." - default 240 - ---help--- - Number of pixels vertically. Double it if anti aliasing is used - -config LV_DPI - int "DPI (px/inch)" - default 100 - ---help--- - Number of pixels in 1 inch - -config LV_ANTIALIAS - bool "Anti aliasing of the screen" +config LV_PORT_USE_LCDDEV + bool "Enable LCD device port" default n -config LV_DISP_DEF_REFR_PERIOD - int "Default refresh period in milliseconds" - default 30 - ---help--- - The graphics library will check for invalid areas an refresh - them with this period time +if LV_PORT_USE_LCDDEV -config LV_INV_FIFO_SIZE - int "Average number of object on the screen" - default 32 - ---help--- - If too much area is invalidated (greater then this number) then - the whole screen will be refreshed +config LV_PORT_LCDDEV_DEFAULT_DEVICEPATH + string "LCD default device path" + default "/dev/lcd0" -endmenu +config LV_PORT_LCDDEV_FULL_SCREEN_BUFFER + bool "Use full screen buffer" + default n -menu "Input device settings" +if !LV_PORT_LCDDEV_FULL_SCREEN_BUFFER -config LV_INDEV_DEF_READ_PERIOD - int "Input device default read period in milliseconds" - default 30 - -config LV_INDEV_POINT_MARKER - int "Mark the pressed points on the screen" - default 0 - -config LV_INDEV_DEF_DRAG_LIMIT - int "Default drag limit in pixels" +config LV_PORT_LCDDEV_LINE_BUFFER_DEFAULT + int "Default buffer size (in line)" default 10 -config LV_INDEV_DEF_DRAG_THROW - int "Default slow down ration when throwing on object by drag [%]" - default 20 +endif # LV_PORT_LCDDEV_FULL_SCREEN_BUFFER -config LV_INDEV_DEF_LONG_PRESS_TIME - int "Default long press time [ms]" - default 400 +config LV_PORT_LCDDEV_DOUBLE_BUFFER + bool "Use double buffer" + default n -config LV_INDEV_DEF_LONG_PRESS_REP_TIME - int "Default repeated trigger period in long press [ms]" - default 100 +endif # LV_PORT_USE_LCDDEV -config LV_INDEV_DEF_GESTURE_LIMIT - int "Gesture threshold in pixels" - default 50 +config LV_PORT_USE_FBDEV + bool "Enable framebuffer port" + default n -config LV_INDEV_DEF_GESTURE_MIN_VELOCITY - int "Gesture min velocity at release before swipe (pixels)" - default 3 +config LV_PORT_FBDEV_DEFAULT_DEVICEPATH + string "Framebuffer default device path" + default "/dev/fb0" + depends on LV_PORT_USE_FBDEV -endmenu +config LV_PORT_USE_TOUCHPAD + bool "Enable touchpad port" + default n -menu "Color settings" +config LV_PORT_TOUCHPAD_DEFAULT_DEVICEPATH + depends on LV_PORT_USE_TOUCHPAD + string "Touchpad default device path" + default "/dev/input0" -config LV_COLOR_DEPTH - int "Color depth (8/16/32)" - default 16 +config LV_USE_ENCODER + depends on INPUT_MOUSE_WHEEL + bool "Encoder interface" + default n -config LV_COLOR_16_SWAP - bool "Swap the 2 bytes of RGB565 color" - depends on LV_COLOR_DEPTH = 16 +menuconfig LV_PORT_USE_BUTTON + bool "Enable button port" + default n + +if LV_PORT_USE_BUTTON + +config LV_PORT_BUTTON_DEFAULT_DEVICEPATH + string "Button default device path" + default "/dev/buttons" + +config LV_PORT_BUTTON_BUTTON_0_MAP_X + int "Button 0 mapping coordinate x" default 0 -config LV_COLOR_SCREEN_TRANSP - bool "Enable screen transparency.(If disabled, 32-bit color depth fall to 24-bit)" +config LV_PORT_BUTTON_BUTTON_0_MAP_Y + int "Button 0 mapping coordinate y" default 0 -config LV_COLOR_TRANSP - hex "Chroma key color (pixels with this color will be transparent on images)" - default 0x00ff00 - -endmenu - -menu "Text (font) settings" - -config LV_TXT_UTF8 - bool "Unicode support" - default n - -config LV_TXT_BREAK_CHARS - string "Characters where the words/line cab be wrapped" - default " ,.;:-_" - -endmenu - -menu "Feature usage" -config USE_LV_ANIMATION - bool "Enable animations" - default y - -config USE_LV_SHADOW - bool "Enable shadows" - default y - -config USE_LV_GROUP - bool "Enable object groups (for keyboard)" - default y - -config USE_LV_GPU - bool "Enable GPU (hardware acceleration) API" - default y - -config USE_LV_REAL_DRAW - bool "Enable function which draws directly to the frame buffer instead of VDB" - default y - -config USE_LV_FILESYSTEM - bool "Enable filesystem (required for images, lv_img)" - default y - -if USE_LV_FILESYSTEM - -config LV_FILESYSTEM_MOUNTPOINT - string "File system mount point" - default "/data" - -endif - -config USE_LV_MULTI_LANG - int "Number of languages for labels to store (0 to disable)" +config LV_PORT_BUTTON_BUTTON_1_MAP_X + int "Button 1 mapping coordinate x" default 0 -endmenu +config LV_PORT_BUTTON_BUTTON_1_MAP_Y + int "Button 1 mapping coordinate y" + default 0 -menu "Log usage" +config LV_PORT_BUTTON_BUTTON_2_MAP_X + int "Button 2 mapping coordinate x" + default 0 -config LV_USE_LOG - bool "Enable/disable the log module" +config LV_PORT_BUTTON_BUTTON_2_MAP_Y + int "Button 2 mapping coordinate y" + default 0 + +config LV_PORT_BUTTON_BUTTON_3_MAP_X + int "Button 3 mapping coordinate x" + default 0 + +config LV_PORT_BUTTON_BUTTON_3_MAP_Y + int "Button 3 mapping coordinate y" + default 0 + +config LV_PORT_BUTTON_BUTTON_4_MAP_X + int "Button 4 mapping coordinate x" + default 0 + +config LV_PORT_BUTTON_BUTTON_4_MAP_Y + int "Button 4 mapping coordinate y" + default 0 + +config LV_PORT_BUTTON_BUTTON_5_MAP_X + int "Button 5 mapping coordinate x" + default 0 + +config LV_PORT_BUTTON_BUTTON_5_MAP_Y + int "Button 5 mapping coordinate y" + default 0 + +endif # LV_PORT_USE_BUTTON + +menuconfig LV_PORT_USE_KEYPAD + bool "Enable keypad port" default n - -choice - prompt "Log level" - depends on LV_USE_LOG - default LV_LOG_LEVEL_WARN - -config LV_LOG_LEVEL_TRACE - bool "Trace" - -config LV_LOG_LEVEL_INFO - bool "Info" - -config LV_LOG_LEVEL_WARN - bool "Warn" - -config LV_LOG_LEVEL_ERROR - bool "Error" - -endchoice - -config LV_LOG_PRINTF - bool "Use printf() for logging" - depends on LV_USE_LOG - default y - -endmenu - -menu "Debug usage" - -config LV_USE_DEBUG - bool "Enable/disable the debug module" - default n - -config LV_USE_ASSERT_NULL - bool "Check if the parameter is NULL" - depends on LV_USE_DEBUG - default n - -config LV_USE_ASSERT_MEM - bool "Checks is the memory is successfully allocated or no" - depends on LV_USE_DEBUG - default n - -config LV_USE_ASSERT_STR - bool "Check the strings" - depends on LV_USE_DEBUG - default n - -config LV_USE_ASSERT_OBJ - bool "Check object's type and existence" - depends on LV_USE_DEBUG - default n - -config LV_USE_ASSERT_STYLE - bool "Check if the styles are properly initialized" - depends on LV_USE_DEBUG - default n - -endmenu - -menu "Theme usage" - -config LV_USE_THEME_TEMPL - bool "Use Template theme: just for test" - default n - -config LV_USE_THEME_MONO - bool "Use Mono theme: mono color theme" - default n - -config LV_USE_THEME_MATERIAL - bool "Use Material theme: material theme with bold colors" - default n - -endmenu - -menu "Base object settings" - -config LV_OBJ_REALIGN - bool "Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters" - default y - -endmenu - -menu "Object type usage settings" - -config USE_LV_LABEL - bool "Label usage" - default y - -config LV_LABEL_SCROLL_SPEED - int "Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode" - depends on USE_LV_LABEL - default 25 - -config USE_LV_IMG - bool "Image usage" - default y - -config LV_IMG_CF_INDEXED - bool "Enable indexed (palette) images" - depends on USE_LV_IMG - default y - -config LV_IMG_CF_ALPHA - bool "Enable alpha indexed images" - depends on USE_LV_IMG - default y - -config USE_LV_LINE - bool "Line usage" - default y - -config USE_LV_ARC - bool "Arc usage" - default y - -config USE_LV_CONT - bool "Container usage" - default y - -config USE_LV_PAGE - depends on USE_LV_CONT - bool "Page usage" - default y - -config USE_LV_WIN - depends on USE_LV_PAGE && USE_LV_LABEL && USE_LV_IMG && USE_LV_BTN - bool "Window usage" - default y - -config USE_LV_TABVIEW - depends on USE_LV_PAGE && USE_LV_BTNM - bool "Tabview usage" - default y - -config LV_TABVIEW_ANIM_TIME - int "Time of slide animation [ms] (0: no animation)" - depends on USE_LV_TABVIEW - default 300 - -config USE_LV_TILEVIEW - depends on USE_LV_CONT && USE_LV_PAGE - bool "Tileview usage" - default y - -config LV_TILEVIEW_ANIM_TIME - int "Time of slide animation [ms] (0: no animation)" - depends on USE_LV_TILEVIEW - default 300 - -config USE_LV_BAR - bool "Bar usage" - default y - -config USE_LV_LMETER - depends on USE_LV_BAR - bool "Line meter usage" - default y - -config USE_LV_GAUGE - depends on USE_LV_BAR && USE_LV_LMETER - bool "Gauge usage" - default y - -config USE_LV_CHART - bool "Chart usage" - default y - -config LV_CHART_AXIS_TICK_LABEL_MAX_LEN - depends on USE_LV_CHART - int "Chart axis tick label max length" - default 20 - -config USE_LV_TABLE - bool "Table usage" - depends on USE_LV_LABEL - default y - -config LV_TABLE_COL_MAX - int "Maximum number of table columns" - depends on USE_LV_TABLE - default 12 - -config USE_LV_LED - bool "LED usage" - default y - -config USE_LV_MBOX - bool "Messagebox usage" - depends on USE_LV_BTNM && USE_LV_LABEL - default y - -config USE_LV_TA - bool "Text area usage" - depends on USE_LV_LABEL && USE_LV_PAGE - default y - -config USE_LV_SPINBOX - bool "Spinbox usage" - depends on USE_LV_TA - default y - -config USE_LV_CALENDAR - bool "Calendar usage" - default y - -config USE_LV_PRELOAD - bool "Preload usage" - depends on USE_LV_ARC - default y - -config LV_PRELOAD_DEF_ARC_LENGTH - int "Degrees of arc length (default)" - range 0 360 - depends on USE_LV_PRELOAD - default 60 - -config LV_PRELOAD_DEF_SPIN_TIME - int "Time (ms) preload spins (default)" - depends on USE_LV_PRELOAD - default 1000 - -choice - prompt "Default preload animation" - depends on USE_LV_PRELOAD - default LV_PRELOAD_DEF_ANIM_SPINNING_ARC - -config LV_PRELOAD_DEF_ANIM_SPINNING_ARC - bool "Spinning Arc" - -config LV_PRELOAD_DEF_ANIM_FILLSPIN_ARC - bool "Fillspin Arc" - -endchoice - -config USE_LV_CANVAS - bool "Canvas usage" - depends on USE_LV_IMG - default n - -config USE_LV_BTN - bool "Button usage" - depends on USE_LV_CONT - default y - -config LV_BTN_INK_EFFECT - bool "Enable button-state animations" - depends on USE_LV_BTN && USE_LV_ANIMATION - default y - -config USE_LV_IMGBTN - depends on USE_LV_BTN - bool "Image button usage" - default y - -config LV_IMGBTN_TILED - bool "Tiled image button" - depends on USE_LV_IMGBTN ---help--- - The imgbtn requires left, mid and right parts and the width can be set freely + button bit map < 0 is no binding, must >= 0 and < 31 to binding button device. -config USE_LV_BTNM - bool "Button matrix usage" - default y +if LV_PORT_USE_KEYPAD -config USE_LV_KB - bool "Keyboard" - depends on USE_LV_BTNM - default y +config LV_PORT_KEYPAD_DEFAULT_DEVICEPATH + string "Button default device path" + default "/dev/buttons" -config USE_LV_CB - bool "Chekbox usage" - depends on USE_LV_BTN - default y +config LV_PORT_KEYPAD_KEY_UP_MAP_BIT + int "LV_KEY_UP button bit map" + default -1 -config USE_LV_SW - bool "Switch usage" - depends on USE_LV_BTN - default y +config LV_PORT_KEYPAD_KEY_DOWN_MAP_BIT + int "LV_KEY_DOWN button bit map" + default -1 -config USE_LV_LIST - bool "List usage" - depends on USE_LV_BTN && USE_LV_PAGE - default y +config LV_PORT_KEYPAD_KEY_RIGHT_MAP_BIT + int "LV_KEY_RIGHT button bit map" + default -1 -config USE_LV_DDLIST - bool "Drop down list usage" - depends on USE_LV_PAGE && USE_LV_LABEL - default y +config LV_PORT_KEYPAD_KEY_LEFT_MAP_BIT + int "LV_KEY_LEFT button bit map" + default -1 -config USE_LV_ROLLER - bool "Roller usage" - depends on USE_LV_DDLIST - default y +config LV_PORT_KEYPAD_KEY_ESC_MAP_BIT + int "LV_KEY_ESC button bit map" + default -1 -config USE_LV_SLIDER - bool "Slider usage" - depends on USE_LV_BAR - default y +config LV_PORT_KEYPAD_KEY_DEL_MAP_BIT + int "LV_KEY_DEL button bit map" + default -1 -endmenu +config LV_PORT_KEYPAD_KEY_BACKSPACE_MAP_BIT + int "LV_KEY_BACKSPACE button bit map" + default -1 + +config LV_PORT_KEYPAD_KEY_ENTER_MAP_BIT + int "LV_KEY_ENTER button bit map" + default -1 + +config LV_PORT_KEYPAD_KEY_NEXT_MAP_BIT + int "LV_KEY_NEXT button bit map" + default -1 + +config LV_PORT_KEYPAD_KEY_PREV_MAP_BIT + int "LV_KEY_PREV button bit map" + default -1 + +config LV_PORT_KEYPAD_KEY_HOME_MAP_BIT + int "LV_KEY_HOME button bit map" + default -1 + +config LV_PORT_KEYPAD_KEY_END_MAP_BIT + int "LV_KEY_END button bit map" + default -1 + +endif # LV_PORT_USE_KEYPAD + +if LV_PORT_USE_ENCODER + +config LV_PORT_ENCODER_DEFAULT_DEVICEPATH + string "Encoder default device path" + default "/dev/input0" + +endif # LV_USE_ENCODER + +menu "Memory configuration" + +config LV_PORT_MEM_ATTRIBUTE_FAST_MEM_SECTION_NAME + string "LV_ATTRIBUTE_FAST_MEM Section Name" + default "" + ---help--- + Set this option to configure custom memory as LV_ATTRIBUTE_FAST_MEM + +if LV_MEM_CUSTOM + +config LV_PORT_MEM_CUSTOM_SIZE + int "Size of the custom memory used by `lv_mem_alloc` in kilobytes (>= 2kB)" + default 0 + +if LV_PORT_MEM_CUSTOM_SIZE != 0 + +config LV_PORT_MEM_CUSTOM_NAME + string "Name of the custom HEAP memory" + default "lvgl" + +endif # LV_PORT_MEM_CUSTOM_SIZE + +endif # LV_MEM_CUSTOM + +endmenu # "Memory configuration" endif # GRAPHICS_LVGL diff --git a/graphics/lvgl/Make.defs b/graphics/lvgl/Make.defs index 7fa5292ad..0caf681f3 100644 --- a/graphics/lvgl/Make.defs +++ b/graphics/lvgl/Make.defs @@ -26,8 +26,4 @@ CONFIGURED_APPS += $(APPDIR)/graphics/lvgl CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/lvgl CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/lvgl -# It allows `` import. - -CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/lvgl/lvgl -CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/graphics/lvgl/lvgl endif diff --git a/graphics/lvgl/Makefile b/graphics/lvgl/Makefile index 5bfdd3c7d..9188e5d73 100644 --- a/graphics/lvgl/Makefile +++ b/graphics/lvgl/Makefile @@ -25,32 +25,67 @@ include $(APPDIR)/Make.defs LVGL_DIR = . LVGL_DIR_NAME = lvgl -# Relax format check for LVGL to avoid errors on prinf() use +# Relax LVGL's format checking and unused variable checking to avoid errors -CFLAGS += -Wno-format +CFLAGS += -Wno-format -Wno-unused-variable -# LVGL Libraries +-include ./lvgl/lvgl.mk --include ./lvgl/src/lv_core/lv_core.mk --include ./lvgl/src/lv_hal/lv_hal.mk --include ./lvgl/src/lv_widgets/lv_widgets.mk --include ./lvgl/src/lv_font/lv_font.mk --include ./lvgl/src/lv_misc/lv_misc.mk --include ./lvgl/src/lv_themes/lv_themes.mk --include ./lvgl/src/lv_draw/lv_draw.mk --include ./lvgl/src/lv_gpu/lv_gpu.mk +CSRCS += port/lv_port.c +CSRCS += port/lv_port_tick.c -CSRCS += lv_tick_interface.c -ifneq ($(CONFIG_USE_LV_FILESYSTEM),) -CSRCS += lv_fs_interface.c +ifeq ($(CONFIG_LV_PORT_USE_LCDDEV),y) +CSRCS += port/lv_port_lcddev.c +endif + +ifeq ($(CONFIG_LV_PORT_USE_FBDEV),y) +CSRCS += port/lv_port_fbdev.c +endif + +ifeq ($(CONFIG_LV_PORT_USE_TOUCHPAD),y) +CSRCS += port/lv_port_touchpad.c +endif + +ifeq ($(CONFIG_LV_PORT_USE_BUTTON),y) +CSRCS += port/lv_port_button.c +endif + +ifeq ($(CONFIG_LV_PORT_USE_KEYPAD),y) +CSRCS += port/lv_port_keypad.c +endif + +ifeq ($(CONFIG_LV_PORT_USE_ENCODER),y) +CSRCS += port/lv_port_encoder.c +endif + +ifeq ($(CONFIG_LV_USE_LOG),y) +CSRCS += port/lv_port_syslog.c +endif + +ifneq ($(CONFIG_LV_PORT_MEM_ATTRIBUTE_FAST_MEM_SECTION_NAME), "") +CFLAGS += "-DLV_ATTRIBUTE_FAST_MEM=locate_data(CONFIG_LV_PORT_MEM_ATTRIBUTE_FAST_MEM_SECTION_NAME)" +CXXFLAGS += "-DLV_ATTRIBUTE_FAST_MEM=locate_data(CONFIG_LV_PORT_MEM_ATTRIBUTE_FAST_MEM_SECTION_NAME)" +endif + +ifeq ($(CONFIG_LV_MEM_CUSTOM),y) +ifneq ($(CONFIG_LV_PORT_MEM_CUSTOM_SIZE), 0) +CFLAGS += "-DLV_MEM_CUSTOM_ALLOC=lv_port_mem_alloc" +CFLAGS += "-DLV_MEM_CUSTOM_FREE=lv_port_mem_free" +CFLAGS += "-DLV_MEM_CUSTOM_REALLOC=lv_port_mem_realloc" +CSRCS += port/lv_port_mem.c +endif +endif + +ifneq ($(CONFIG_LV_ASSERT_HANDLER_INCLUDE), "") +CFLAGS += "-DLV_ASSERT_HANDLER=ASSERT(0);" endif # Set up build configuration and environment WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'} -CONFIG_GRAPH_LVGL_URL ?= "https://github.com/lvgl/lvgl/archive" +CONFIG_GRAPH_LVGL_URL ?= "https://github.com/lvgl/lvgl/archive/refs/tags" LVGL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LVGL_VERSION))) LVGL_TARBALL = v$(LVGL_VERSION).zip diff --git a/graphics/lvgl/lv_conf.h b/graphics/lvgl/lv_conf.h deleted file mode 100644 index 53ac9959d..000000000 --- a/graphics/lvgl/lv_conf.h +++ /dev/null @@ -1,1052 +0,0 @@ -/**************************************************************************** - * apps/graphics/lvgl/lv_conf.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __APPS_GRAPHICS_LVGL_LV_CONF_H -#define __APPS_GRAPHICS_LVGL_LV_CONF_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -/* Type of coordinates. Should be `int16_t` - * (or `int32_t` for extreme cases) - */ - -typedef int16_t lv_coord_t; - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Graphical settings - ****************************************************************************/ - -/* Maximal horizontal and vertical resolution to support by the library. */ - -#define LV_HOR_RES_MAX CONFIG_LV_HOR_RES -#define LV_VER_RES_MAX CONFIG_LV_VER_RES - -/* Color depth: - * - 1: 1 byte per pixel - * - 8: RGB233 - * - 16: RGB565 - * - 32: ARGB8888 - */ - -#define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH - -/* Swap the 2 bytes of RGB565 color. - * Useful if the display has a 8 bit interface (e.g. SPI) - */ - -#ifdef CONFIG_LV_COLOR_16_SWAP -#define LV_COLOR_16_SWAP CONFIG_LV_COLOR_16_SWAP -#else -#define LV_COLOR_16_SWAP 0 -#endif - -/* 1: Enable screen transparency. - * Useful for OSD or other overlapping GUIs. - * Requires `LV_COLOR_DEPTH = 32` colors and the screen's style - * should be modified: `style.body.opa = ...` - */ - -#ifdef CONFIG_LV_COLOR_SCREEN_TRANSP -#define LV_COLOR_SCREEN_TRANSP CONFIG_LV_COLOR_SCREEN_TRANSP -#else -#define LV_COLOR_SCREEN_TRANSP 0 -#endif - -/* Images pixels with this color will not be drawn (with chroma keying) */ - -/* LV_COLOR_LIME: pure green */ - -#define LV_COLOR_TRANSP ((lv_color_t){.full = (CONFIG_LV_COLOR_TRANSP)}) - -/* Enable chroma keying for indexed images. */ - -#define LV_INDEXED_CHROMA 1 - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ - -#ifdef CONFIG_LV_ANTIALIAS -#define LV_ANTIALIAS CONFIG_LV_ANTIALIAS -#else -#define LV_ANTIALIAS 0 -#endif - -/* Default display refresh period. - * Can be changed in the display driver (`lv_disp_drv_t`). - */ - -#define LV_DISP_DEF_REFR_PERIOD CONFIG_LV_DISP_DEF_REFR_PERIOD /* [ms] */ - -/* Dot Per Inch: used to initialize default sizes. - * E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces) - */ - -#define LV_DPI CONFIG_LV_DPI /* [px] */ - -/* The the real width of the display changes some default values: - * default object sizes, layout of examples, etc. - * According to the width of the display (hor. res. / dpi) - * the displays fall in 4 categories. - * The 4th is extra large which has no upper limit so not listed here - * The upper limit of the categories are set below in 0.1 inch unit. - */ - -#define LV_DISP_SMALL_LIMIT 30 -#define LV_DISP_MEDIUM_LIMIT 50 -#define LV_DISP_LARGE_LIMIT 70 - -/**************************************************************************** - * Memory manager settings - ****************************************************************************/ - -/* LittelvGL's internal memory manager's settings. - * The graphical objects and other related data are stored here. - */ - -/* 1: use custom malloc/free, 0: use the built-in - * `lv_mem_alloc` and `lv_mem_free` - */ - -#define LV_MEM_CUSTOM 1 -#if LV_MEM_CUSTOM == 0 - -/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB) */ - -# define LV_MEM_SIZE CONFIG_LV_MEM_SIZE - -/* Compiler prefix for a big array declaration */ - -# define LV_MEM_ATTR - -/* Set an address for the memory pool instead of allocating it as an array. - * Can be in external SRAM too. - */ - -# define LV_MEM_ADR 0 - -/* Automatically defrag. on free. Defrag. means - * joining the adjacent free cells. - */ - -# define LV_MEM_AUTO_DEFRAG 1 -#else /* LV_MEM_CUSTOM */ -# define LV_MEM_CUSTOM_INCLUDE /* Header for the dynamic memory function */ -# define LV_MEM_CUSTOM_ALLOC malloc /* Wrapper to malloc */ -# define LV_MEM_CUSTOM_FREE free /* Wrapper to free */ -#endif /* LV_MEM_CUSTOM */ - -/* Garbage Collector settings - * Used if lvgl is binded to higher level language and the memory is - * managed by that language - */ - -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 -# define LV_GC_INCLUDE "gc.h" /* Include Garbage Collector related things */ -# define LV_MEM_CUSTOM_REALLOC your_realloc /* Wrapper to realloc */ -# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /* Wrapper to lv_mem_get_size */ -#endif /* LV_ENABLE_GC */ - -/**************************************************************************** - * Input device settings - ****************************************************************************/ - -/* Input device default settings. - * Can be changed in the Input device driver (`lv_indev_drv_t`) - */ - -/* Input device read period in milliseconds */ - -#define LV_INDEV_DEF_READ_PERIOD CONFIG_LV_INDEV_DEF_READ_PERIOD - -/* Drag threshold in pixels */ - -#define LV_INDEV_DEF_DRAG_LIMIT CONFIG_LV_INDEV_DEF_DRAG_LIMIT - -/* Drag throw slow-down in [%]. Greater value -> faster slow-down */ - -#define LV_INDEV_DEF_DRAG_THROW CONFIG_LV_INDEV_DEF_DRAG_THROW - -/* Long press time in milliseconds. - * Time to send `LV_EVENT_LONG_PRESSSED`) - */ - -#define LV_INDEV_DEF_LONG_PRESS_TIME CONFIG_LV_INDEV_DEF_LONG_PRESS_TIME - -/* Repeated trigger period in long press [ms] - * Time between `LV_EVENT_LONG_PRESSED_REPEAT - */ - -#define LV_INDEV_DEF_LONG_PRESS_REP_TIME \ - CONFIG_LV_INDEV_DEF_LONG_PRESS_REP_TIME - -/* Gesture threshold in pixels */ - -#define LV_INDEV_DEF_GESTURE_LIMIT CONFIG_LV_INDEV_DEF_GESTURE_LIMIT - -/* Gesture min velocity at release before swipe (pixels) */ - -#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY \ - CONFIG_LV_INDEV_DEF_GESTURE_MIN_VELOCITY - -/**************************************************************************** - * Feature usage - ****************************************************************************/ - -/* 1: Enable the Animations */ - -#ifdef CONFIG_USE_LV_ANIMATION -#define LV_USE_ANIMATION CONFIG_USE_LV_ANIMATION -#else -#define LV_USE_ANIMATION 0 -#endif - -#if LV_USE_ANIMATION - -/* Declare the type of the user data of animations - * (can be e.g. `void *`, `int`, `struct`) - */ - -typedef void * lv_anim_user_data_t; - -#endif - -/* 1: Enable shadow drawing */ - -#ifdef CONFIG_USE_LV_SHADOW -#define LV_USE_SHADOW CONFIG_USE_LV_SHADOW -#else -#define LV_USE_SHADOW 0 -#endif - -#if LV_USE_SHADOW -/* Allow buffering some shadow calculation - * LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, - * where shadow size is `shadow_width + radius` - * Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost - */ - -# define LV_SHADOW_CACHE_SIZE 0 -#endif - -/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`) */ - -#define LV_USE_BLEND_MODES 1 - -/* 1: Use the `opa_scale` style property to set the opacity - * of an object and its children at once - */ - -#define LV_USE_OPA_SCALE 1 - -/* 1: Use image zoom and rotation */ - -#define LV_USE_IMG_TRANSFORM 1 - -/* 1: Enable object groups (for keyboard/encoder navigation) */ - -#ifdef CONFIG_USE_LV_GROUP -#define LV_USE_GROUP CONFIG_USE_LV_GROUP -#else -#define LV_USE_GROUP 0 -#endif -#if LV_USE_GROUP -typedef void * lv_group_user_data_t; -#endif /* LV_USE_GROUP */ - -/* 1: Enable GPU interface */ - -#ifdef CONFIG_USE_LV_GPU -#define LV_USE_GPU CONFIG_USE_LV_GPU -#else -#define LV_USE_GPU 0 -#endif - -/* 1: Enable file system (might be required for images */ - -#ifdef CONFIG_USE_LV_FILESYSTEM -#define LV_USE_FILESYSTEM CONFIG_USE_LV_FILESYSTEM -#else -#define LV_USE_FILESYSTEM 0 -#endif - -#if LV_USE_FILESYSTEM -/* Declare the type of the user data of file system drivers - * (can be e.g. `void *`, `int`, `struct`) - */ - -typedef void * lv_fs_drv_user_data_t; -#endif - -/* 1: Add a `user_data` to drivers and objects */ - -#ifdef CONFIG_LV_USE_USER_DATA -#define LV_USE_USER_DATA CONFIG_LV_USE_USER_DATA -#else -#define LV_USE_USER_DATA 0 -#endif - -/* 1: Show CPU usage and FPS count in the right bottom corner */ - -#ifdef CONFIG_LV_USE_PERF_MONITOR -#define LV_USE_PERF_MONITOR CONFIG_LV_USE_PERF_MONITOR -#else -#define LV_USE_PERF_MONITOR 0 -#endif - -/* 1: Use the functions and types from the older API if possible */ - -#define LV_USE_API_EXTENSION_V6 1 - -/**************************************************************************** - * Image decoder and cache - ****************************************************************************/ - -/* 1: Enable indexed (palette) images */ - -#ifdef CONFIG_LV_IMG_CF_INDEXED -#define LV_IMG_CF_INDEXED CONFIG_LV_IMG_CF_INDEXED -#else -#define LV_IMG_CF_INDEXED 0 -#endif - -/* 1: Enable alpha indexed images */ - -#ifdef CONFIG_LV_IMG_CF_ALPHA -#define LV_IMG_CF_ALPHA CONFIG_LV_IMG_CF_ALPHA -#else -#define LV_IMG_CF_ALPHA 0 -#endif - -/* Default image cache size. Image caching keeps the images opened. - * If only the built-in image formats are used there is - * no real advantage of caching. - * (I.e. no new image decoder is added) - * With complex image decoders (e.g. PNG or JPG) caching can - * save the continuous open/decode of images. - * However the opened images might consume additional RAM. - * LV_IMG_CACHE_DEF_SIZE must be >= 1 - */ - -#define LV_IMG_CACHE_DEF_SIZE 1 - -/* Declare the type of the user data of image decoder - * (can be e.g. `void *`, `int`, `struct`) - */ - -typedef void * lv_img_decoder_user_data_t; - -/**************************************************************************** - * Compiler settings - ****************************************************************************/ - -/* Define a custom attribute to `lv_tick_inc` function */ - -#define LV_ATTRIBUTE_TICK_INC - -/* Define a custom attribute to `lv_task_handler` function */ - -#define LV_ATTRIBUTE_TASK_HANDLER - -/* With size optimization (-Os) the compiler might not align data to - * 4 or 8 byte boundary. This alignment will be explicitly applied - * where needed. - * E.g. __attribute__((aligned(4))) - */ - -#define LV_ATTRIBUTE_MEM_ALIGN - -/* Attribute to mark large constant arrays for example - * font's bitmaps - */ - -#define LV_ATTRIBUTE_LARGE_CONST - -/* Prefix performance critical functions to place them into a - * faster memory (e.g RAM). Uses 15-20 kB extra memory - */ - -#define LV_ATTRIBUTE_FAST_MEM - -/* Export integer constant to binding. - * This macro is used with constants in the form of LV_ that - * should also appear on lvgl binding API such as Micropython - * - * The default value just prevents a GCC warning. - */ - -#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning - -/**************************************************************************** - * HAL settings - ****************************************************************************/ - -/* 1: use a custom tick source. - * It removes the need to manually update the tick with `lv_tick_inc`) - */ - -#define LV_TICK_CUSTOM 1 -#if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "lv_tick_interface.h" /* Header for the sys time function */ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (lv_tick_interface()) /* Expression evaluating to current systime in ms */ -#endif /* LV_TICK_CUSTOM */ - -typedef void * lv_disp_drv_user_data_t; /* Type of user data in the display driver */ -typedef void * lv_indev_drv_user_data_t; /* Type of user data in the input device driver */ - -/**************************************************************************** - * Log settings - ****************************************************************************/ - -/* 1: Enable the log module */ - -#ifdef CONFIG_LV_USE_LOG -#define LV_USE_LOG CONFIG_LV_USE_LOG -#else -#define LV_USE_LOG 0 -#endif - -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE - A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO - Log important events - * LV_LOG_LEVEL_WARN - Log if something happened but didn't cause a crash - * LV_LOG_LEVEL_ERROR - Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE - Do not log anything - */ - -#ifdef CONFIG_LV_LOG_LEVEL_TRACE -# define LV_LOG_LEVEL LV_LOG_LEVEL_TRACE -#endif - -#ifdef CONFIG_LV_LOG_LEVEL_INFO -# define LV_LOG_LEVEL LV_LOG_LEVEL_INFO -#endif - -#ifdef CONFIG_LV_LOG_LEVEL_WARN -# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN -#endif - -#ifdef CONFIG_LV_LOG_LEVEL_ERROR -# define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR -#endif - -#ifdef CONFIG_LV_LOG_LEVEL_NONE -# define LV_LOG_LEVEL LV_LOG_LEVEL_NONE -#endif - -/* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print_cb` - */ - -#ifdef CONFIG_LV_LOG_PRINTF -# define LV_LOG_PRINTF CONFIG_LV_LOG_PRINTF -#else -# define LV_LOG_PRINTF 0 -#endif -#endif /* LV_USE_LOG */ - -/**************************************************************************** - * Debug settings - ****************************************************************************/ - -/* If Debug is enabled LittelvGL validates the parameters of the functions. - * If an invalid parameter is found an error log message is printed and - * the MCU halts at the error. (`LV_USE_LOG` should be enabled) - * If you are debugging the MCU you can pause - * the debugger to see exactly where the issue is. - * - * The behavior of asserts can be overwritten by redefining them here. - * E.g. #define LV_ASSERT_MEM(p) - */ - -#ifndef CONFIG_LV_USE_DEBUG -#define CONFIG_LV_USE_DEBUG 0 -#endif - -#define LV_USE_DEBUG CONFIG_LV_USE_DEBUG - -/* Check if the parameter is NULL. (Quite fast) */ - -#ifdef CONFIG_LV_USE_ASSERT_NULL -#define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL -#else -#define LV_USE_ASSERT_NULL 0 -#endif - -/* Checks is the memory is successfully allocated or no. (Quite fast) */ - -#ifdef CONFIG_LV_USE_ASSERT_MEM -#define LV_USE_ASSERT_MEM CONFIG_LV_USE_ASSERT_MEM -#else -#define LV_USE_ASSERT_MEM 0 -#endif - -/* Check the integrity of `lv_mem` after critical operations. (Slow) */ - -#define LV_USE_ASSERT_MEM_INTEGRITY 0 - -/* Check the strings. - * Search for NULL, very long strings, invalid characters, - * and unnatural repetitions. (Slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead - * (if it's enabled) - */ -#ifdef CONFIG_LV_USE_ASSERT_STR -#define LV_USE_ASSERT_STR CONFIG_LV_USE_ASSERT_STR -#else -#define LV_USE_ASSERT_STR 0 -#endif - -/* Check NULL, the object's type and existence - * (e.g. not deleted). (Quite slow) - * If disabled `LV_USE_ASSERT_NULL` will be - * performed instead (if it's enabled) - */ - -#ifdef CONFIG_LV_USE_ASSERT_OBJ -#define LV_USE_ASSERT_OBJ CONFIG_LV_USE_ASSERT_OBJ -#else -#define LV_USE_ASSERT_OBJ 0 -#endif - -/* Check if the styles are properly initialized. (Fast) */ - -#ifdef CONFIG_LV_USE_ASSERT_STYLE -#define LV_USE_ASSERT_STYLE CONFIG_LV_USE_ASSERT_STYLE -#else -#define LV_USE_ASSERT_STYLE 0 -#endif - -/**************************************************************************** - * THEME USAGE - ****************************************************************************/ - -/* Always enable at least on theme */ - -/* No theme, you can apply your styles as you need - * No flags. Set LV_THEME_DEFAULT_FLAG 0 - */ - -#define LV_USE_THEME_EMPTY 1 - -/* Simple to the create your theme based on it - * No flags. Set LV_THEME_DEFAULT_FLAG 0 - */ - -#define LV_USE_THEME_TEMPLATE 1 - -/* A fast and impressive theme. - * Flags: - * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme - */ - -#define LV_USE_THEME_MATERIAL 1 - -/* Mono-color theme for monochrome displays. - * If LV_THEME_DEFAULT_COLOR_PRIMARY is LV_COLOR_BLACK the - * texts and borders will be black and the background will be - * white. Else the colors are inverted. - * No flags. Set LV_THEME_DEFAULT_FLAG 0 - */ - -#define LV_USE_THEME_MONO 1 - -#define LV_THEME_DEFAULT_INCLUDE /* Include a header for the init. function */ -#define LV_THEME_DEFAULT_INIT lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE -#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT -#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16 - -/**************************************************************************** - * FONT USAGE - ****************************************************************************/ - -/* The built-in fonts contains the ASCII range and some Symbols - * with 4 bit-per-pixel. - * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html - * To create a new font go to: https://lvgl.com/ttf-font-to-c-array - */ - -/* Montserrat fonts with bpp = 4 - * https://fonts.google.com/specimen/Montserrat - */ - -/* They only take up storage space after being used, - * so we can enable them all by default - */ - -#define LV_FONT_MONTSERRAT_12 1 -#define LV_FONT_MONTSERRAT_14 1 -#define LV_FONT_MONTSERRAT_16 1 -#define LV_FONT_MONTSERRAT_18 1 -#define LV_FONT_MONTSERRAT_20 1 -#define LV_FONT_MONTSERRAT_22 1 -#define LV_FONT_MONTSERRAT_24 1 -#define LV_FONT_MONTSERRAT_26 1 -#define LV_FONT_MONTSERRAT_28 1 -#define LV_FONT_MONTSERRAT_30 1 -#define LV_FONT_MONTSERRAT_32 1 -#define LV_FONT_MONTSERRAT_34 1 -#define LV_FONT_MONTSERRAT_36 1 -#define LV_FONT_MONTSERRAT_38 1 -#define LV_FONT_MONTSERRAT_40 1 -#define LV_FONT_MONTSERRAT_42 1 -#define LV_FONT_MONTSERRAT_44 1 -#define LV_FONT_MONTSERRAT_46 1 -#define LV_FONT_MONTSERRAT_48 1 - -/* Demonstrate special features */ -#define LV_FONT_MONTSERRAT_12_SUBPX 0 -#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /* bpp = 3 */ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /* Hebrew, Arabic, PErisan letters and all their forms */ -#define LV_FONT_SIMSUN_16_CJK 0 /* 1000 most common CJK radicals */ - -/* Pixel perfect monospace font - * http://pelulamu.net/unscii/ - */ - -#ifdef CONFIG_USE_LV_FONT_UNSCII_8 -#define LV_FONT_UNSCII_8 CONFIG_USE_LV_FONT_UNSCII_8 -#else -#define LV_FONT_UNSCII_8 0 -#endif - -/* Optionally declare your custom fonts here. - * You can use these fonts as default font too - * and they will be available globally. E.g. - * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) - */ - -#define LV_FONT_CUSTOM_DECLARE - -/* Enable it if you have fonts with a lot of characters. - * The limit depends on the font size, font face and bpp - * but with > 10,000 characters if you see issues probably you need - * to enable it. - */ - -#define LV_FONT_FMT_TXT_LARGE 0 - -/* Set the pixel order of the display. - * Important only if "subpx fonts" are used. - * With "normal" font it doesn't matter. - */ - -#define LV_FONT_SUBPX_BGR 0 - -/* Declare the type of the user data of fonts - * (can be e.g. `void *`, `int`, `struct`) - */ - -typedef void * lv_font_user_data_t; - -/**************************************************************************** - * Text settings - ****************************************************************************/ - -/* Select a character encoding for strings. - * Your IDE or editor should have the same character encoding - * - LV_TXT_ENC_UTF8 - * - LV_TXT_ENC_ASCII - */ - -#define LV_TXT_ENC LV_TXT_ENC_UTF8 - -/* Can break (wrap) texts on these chars */ - -#define LV_TXT_BREAK_CHARS CONFIG_LV_TXT_BREAK_CHARS - -/* If a word is at least this long, will break wherever "prettiest" - * To disable, set to a value <= 0 - */ - -#define LV_TXT_LINE_BREAK_LONG_LEN 0 - -/* Minimum number of characters in a long word to put - * on a line before a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. - */ - -#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 - -/* Minimum number of characters in a long word to put on a - * line after a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. - */ - -#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 - -/* The control character to use for signalling text recoloring. */ - -#define LV_TXT_COLOR_CMD "#" - -/* Support bidirectional texts. - * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the - * Unicode Bidirectioanl Algorithm: - * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics - */ - -#define LV_USE_BIDI 0 -#if LV_USE_BIDI -/* Set the default direction. Supported values: - * `LV_BIDI_DIR_LTR` Left-to-Right - * `LV_BIDI_DIR_RTL` Right-to-Left - * `LV_BIDI_DIR_AUTO` detect texts base direction - */ - -#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO -#endif - -/* Enable Arabic/Persian processing - * In these languages characters should be replaced with - * an other form based on their position in the text - */ - -#define LV_USE_ARABIC_PERSIAN_CHARS 0 - -/* Change the built in (v)snprintf functions */ - -#define LV_SPRINTF_CUSTOM 1 -#if LV_SPRINTF_CUSTOM -# define LV_SPRINTF_INCLUDE -# define lv_snprintf snprintf -# define lv_vsnprintf vsnprintf -#endif /* LV_SPRINTF_CUSTOM */ - -/**************************************************************************** - * LV_OBJ SETTINGS - ****************************************************************************/ - -/* Declare the type of the user data of object - * (can be e.g. `void *`, `int`, `struct`) - */ - -typedef void * lv_obj_user_data_t; - -/* 1: enable `lv_obj_realaign()` based on `lv_obj_align()` parameters */ - -#ifdef CONFIG_LV_OBJ_REALIGN -#define LV_USE_OBJ_REALIGN CONFIG_LV_OBJ_REALIGN -#else -#define LV_USE_OBJ_REALIGN 0 -#endif - -/* Enable to make the object clickable on a larger area. - * LV_EXT_CLICK_AREA_OFF or 0: Disable this feature - * LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted - * horizontally and vertically (0..255 px) - * LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted - * in all 4 directions (-32k..+32k px) - */ - -#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_TINY - -/**************************************************************************** - * LV OBJ X USAGE - ****************************************************************************/ - -/* Documentation of the object types: - * https://docs.littlevgl.com/#Object-types - */ - -/* Arc (dependencies: -) */ - -#ifdef CONFIG_USE_LV_ARC -#define LV_USE_ARC CONFIG_USE_LV_ARC -#else -#define LV_USE_ARC 0 -#endif - -/* Bar (dependencies: -) */ - -#ifdef CONFIG_USE_LV_BAR -#define LV_USE_BAR CONFIG_USE_LV_BAR -#else -#define LV_USE_BAR 0 -#endif - -/* Button (dependencies: lv_cont) */ - -#ifdef CONFIG_USE_LV_BTN -#define LV_USE_BTN CONFIG_USE_LV_BTN -#else -#define LV_USE_BTN 0 -#endif - -#if LV_USE_BTN != 0 - -/* Enable button-state animations - draw a - * circle on click (dependencies: LV_USE_ANIMATION) - */ - -#ifdef CONFIG_LV_BTN_INK_EFFECT -#define LV_BTN_INK_EFFECT CONFIG_LV_BTN_INK_EFFECT -#else -#define LV_BTN_INK_EFFECT 0 -#endif - -#endif - -/* Button matrix (dependencies: -) */ - -#ifdef CONFIG_USE_LV_BTNM -#define LV_USE_BTNM CONFIG_USE_LV_BTNM -#else -#define LV_USE_BTNM 0 -#endif - -/* Calendar (dependencies: -) */ - -#ifdef CONFIG_USE_LV_CALENDAR -#define LV_USE_CALENDAR CONFIG_USE_LV_CALENDAR -#else -#define LV_USE_CALENDAR 0 -#endif - -/* Canvas (dependencies: lv_img) */ - -#ifdef CONFIG_USE_LV_CANVAS -#define LV_USE_CANVAS CONFIG_USE_LV_CANVAS -#else -#define LV_USE_CANVAS 0 -#endif - -/* Check box (dependencies: lv_btn, lv_label) */ - -#ifdef CONFIG_USE_LV_CB -#define LV_USE_CB CONFIG_USE_LV_CB -#else -#define LV_USE_CB 0 -#endif - -/* Chart (dependencies: -) */ - -#ifdef CONFIG_USE_LV_CHART -#define LV_USE_CHART CONFIG_USE_LV_CHART -#else -#define LV_USE_CHART 0 -#endif - -#if LV_USE_CHART -# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN CONFIG_LV_CHART_AXIS_TICK_LABEL_MAX_LEN -#endif - -/* Container (dependencies: -) */ - -#define LV_USE_CONT 1 - -/* Color picker (dependencies: -) */ - -#define LV_USE_CPICKER 1 - -/* Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h) */ - -#define LV_USE_DDLIST 1 -#if LV_USE_DDLIST != 0 -/* Open and close default animation time [ms] (0: no animation) */ - -# define LV_DDLIST_DEF_ANIM_TIME 200 -#endif - -/* Gauge (dependencies:lv_bar, lv_lmeter) */ - -#define LV_USE_GAUGE 1 - -/* Image (dependencies: lv_label) */ - -#define LV_USE_IMG 1 - -/* Image Button (dependencies: lv_btn) */ - -#define LV_USE_IMGBTN 1 -#if LV_USE_IMGBTN -/* 1: The imgbtn requires left, mid and right - * parts and the width can be set freely - */ - -# define LV_IMGBTN_TILED 0 -#endif - -/* Keyboard (dependencies: lv_btnm) */ - -#define LV_USE_KB 1 - -/* Label (dependencies: -) */ - -#define LV_USE_LABEL 1 -#if LV_USE_LABEL != 0 -/* Hor, or ver. scroll speed [px/sec] in - * 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode - */ - -# define LV_LABEL_DEF_SCROLL_SPEED 25 - -/* Waiting period at beginning/end of animation cycle */ - -# define LV_LABEL_WAIT_CHAR_COUNT 3 - -/* Enable selecting text of the label */ - -# define LV_LABEL_TEXT_SEL 0 - -/* Store extra some info in labels (12 bytes) - * to speed up drawing of very long texts - */ - -# define LV_LABEL_LONG_TXT_HINT 0 -#endif - -/* LED (dependencies: -) */ - -#define LV_USE_LED 1 - -/* Line (dependencies: -) */ - -#define LV_USE_LINE 1 - -/* List (dependencies: lv_page, lv_btn, lv_label, - * (lv_img optionally for icons)) - */ - -#define LV_USE_LIST 1 -#if LV_USE_LIST != 0 -/* Default animation time of focusing to a - * list element [ms] (0: no animation) - */ - -# define LV_LIST_DEF_ANIM_TIME 100 -#endif - -/* Line meter (dependencies: *) */ - -#define LV_USE_LMETER 1 - -/* Message box (dependencies: lv_rect, lv_btnm, lv_label) */ - -#define LV_USE_MBOX 1 - -/* Page (dependencies: lv_cont) */ - -#define LV_USE_PAGE 1 -#if LV_USE_PAGE != 0 -/* Focus default animation time [ms] (0: no animation) */ - -# define LV_PAGE_DEF_ANIM_TIME 400 -#endif - -/* Preload (dependencies: lv_arc, lv_anim) */ - -#define LV_USE_PRELOAD 1 -#if LV_USE_PRELOAD != 0 -# define LV_PRELOAD_DEF_ARC_LENGTH 60 /* [deg] */ -# define LV_PRELOAD_DEF_SPIN_TIME 1000 /* [ms] */ -# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC -#endif - -/* Roller (dependencies: lv_ddlist) */ - -#define LV_USE_ROLLER 1 -#if LV_USE_ROLLER != 0 -/* Focus animation time [ms] (0: no animation) */ - -# define LV_ROLLER_DEF_ANIM_TIME 200 - -/* Number of extra "pages" when the roller is infinite */ - -# define LV_ROLLER_INF_PAGES 7 -#endif - -/* Slider (dependencies: lv_bar) */ - -#define LV_USE_SLIDER 1 - -/* Spinbox (dependencies: lv_ta) */ - -#define LV_USE_SPINBOX 1 - -/* Switch (dependencies: lv_slider) */ - -#define LV_USE_SW 1 - -/* Text area (dependencies: lv_label, lv_page) */ - -#define LV_USE_TA 1 -#if LV_USE_TA != 0 -# define LV_TA_DEF_CURSOR_BLINK_TIME 400 /* ms */ -# define LV_TA_DEF_PWD_SHOW_TIME 1500 /* ms */ -#endif - -/* Table (dependencies: lv_label) */ - -#define LV_USE_TABLE 1 -#if LV_USE_TABLE -# define LV_TABLE_COL_MAX 12 -#endif - -/* Tab (dependencies: lv_page, lv_btnm) */ - -#define LV_USE_TABVIEW 1 -# if LV_USE_TABVIEW != 0 -/* Time of slide animation [ms] (0: no animation) */ - -# define LV_TABVIEW_DEF_ANIM_TIME 300 -#endif - -/* Tileview (dependencies: lv_page) */ - -#define LV_USE_TILEVIEW 1 -#if LV_USE_TILEVIEW -/* Time of slide animation [ms] (0: no animation) */ - -# define LV_TILEVIEW_DEF_ANIM_TIME 300 -#endif - -/* Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page) */ - -#define LV_USE_WIN 1 - -/**************************************************************************** - * Non-user section - ****************************************************************************/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -# define _CRT_SECURE_NO_WARNINGS -#endif - -#endif /* __APPS_GRAPHICS_LVGL_LV_CONF_H */ diff --git a/graphics/lvgl/lv_conf/Kconfig b/graphics/lvgl/lv_conf/Kconfig new file mode 100644 index 000000000..65f02eda3 --- /dev/null +++ b/graphics/lvgl/lv_conf/Kconfig @@ -0,0 +1,1115 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +# Kconfig file for LVGL v8.0 + +menu "LVGL configuration" + + # Define CONFIG_LV_CONF_SKIP so we can use LVGL + # without lv_conf.h file, the lv_conf_internal.h and + # lv_conf_kconfig.h files are used instead. + config LV_CONF_SKIP + bool "Uncheck this to use custom lv_conf.h" + default y + + config LV_CONF_MINIMAL + bool "LVGL minimal configuration." + + menu "Color settings" + choice LV_COLOR_DEPTH + prompt "Color depth." + default LV_COLOR_DEPTH_16 + help + Color depth to be used. + + config LV_COLOR_DEPTH_32 + bool "32: ARGB8888" + config LV_COLOR_DEPTH_16 + bool "16: RGB565" + config LV_COLOR_DEPTH_8 + bool "8: RGB232" + config LV_COLOR_DEPTH_1 + bool "1: 1 byte per pixel" + endchoice + + config LV_COLOR_DEPTH + int + default 1 if LV_COLOR_DEPTH_1 + default 8 if LV_COLOR_DEPTH_8 + default 16 if LV_COLOR_DEPTH_16 + default 32 if LV_COLOR_DEPTH_32 + + config LV_COLOR_16_SWAP + bool "Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)." + depends on LV_COLOR_DEPTH_16 + + config LV_COLOR_SCREEN_TRANSP + bool "Enable more complex drawing routines to manage screens transparency." + help + Can be used if the UI is above another layer, e.g. an OSD menu or video player. + The screen's `bg_opa` should be set to non LV_OPA_COVER value + + config LV_COLOR_MIX_ROUND_OFS + int "Adjust color mix functions rounding" + default 128 if !LV_COLOR_DEPTH_32 + default 0 if LV_COLOR_DEPTH_32 + range 0 254 + help + 0: no adjustment, get the integer part of the result (round down) + 64: round up from x.75 + 128: round up from half + 192: round up from x.25 + 254: round up + + config LV_COLOR_CHROMA_KEY_HEX + hex "Images pixels with this color will not be drawn (if they are chroma keyed)." + range 0x000000 0xFFFFFF + default 0x00FF00 + help + See misc/lv_color.h for some color values examples. + endmenu + + menu "Memory settings" + config LV_MEM_CUSTOM + bool "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc()` and `lv_mem_free()`" + + config LV_MEM_SIZE_KILOBYTES + int "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)" + range 2 128 + default 32 + depends on !LV_MEM_CUSTOM + + config LV_MEM_ADDR + hex "Address for the memory pool instead of allocating it as a normal array" + default 0x0 + depends on !LV_MEM_CUSTOM + + config LV_MEM_CUSTOM_INCLUDE + string "Header to include for the custom memory function" + default "stdlib.h" + depends on LV_MEM_CUSTOM + + config LV_MEM_BUF_MAX_NUM + int "Number of the memory buffer" + default 16 + help + Number of the intermediate memory buffer used during rendering and other + internal processing mechanisms. You will see an error log message if + there wasn't enough buffers. + + config LV_MEMCPY_MEMSET_STD + bool "Use the standard memcpy and memset instead of LVGL's own functions" + endmenu + + menu "HAL Settings" + config LV_DISP_DEF_REFR_PERIOD + int "Default display refresh period (ms)." + default 30 + help + Can be changed in the display driver (`lv_disp_drv_t`). + + config LV_INDEV_DEF_READ_PERIOD + int "Input device read period [ms]." + default 30 + + config LV_TICK_CUSTOM + bool "Use a custom tick source" + + config LV_TICK_CUSTOM_INCLUDE + string "Header for the system time function" + default "Arduino.h" + depends on LV_TICK_CUSTOM + + config LV_DPI_DEF + int "Default Dots Per Inch (in px)." + default 130 + help + Used to initialize default sizes such as widgets sized, style paddings. + (Not so important, you can adjust it to modify default sizes and spaces) + endmenu + + menu "Feature configuration" + + menu "Drawing" + config LV_DRAW_COMPLEX + bool "Enable complex draw engine" + default y + help + Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, + image transformations or any masks. + + config LV_SHADOW_CACHE_SIZE + int "Allow buffering some shadow calculation" + depends on LV_DRAW_COMPLEX + default 0 + help + LV_SHADOW_CACHE_SIZE is the max shadow size to buffer, where + shadow size is `shadow_width + radius`. + Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost. + + config LV_CIRCLE_CACHE_SIZE + int "Set number of maximally cached circle data" + depends on LV_DRAW_COMPLEX + default 4 + help + The circumference of 1/4 circle are saved for anti-aliasing + radius * 4 bytes are used per circle (the most often used + radiuses are saved). + Set to 0 to disable caching. + + config LV_LAYER_SIMPLE_BUF_SIZE + int "Optimal size to buffer the widget with opacity" + default 24576 + help + "Simple layers" are used when a widget has `style_opa < 255` + to buffer the widget into a layer and blend it as an image + with the given opacity. Note that `bg_opa`, `text_opa` etc + don't require buffering into layer. + + config LV_IMG_CACHE_DEF_SIZE + int "Default image cache size. 0 to disable caching." + default 0 + help + If only the built-in image formats are used there is no real advantage of caching. + (I.e. no new image decoder is added). + + With complex image decoders (e.g. PNG or JPG) caching can + save the continuous open/decode of images. + However the opened images might consume additional RAM. + + config LV_GRADIENT_MAX_STOPS + int "Number of stops allowed per gradient." + default 2 + help + Increase this to allow more stops. + This adds (sizeof(lv_color_t) + 1) bytes per additional stop + + config LV_GRAD_CACHE_DEF_SIZE + int "Default gradient buffer size." + default 0 + help + When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. + LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. + If the cache is too small the map will be allocated only while it's required for the drawing. + 0 mean no caching. + + config LV_DITHER_GRADIENT + bool "Allow dithering the gradients" + help + Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) + LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface + The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion + + config LV_DITHER_ERROR_DIFFUSION + bool "Add support for error diffusion dithering" + depends on LV_DITHER_GRADIENT + help + Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. + The increase in memory consumption is (24 bits * object's width) + + config LV_DISP_ROT_MAX_BUF + int "Maximum buffer size to allocate for rotation" + default 10240 + help + Only used if software rotation is enabled in the display driver. + endmenu + + menu "GPU" + config LV_USE_GPU_ARM2D + bool "Enable Arm's 2D image processing library (Arm-2D) for all Cortex-M processors." + default n + help + Must deploy arm-2d library to your project and add include PATH for "arm_2d.h". + + config LV_USE_GPU_STM32_DMA2D + bool "Enable STM32 DMA2D (aka Chrom Art) GPU." + config LV_GPU_DMA2D_CMSIS_INCLUDE + string "include path of CMSIS header of target processor" + depends on LV_USE_GPU_STM32_DMA2D + default "" + help + Must be defined to include path of CMSIS header of target processor + e.g. "stm32f769xx.h" or "stm32f429xx.h" + + config LV_USE_GPU_SWM341_DMA2D + bool "Enable SWM341 DMA2D GPU." + config LV_GPU_SWM341_DMA2D_INCLUDE + string "include path of CMSIS header of target processor" + depends on LV_USE_GPU_SWM341_DMA2D + default "SWM341.h" + help + Must be defined to include path of CMSIS header of target processor + e.g. "SWM341.h" + + config LV_USE_GPU_NXP_PXP + bool "Use NXP's PXP GPU iMX RTxxx platforms." + config LV_USE_GPU_NXP_PXP_AUTO_INIT + bool "Call lv_gpu_nxp_pxp_init() automatically or manually." + depends on LV_USE_GPU_NXP_PXP + help + 1: Add default bare metal and FreeRTOS interrupt handling + routines for PXP (lv_gpu_nxp_pxp_osa.c) and call + lv_gpu_nxp_pxp_init() automatically during lv_init(). + Note that symbol SDK_OS_FREE_RTOS has to be defined in order + to use FreeRTOS OSA, otherwise bare-metal implementation is + selected. + 0: lv_gpu_nxp_pxp_init() has to be called manually before + lv_init(). + + config LV_USE_GPU_NXP_VG_LITE + bool "Use NXP's VG-Lite GPU iMX RTxxx platforms." + + config LV_USE_GPU_SDL + bool "Use SDL renderer API" + default n + config LV_GPU_SDL_INCLUDE_PATH + string "include path of SDL header" + depends on LV_USE_GPU_SDL + default "SDL2/SDL.h" + config LV_GPU_SDL_LRU_SIZE + int "Maximum buffer size to allocate for rotation" + depends on LV_USE_GPU_SDL + default 8388608 + help + Texture cache size, 8MB by default. + endmenu + + menu "Logging" + config LV_USE_LOG + bool "Enable the log module" + + choice + bool "Default log verbosity" if LV_USE_LOG + default LV_LOG_LEVEL_WARN + help + Specify how important log should be added. + + config LV_LOG_LEVEL_TRACE + bool "A lot of logs to give detailed information" + config LV_LOG_LEVEL_INFO + bool "Log important events" + config LV_LOG_LEVEL_WARN + bool "Log if something unwanted happened but didn't cause a problem" + config LV_LOG_LEVEL_ERROR + bool "Only critical issues, when the system may fail" + config LV_LOG_LEVEL_USER + bool "Only logs added by the user" + config LV_LOG_LEVEL_NONE + bool "Do not log anything" + endchoice + + config LV_LOG_LEVEL + int + default 0 if LV_LOG_LEVEL_TRACE + default 1 if LV_LOG_LEVEL_INFO + default 2 if LV_LOG_LEVEL_WARN + default 3 if LV_LOG_LEVEL_ERROR + default 4 if LV_LOG_LEVEL_USER + default 5 if LV_LOG_LEVEL_NONE + + config LV_LOG_PRINTF + bool "Print the log with 'printf'" if LV_USE_LOG + help + Use printf for log output. + If not set the user needs to register a callback with `lv_log_register_print_cb`. + + config LV_LOG_TRACE_MEM + bool "Enable/Disable LV_LOG_TRACE in mem module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_TIMER + bool "Enable/Disable LV_LOG_TRACE in timer module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_INDEV + bool "Enable/Disable LV_LOG_TRACE in indev module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_DISP_REFR + bool "Enable/Disable LV_LOG_TRACE in disp refr module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_EVENT + bool "Enable/Disable LV_LOG_TRACE in event module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_OBJ_CREATE + bool "Enable/Disable LV_LOG_TRACE in obj create module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_LAYOUT + bool "Enable/Disable LV_LOG_TRACE in layout module" + default y + depends on LV_USE_LOG + + config LV_LOG_TRACE_ANIM + bool "Enable/Disable LV_LOG_TRACE in anim module" + default y + depends on LV_USE_LOG + endmenu + + menu "Asserts" + config LV_USE_ASSERT_NULL + bool "Check if the parameter is NULL. (Very fast, recommended)" + default y if !LV_CONF_MINIMAL + + config LV_USE_ASSERT_MALLOC + bool "Checks if the memory is successfully allocated or no. (Very fast, recommended)" + default y if !LV_CONF_MINIMAL + + config LV_USE_ASSERT_STYLE + bool "Check if the styles are properly initialized. (Very fast, recommended)" + + config LV_USE_ASSERT_MEM_INTEGRITY + bool "Check the integrity of `lv_mem` after critical operations. (Slow)" + + config LV_USE_ASSERT_OBJ + bool "Check NULL, the object's type and existence (e.g. not deleted). (Slow)." + + config LV_ASSERT_HANDLER_INCLUDE + string "Header to include for the custom assert function" + default "assert.h" + endmenu + + menu "Others" + config LV_USE_PERF_MONITOR + bool "Show CPU usage and FPS count." + + choice + prompt "Performance monitor position." + depends on LV_USE_PERF_MONITOR + default LV_PERF_MONITOR_ALIGN_BOTTOM_RIGHT + + config LV_PERF_MONITOR_ALIGN_TOP_LEFT + bool "Top left" + config LV_PERF_MONITOR_ALIGN_TOP_MID + bool "Top middle" + config LV_PERF_MONITOR_ALIGN_TOP_RIGHT + bool "Top right" + config LV_PERF_MONITOR_ALIGN_BOTTOM_LEFT + bool "Bottom left" + config LV_PERF_MONITOR_ALIGN_BOTTOM_MID + bool "Bottom middle" + config LV_PERF_MONITOR_ALIGN_BOTTOM_RIGHT + bool "Bottom right" + config LV_PERF_MONITOR_ALIGN_LEFT_MID + bool "Left middle" + config LV_PERF_MONITOR_ALIGN_RIGHT_MID + bool "Right middle" + config LV_PERF_MONITOR_ALIGN_CENTER + bool "Center" + endchoice + + config LV_USE_MEM_MONITOR + bool "Show the used memory and the memory fragmentation." + depends on !LV_MEM_CUSTOM + + choice + prompt "Memory monitor position." + depends on LV_USE_MEM_MONITOR + default LV_MEM_MONITOR_ALIGN_BOTTOM_LEFT + + config LV_MEM_MONITOR_ALIGN_TOP_LEFT + bool "Top left" + config LV_MEM_MONITOR_ALIGN_TOP_MID + bool "Top middle" + config LV_MEM_MONITOR_ALIGN_TOP_RIGHT + bool "Top right" + config LV_MEM_MONITOR_ALIGN_BOTTOM_LEFT + bool "Bottom left" + config LV_MEM_MONITOR_ALIGN_BOTTOM_MID + bool "Bottom middle" + config LV_MEM_MONITOR_ALIGN_BOTTOM_RIGHT + bool "Bottom right" + config LV_MEM_MONITOR_ALIGN_LEFT_MID + bool "Left middle" + config LV_MEM_MONITOR_ALIGN_RIGHT_MID + bool "Right middle" + config LV_MEM_MONITOR_ALIGN_CENTER + bool "Center" + endchoice + + config LV_USE_REFR_DEBUG + bool "Draw random colored rectangles over the redrawn areas." + + config LV_SPRINTF_CUSTOM + bool "Change the built-in (v)snprintf functions" + + config LV_SPRINTF_INCLUDE + string "Header to include for the custom sprintf function" + depends on LV_SPRINTF_CUSTOM + default "stdio.h" + + config LV_SPRINTF_USE_FLOAT + bool "Enable float in built-in (v)snprintf functions" + depends on !LV_SPRINTF_CUSTOM + + config LV_USE_USER_DATA + bool "Add a 'user_data' to drivers and objects." + default y + + config LV_ENABLE_GC + bool "Enable garbage collector" + + config LV_GC_INCLUDE + string "Header to include for the garbage collector related things" + depends on LV_ENABLE_GC + default "gc.h" + endmenu + + menu "Compiler settings" + config LV_BIG_ENDIAN_SYSTEM + bool "For big endian systems set to 1" + + config LV_ATTRIBUTE_MEM_ALIGN_SIZE + int "Required alignment size for buffers" + default 1 + + config LV_ATTRIBUTE_FAST_MEM_USE_IRAM + bool "Set IRAM as LV_ATTRIBUTE_FAST_MEM" + help + Set this option to configure IRAM as LV_ATTRIBUTE_FAST_MEM + + config LV_USE_LARGE_COORD + bool "Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t" + endmenu + endmenu + + menu "Font usage" + menu "Enable built-in fonts" + config LV_FONT_MONTSERRAT_8 + bool "Enable Montserrat 8" + config LV_FONT_MONTSERRAT_10 + bool "Enable Montserrat 10" + config LV_FONT_MONTSERRAT_12 + bool "Enable Montserrat 12" + config LV_FONT_MONTSERRAT_14 + bool "Enable Montserrat 14" + default y if !LV_CONF_MINIMAL + config LV_FONT_MONTSERRAT_16 + bool "Enable Montserrat 16" + config LV_FONT_MONTSERRAT_18 + bool "Enable Montserrat 18" + config LV_FONT_MONTSERRAT_20 + bool "Enable Montserrat 20" + config LV_FONT_MONTSERRAT_22 + bool "Enable Montserrat 22" + config LV_FONT_MONTSERRAT_24 + bool "Enable Montserrat 24" + config LV_FONT_MONTSERRAT_26 + bool "Enable Montserrat 26" + config LV_FONT_MONTSERRAT_28 + bool "Enable Montserrat 28" + config LV_FONT_MONTSERRAT_30 + bool "Enable Montserrat 30" + config LV_FONT_MONTSERRAT_32 + bool "Enable Montserrat 32" + config LV_FONT_MONTSERRAT_34 + bool "Enable Montserrat 34" + config LV_FONT_MONTSERRAT_36 + bool "Enable Montserrat 36" + config LV_FONT_MONTSERRAT_38 + bool "Enable Montserrat 38" + config LV_FONT_MONTSERRAT_40 + bool "Enable Montserrat 40" + config LV_FONT_MONTSERRAT_42 + bool "Enable Montserrat 42" + config LV_FONT_MONTSERRAT_44 + bool "Enable Montserrat 44" + config LV_FONT_MONTSERRAT_46 + bool "Enable Montserrat 46" + config LV_FONT_MONTSERRAT_48 + bool "Enable Montserrat 48" + + config LV_FONT_MONTSERRAT_12_SUBPX + bool "Enable Montserrat 12 sub-pixel" + config LV_FONT_MONTSERRAT_28_COMPRESSED + bool "Enable Montserrat 28 compressed" + config LV_FONT_DEJAVU_16_PERSIAN_HEBREW + bool "Enable Dejavu 16 Persian, Hebrew, Arabic letters" + config LV_FONT_SIMSUN_16_CJK + bool "Enable Simsun 16 CJK" + + config LV_FONT_UNSCII_8 + bool "Enable UNSCII 8 (Perfect monospace font)" + default y if LV_CONF_MINIMAL + config LV_FONT_UNSCII_16 + bool "Enable UNSCII 16 (Perfect monospace font)" + + config LV_FONT_CUSTOM + bool "Enable the custom font" + config LV_FONT_CUSTOM_DECLARE + string "Header to include for the custom font" + depends on LV_FONT_CUSTOM + endmenu + + choice LV_FONT_DEFAULT + prompt "Select theme default title font" + default LV_FONT_DEFAULT_MONTSERRAT_14 if !LV_CONF_MINIMAL + default LV_FONT_DEFAULT_UNSCII_8 if LV_CONF_MINIMAL + help + Select theme default title font + + config LV_FONT_DEFAULT_MONTSERRAT_8 + bool "Montserrat 8" + select LV_FONT_MONTSERRAT_8 + config LV_FONT_DEFAULT_MONTSERRAT_12 + bool "Montserrat 12" + select LV_FONT_MONTSERRAT_12 + config LV_FONT_DEFAULT_MONTSERRAT_14 + bool "Montserrat 14" + select LV_FONT_MONTSERRAT_14 + config LV_FONT_DEFAULT_MONTSERRAT_16 + bool "Montserrat 16" + select LV_FONT_MONTSERRAT_16 + config LV_FONT_DEFAULT_MONTSERRAT_18 + bool "Montserrat 18" + select LV_FONT_MONTSERRAT_18 + config LV_FONT_DEFAULT_MONTSERRAT_20 + bool "Montserrat 20" + select LV_FONT_MONTSERRAT_20 + config LV_FONT_DEFAULT_MONTSERRAT_22 + bool "Montserrat 22" + select LV_FONT_MONTSERRAT_22 + config LV_FONT_DEFAULT_MONTSERRAT_24 + bool "Montserrat 24" + select LV_FONT_MONTSERRAT_24 + config LV_FONT_DEFAULT_MONTSERRAT_26 + bool "Montserrat 26" + select LV_FONT_MONTSERRAT_26 + config LV_FONT_DEFAULT_MONTSERRAT_28 + bool "Montserrat 28" + select LV_FONT_MONTSERRAT_28 + config LV_FONT_DEFAULT_MONTSERRAT_30 + bool "Montserrat 30" + select LV_FONT_MONTSERRAT_30 + config LV_FONT_DEFAULT_MONTSERRAT_32 + bool "Montserrat 32" + select LV_FONT_MONTSERRAT_32 + config LV_FONT_DEFAULT_MONTSERRAT_34 + bool "Montserrat 34" + select LV_FONT_MONTSERRAT_34 + config LV_FONT_DEFAULT_MONTSERRAT_36 + bool "Montserrat 36" + select LV_FONT_MONTSERRAT_36 + config LV_FONT_DEFAULT_MONTSERRAT_38 + bool "Montserrat 38" + select LV_FONT_MONTSERRAT_38 + config LV_FONT_DEFAULT_MONTSERRAT_40 + bool "Montserrat 40" + select LV_FONT_MONTSERRAT_40 + config LV_FONT_DEFAULT_MONTSERRAT_42 + bool "Montserrat 42" + select LV_FONT_MONTSERRAT_42 + config LV_FONT_DEFAULT_MONTSERRAT_44 + bool "Montserrat 44" + select LV_FONT_MONTSERRAT_44 + config LV_FONT_DEFAULT_MONTSERRAT_46 + bool "Montserrat 46" + select LV_FONT_MONTSERRAT_46 + config LV_FONT_DEFAULT_MONTSERRAT_48 + bool "Montserrat 48" + select LV_FONT_MONTSERRAT_48 + config LV_FONT_DEFAULT_MONTSERRAT_12_SUBPX + bool "Montserrat 12 sub-pixel" + select LV_FONT_MONTSERRAT_12_SUBPX + config LV_FONT_DEFAULT_MONTSERRAT_28_COMPRESSED + bool "Montserrat 28 compressed" + select LV_FONT_MONTSERRAT_28_COMPRESSED + config LV_FONT_DEFAULT_DEJAVU_16_PERSIAN_HEBREW + bool "Dejavu 16 Persian, Hebrew, Arabic letters" + select LV_FONT_DEJAVU_16_PERSIAN_HEBREW + config LV_FONT_DEFAULT_SIMSUN_16_CJK + bool "Simsun 16 CJK" + select LV_FONT_SIMSUN_16_CJK + config LV_FONT_DEFAULT_UNSCII_8 + bool "UNSCII 8 (Perfect monospace font)" + select LV_FONT_UNSCII_8 + config LV_FONT_DEFAULT_UNSCII_16 + bool "UNSCII 16 (Perfect monospace font)" + select LV_FONT_UNSCII_16 + endchoice + + config LV_FONT_FMT_TXT_LARGE + bool "Enable it if you have fonts with a lot of characters." + help + The limit depends on the font size, font face and bpp + but with > 10,000 characters if you see issues probably you + need to enable it. + + config LV_USE_FONT_COMPRESSED + bool "Sets support for compressed fonts." + + config LV_USE_FONT_SUBPX + bool "Enable subpixel rendering." + + config LV_FONT_SUBPX_BGR + bool "Use BGR instead RGB for sub-pixel rendering." + depends on LV_USE_FONT_SUBPX + help + Set the pixel order of the display. + Important only if "subpx fonts" are used. + With "normal" font it doesn't matter. + + config LV_USE_FONT_PLACEHOLDER + bool "Enable drawing placeholders when glyph dsc is not found." + default y + endmenu + + menu "Text Settings" + choice LV_TXT_ENC + prompt "Select a character encoding for strings" + help + Select a character encoding for strings. Your IDE or editor should have the same character encoding. + default LV_TXT_ENC_UTF8 if !LV_CONF_MINIMAL + default LV_TXT_ENC_ASCII if LV_CONF_MINIMAL + + config LV_TXT_ENC_UTF8 + bool "UTF8" + config LV_TXT_ENC_ASCII + bool "ASCII" + endchoice + + config LV_TXT_BREAK_CHARS + string "Can break (wrap) texts on these chars" + default " ,.;:-_" + + config LV_TXT_LINE_BREAK_LONG_LEN + int "Line break long length" + default 0 + help + If a word is at least this long, will break wherever 'prettiest'. + To disable, set to a value <= 0. + + config LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN + int "Min num chars before break" + default 3 + depends on LV_TXT_LINE_BREAK_LONG_LEN > 0 + help + Minimum number of characters in a long word to put on a line before a break. + + config LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN + int "Min num chars after break" + default 3 + depends on LV_TXT_LINE_BREAK_LONG_LEN > 0 + help + Minimum number of characters in a long word to put on a line after a break. + + config LV_TXT_COLOR_CMD + string "The control character to use for signalling text recoloring" + default "#" + + config LV_USE_BIDI + bool "Support bidirectional texts" + help + Allows mixing Left-to-Right and Right-to-Left texts. + The direction will be processed according to the Unicode Bidirectional Algorithm: + https://www.w3.org/International/articles/inline-bidi-markup/uba-basics + + choice + prompt "Set the default BIDI direction" + default LV_BIDI_DIR_AUTO + depends on LV_USE_BIDI + + config LV_BIDI_DIR_LTR + bool "Left-to-Right" + config LV_BIDI_DIR_RTL + bool "Right-to-Left" + config LV_BIDI_DIR_AUTO + bool "Detect texts base direction" + endchoice + + config LV_USE_ARABIC_PERSIAN_CHARS + bool "Enable Arabic/Persian processing" + help + In these languages characters should be replaced with + an other form based on their position in the text. + endmenu + + menu "Widget usage" + config LV_USE_ARC + bool "Arc." + default y if !LV_CONF_MINIMAL + config LV_USE_BAR + bool "Bar." + default y if !LV_CONF_MINIMAL + config LV_USE_BTN + bool "Button." + default y if !LV_CONF_MINIMAL + config LV_USE_BTNMATRIX + bool "Button matrix." + default y if !LV_CONF_MINIMAL + config LV_USE_CANVAS + bool "Canvas. Dependencies: lv_img." + select LV_USE_IMG + default y if !LV_CONF_MINIMAL + config LV_USE_CHECKBOX + bool "Check Box" + default y if !LV_CONF_MINIMAL + config LV_USE_DROPDOWN + bool "Drop down list. Requires: lv_label." + select LV_USE_LABEL + default y if !LV_CONF_MINIMAL + config LV_USE_IMG + bool "Image. Requires: lv_label." + select LV_USE_LABEL + default y if !LV_CONF_MINIMAL + config LV_USE_LABEL + bool "Label." + default y if !LV_CONF_MINIMAL + config LV_LABEL_TEXT_SELECTION + bool "Enable selecting text of the label." + depends on LV_USE_LABEL + default y + config LV_LABEL_LONG_TXT_HINT + bool "Store extra some info in labels (12 bytes) to speed up drawing of very long texts." + depends on LV_USE_LABEL + default y + config LV_USE_LINE + bool "Line." + default y if !LV_CONF_MINIMAL + config LV_USE_ROLLER + bool "Roller. Requires: lv_label." + select LV_USE_LABEL + default y if !LV_CONF_MINIMAL + config LV_ROLLER_INF_PAGES + int "Number of extra 'pages' when the controller is infinite." + default 7 + depends on LV_USE_ROLLER + config LV_USE_SLIDER + bool "Slider. Requires: lv_bar." + select LV_USE_BAR + default y if !LV_CONF_MINIMAL + config LV_USE_SWITCH + bool "Switch." + default y if !LV_CONF_MINIMAL + config LV_USE_TEXTAREA + bool "Text area. Requires: lv_label." + select LV_USE_LABEL + default y if !LV_CONF_MINIMAL + config LV_TEXTAREA_DEF_PWD_SHOW_TIME + int "Text area def. pwd show time [ms]." + default 1500 + depends on LV_USE_TEXTAREA + config LV_USE_TABLE + bool "Table." + default y if !LV_CONF_MINIMAL + endmenu + + menu "Extra Widgets" + config LV_USE_ANIMIMG + bool "Anim image." + default y if !LV_CONF_MINIMAL + config LV_USE_CALENDAR + bool "Calendar." + default y if !LV_CONF_MINIMAL + config LV_CALENDAR_WEEK_STARTS_MONDAY + bool "Calendar week starts monday." + depends on LV_USE_CALENDAR + config LV_USE_CALENDAR_HEADER_ARROW + bool "Use calendar header arrow" + depends on LV_USE_CALENDAR + default y + config LV_USE_CALENDAR_HEADER_DROPDOWN + bool "Use calendar header dropdown" + depends on LV_USE_CALENDAR + default y + config LV_USE_CHART + bool "Chart." + default y if !LV_CONF_MINIMAL + config LV_USE_COLORWHEEL + bool "Colorwheel." + default y if !LV_CONF_MINIMAL + config LV_USE_IMGBTN + bool "Imgbtn." + default y if !LV_CONF_MINIMAL + config LV_USE_KEYBOARD + bool "Keyboard." + default y if !LV_CONF_MINIMAL + config LV_USE_LED + bool "LED." + default y if !LV_CONF_MINIMAL + config LV_USE_LIST + bool "List." + default y if !LV_CONF_MINIMAL + config LV_USE_MENU + bool "Menu." + default y if !LV_CONF_MINIMAL + config LV_USE_METER + bool "Meter." + default y if !LV_CONF_MINIMAL + config LV_USE_MSGBOX + bool "Msgbox." + default y if !LV_CONF_MINIMAL + config LV_USE_SPAN + bool "span" + default y if !LV_CONF_MINIMAL + config LV_SPAN_SNIPPET_STACK_SIZE + int "Maximum number of span descriptor" + default 64 + depends on LV_USE_SPAN + config LV_USE_SPINBOX + bool "Spinbox." + default y if !LV_CONF_MINIMAL + config LV_USE_SPINNER + bool "Spinner." + default y if !LV_CONF_MINIMAL + config LV_USE_TABVIEW + bool "Tabview." + default y if !LV_CONF_MINIMAL + config LV_USE_TILEVIEW + bool "Tileview" + default y if !LV_CONF_MINIMAL + config LV_USE_WIN + bool "Win" + default y if !LV_CONF_MINIMAL + endmenu + + menu "Themes" + config LV_USE_THEME_DEFAULT + bool "A simple, impressive and very complete theme" + default y if !LV_COLOR_DEPTH_1 && !LV_CONF_MINIMAL + config LV_THEME_DEFAULT_DARK + bool "Yes to set dark mode, No to set light mode" + depends on LV_USE_THEME_DEFAULT + config LV_THEME_DEFAULT_GROW + bool "Enable grow on press" + default y + depends on LV_USE_THEME_DEFAULT + config LV_THEME_DEFAULT_TRANSITION_TIME + int "Default transition time in [ms]" + default 80 + depends on LV_USE_THEME_DEFAULT + config LV_USE_THEME_BASIC + bool "A very simple theme that is a good starting point for a custom theme" + default y if !LV_COLOR_DEPTH_1 && !LV_CONF_MINIMAL + config LV_USE_THEME_MONO + bool "Monochrome theme, suitable for some E-paper & dot matrix displays" + default y if LV_COLOR_DEPTH_1 && !LV_CONF_MINIMAL + endmenu + + menu "Layouts" + config LV_USE_FLEX + bool "A layout similar to Flexbox in CSS." + default y if !LV_CONF_MINIMAL + config LV_USE_GRID + bool "A layout similar to Grid in CSS." + default y if !LV_CONF_MINIMAL + endmenu + + menu "3rd Party Libraries" + config LV_USE_FS_STDIO + bool "File system on top of stdio API" + config LV_FS_STDIO_LETTER + int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65 )" + default 0 + depends on LV_USE_FS_STDIO + config LV_FS_STDIO_PATH + string "Set the working directory" + depends on LV_USE_FS_STDIO + config LV_FS_STDIO_CACHE_SIZE + string ">0 to cache this number of bytes in lv_fs_read()" + depends on LV_USE_FS_STDIO + + config LV_USE_FS_POSIX + bool "File system on top of posix API" + config LV_FS_POSIX_LETTER + int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65)" + default 0 + depends on LV_USE_FS_POSIX + config LV_FS_POSIX_PATH + string "Set the working directory" + depends on LV_USE_FS_POSIX + config LV_FS_POSIX_CACHE_SIZE + int ">0 to cache this number of bytes in lv_fs_read()" + default 0 + depends on LV_USE_FS_POSIX + + config LV_USE_FS_WIN32 + bool "File system on top of Win32 API" + config LV_FS_WIN32_LETTER + int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65)" + default 0 + depends on LV_USE_FS_WIN32 + config LV_FS_WIN32_PATH + string "Set the working directory" + depends on LV_USE_FS_WIN32 + config LV_FS_WIN32_CACHE_SIZE + int ">0 to cache this number of bytes in lv_fs_read()" + default 0 + depends on LV_USE_FS_WIN32 + + config LV_USE_FS_FATFS + bool "File system on top of FatFS" + config LV_FS_FATFS_LETTER + int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65)" + default 0 + depends on LV_USE_FS_FATFS + config LV_FS_FATFS_CACHE_SIZE + int ">0 to cache this number of bytes in lv_fs_read()" + default 0 + depends on LV_USE_FS_FATFS + + config LV_USE_PNG + bool "PNG decoder library" + + config LV_USE_BMP + bool "BMP decoder library" + + config LV_USE_SJPG + bool "JPG + split JPG decoder library" + + config LV_USE_GIF + bool "GIF decoder library" + + config LV_USE_QRCODE + bool "QR code library" + + config LV_USE_FREETYPE + bool "FreeType library" + if LV_USE_FREETYPE + menu "FreeType cache config" + config LV_FREETYPE_CACHE_SIZE + int "Memory used by FreeType to cache characters [bytes] (-1: no caching)" + default 16384 + if LV_FREETYPE_CACHE_SIZE >= 0 + config LV_FREETYPE_SBIT_CACHE + bool "enable sbit cache" + default n + config LV_FREETYPE_CACHE_FT_FACES + int "The maximum number of FT_Face(0: use defaults)" + default 0 + config LV_FREETYPE_CACHE_FT_SIZES + int "The maximum number of FT_Size(0: use defaults)" + default 0 + endif + endmenu + endif + + config LV_USE_RLOTTIE + bool "Lottie library" + + config LV_USE_FFMPEG + bool "FFmpeg library" + config LV_FFMPEG_DUMP_FORMAT + bool "Dump format" + depends on LV_USE_FFMPEG + default n + endmenu + + menu "Others" + config LV_USE_SNAPSHOT + bool "Enable API to take snapshot" + default y if !LV_CONF_MINIMAL + + config LV_USE_MONKEY + bool "Enable Monkey test" + default n + + config LV_USE_GRIDNAV + bool "Enable grid navigation" + default n + + config LV_USE_FRAGMENT + bool "Enable lv_obj fragment" + default n + + config LV_USE_IMGFONT + bool "draw img in label or span obj" + default n + + config LV_USE_MSG + bool "Enable a published subscriber based messaging system" + default n + + config LV_USE_IME_PINYIN + bool "Enable Pinyin input method" + default n + config LV_IME_PINYIN_USE_K9_MODE + bool "Enable Pinyin input method 9 key input mode" + depends on LV_USE_IME_PINYIN + default n + config LV_IME_PINYIN_K9_CAND_TEXT_NUM + int "Maximum number of candidate panels for 9-key input mode" + depends on LV_IME_PINYIN_USE_K9_MODE + default 3 + config LV_IME_PINYIN_USE_DEFAULT_DICT + bool "Use built-in Thesaurus" + depends on LV_USE_IME_PINYIN + default y + help + If you do not use the default thesaurus, be sure to use lv_ime_pinyin after setting the thesauruss + config LV_IME_PINYIN_CAND_TEXT_NUM + int "Maximum number of candidate panels" + depends on LV_USE_IME_PINYIN + default 6 + help + Set the maximum number of candidate panels that can be displayed. + This needs to be adjusted according to the size of the screen. + endmenu + + menu "Examples" + config LV_BUILD_EXAMPLES + bool "Enable the examples to be built" + default y if !LV_CONF_MINIMAL + endmenu + + menu "Demos" + config LV_USE_DEMO_WIDGETS + bool "Show some widget" + default n + config LV_DEMO_WIDGETS_SLIDESHOW + bool "Enable slide show" + depends on LV_USE_DEMO_WIDGETS + default n + + config LV_USE_DEMO_KEYPAD_AND_ENCODER + bool "Demonstrate the usage of encoder and keyboard" + default n + + config LV_USE_DEMO_BENCHMARK + bool "Benchmark your system" + default n + config LV_DEMO_BENCHMARK_RGB565A8 + bool "Use RGB565A8 images with 16 bit color depth instead of ARGB8565" + depends on LV_USE_DEMO_BENCHMARK + default n + + config LV_USE_DEMO_STRESS + bool "Stress test for LVGL" + default n + + config LV_USE_DEMO_MUSIC + bool "Music player demo" + default n + config LV_DEMO_MUSIC_SQUARE + bool "Enable Square" + depends on LV_USE_DEMO_MUSIC + default n + config LV_DEMO_MUSIC_LANDSCAPE + bool "Enable Landscape" + depends on LV_USE_DEMO_MUSIC + default n + config LV_DEMO_MUSIC_ROUND + bool "Enable Round" + depends on LV_USE_DEMO_MUSIC + default n + config LV_DEMO_MUSIC_LARGE + bool "Enable Large" + depends on LV_USE_DEMO_MUSIC + default n + config LV_DEMO_MUSIC_AUTO_PLAY + bool "Enable Auto play" + depends on LV_USE_DEMO_MUSIC + default n + endmenu + +endmenu diff --git a/graphics/lvgl/lv_fs_interface.c b/graphics/lvgl/lv_fs_interface.c deleted file mode 100644 index b75c2bf0d..000000000 --- a/graphics/lvgl/lv_fs_interface.c +++ /dev/null @@ -1,575 +0,0 @@ -/**************************************************************************** - * apps/graphics/lvgl/lv_fs_interface.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "lv_fs_interface.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define LV_FS_LETTER '/' - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/* Create a type to store the required data about your file. */ - -typedef int file_t; - -/* Similarly to `file_t` create a type for directory reading too */ - -typedef DIR *dir_t; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static lv_fs_res_t fs_open(lv_fs_drv_t *drv, void *file_p, - const char *path, lv_fs_mode_t mode); -static lv_fs_res_t fs_close(lv_fs_drv_t *drv, void *file_p); -static lv_fs_res_t fs_read(lv_fs_drv_t *drv, void *file_p, - void *buf, uint32_t btr, uint32_t *br); -static lv_fs_res_t fs_write(lv_fs_drv_t *drv, void *file_p, - const void *buf, uint32_t btw, uint32_t *bw); -static lv_fs_res_t fs_seek(lv_fs_drv_t *drv, void *file_p, - uint32_t pos); -static lv_fs_res_t fs_size(lv_fs_drv_t *drv, void *file_p, - uint32_t *size_p); -static lv_fs_res_t fs_tell(lv_fs_drv_t *drv, void *file_p, - uint32_t *pos_p); -static lv_fs_res_t fs_remove(lv_fs_drv_t *drv, const char *path); -static lv_fs_res_t fs_trunc(lv_fs_drv_t *drv, void *file_p); -static lv_fs_res_t fs_rename(lv_fs_drv_t *drv, const char *oldname, - const char *newname); -static lv_fs_res_t fs_free(lv_fs_drv_t *drv, uint32_t *total_p, - uint32_t *free_p); -static lv_fs_res_t fs_dir_open(lv_fs_drv_t *drv, void *dir_p, - const char *path); -static lv_fs_res_t fs_dir_read(lv_fs_drv_t *drv, void *dir_p, char *fn); -static lv_fs_res_t fs_dir_close(lv_fs_drv_t *drv, void *dir_p); - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: fs_open - * - * Description: - * Open a file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * path - path to the file beginning with the driver letter. - * (e.g. /folder/file.txt) - * mode - read: FS_MODE_RD, write: FS_MODE_WR, - * both: FS_MODE_RD | FS_MODE_WR - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_open(lv_fs_drv_t *drv, void *file_p, - const char *path, lv_fs_mode_t mode) -{ - uint32_t flags = 0; - if (mode == LV_FS_MODE_WR) - { - flags = O_WRONLY | O_CREAT; - } - else if (mode == LV_FS_MODE_RD) - { - flags = O_RDONLY; - } - else if (mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) - { - flags = O_RDWR | O_CREAT; - } - else - { - return LV_FS_RES_UNKNOWN; - } - - file_t f = open(--path, flags); - if (f < 0) - { - return LV_FS_RES_FS_ERR; - } - - /* 'file_p' is pointer to a file descriptor and - * we need to store our file descriptor here - */ - - file_t *fp = file_p; /* Just avoid the confusing casings */ - *fp = f; - - return LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_close - * - * Description: - * Close an opened file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * - * Returned Value: - * LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_close(lv_fs_drv_t *drv, void *file_p) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - return close(*fp) < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_read - * - * Description: - * Read data from an opened file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * buf - pointer to a memory block where to store the read data. - * btr - number of Bytes To Read. - * br - the real number of read bytes (Byte Read). - * - * Returned Value: - * LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_read(lv_fs_drv_t *drv, void *file_p, - void *buf, uint32_t btr, uint32_t *br) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - *br = read(*fp, buf, btr); - - return (int32_t)*br < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_write - * - * Description: - * Write into a file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * buf - pointer to a buffer with the bytes to write. - * btw - Bytes To Write. - * bw - the number of real written bytes (Bytes Written). - * NULL if unused. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_write(lv_fs_drv_t *drv, void *file_p, - const void *buf, uint32_t btw, uint32_t *bw) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - *bw = write(*fp, buf, btw); - - return (int32_t)*bw < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_seek - * - * Description: - * Set the read write pointer. Also expand the file size if necessary. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * pos - the new position of read write pointer. - * - * Returned Value: - * LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_seek(lv_fs_drv_t *drv, void *file_p, uint32_t pos) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - off_t offset = lseek(*fp, pos, SEEK_SET); - - return offset < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_size - * - * Description: - * Give the size of a file bytes. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * size - pointer to a variable to store the size. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_size(lv_fs_drv_t *drv, void *file_p, - uint32_t *size_p) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - off_t cur = lseek(*fp, 0, SEEK_CUR); - - *size_p = lseek(*fp, 0L, SEEK_END); - - /* Restore file pointer */ - - lseek(*fp, cur, SEEK_SET); - - return (int32_t)*size_p < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_tell - * - * Description: - * Give the position of the read write pointer. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * pos_p - pointer to to store the result. - * - * Returned Value: - * LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_tell(lv_fs_drv_t *drv, void *file_p, - uint32_t *pos_p) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - *pos_p = lseek(*fp, 0, SEEK_CUR); - - return (int32_t)*pos_p < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_remove - * - * Description: - * Delete a file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * path - path of the file to delete. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_remove(lv_fs_drv_t *drv, const char *path) -{ - return remove(--path) < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_trunc - * - * Description: - * Truncate the file size to the current position of - * the read write pointer. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * file_p - pointer to a file_t variable. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_trunc(lv_fs_drv_t *drv, void *file_p) -{ - /* Just avoid the confusing casings */ - - file_t *fp = file_p; - - off_t p = lseek(*fp, 0, SEEK_CUR); - - return ftruncate(*fp, p) < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_rename - * - * Description: - * Rename a file. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * oldname - path to the file. - * newname - path with the new name - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_rename(lv_fs_drv_t *drv, const char *oldname, - const char *newname) -{ - return rename(--oldname, --newname) < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_free - * - * Description: - * Get the free and total size of a driver in kB. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * total_p - pointer to store the total size [kB]. - * free_p - pointer to store the free size [kB] - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_free(lv_fs_drv_t *drv, uint32_t *total_p, - uint32_t *free_p) -{ - struct statfs sfs; - - if (statfs(CONFIG_LV_FILESYSTEM_MOUNTPOINT, &sfs) < 0) - { - return LV_FS_RES_FS_ERR; - } - else - { - *total_p = sfs.f_blocks * sfs.f_bsize / 1024; - *free_p = sfs.f_bfree * sfs.f_bsize / 1024; - return LV_FS_RES_OK; - } -} - -/**************************************************************************** - * Name: fs_dir_open - * - * Description: - * Initialize a 'fs_read_dir_t' variable for directory reading. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * dir_p - pointer to a 'fs_read_dir_t' variable. - * path - path to a directory. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_dir_open(lv_fs_drv_t *drv, void *dir_p, - const char *path) -{ - dir_t d; - - /* Make the path relative to the current directory - * (the projects root folder) - */ - - if ((d = opendir(--path)) == NULL) - { - return LV_FS_RES_FS_ERR; - } - else - { - /* 'dir_p' is pointer to a file descriptor and - * we need to store our file descriptor here - */ - - /* Just avoid the confusing casings */ - - dir_t *dp = dir_p; - *dp = d; - } - - return LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_dir_read - * - * Description: - * Read the next filename form a directory. - * The name of the directories will begin with '/'. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * dir_p - pointer to an initialized 'fs_read_dir_t' variable. - * fn - pointer to a buffer to store the filename. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_dir_read(lv_fs_drv_t *drv, void *dir_p, char *fn) -{ - /* Just avoid the confusing casings */ - - dir_t *dp = dir_p; - - do - { - struct dirent *entry = readdir(*dp); - - if (entry) - { - if (entry->d_type == DT_DIR) - { - sprintf(fn, "/%s", entry->d_name); - } - else - { - strcpy(fn, entry->d_name); - } - } - else - { - strcpy(fn, ""); - } - } - while (strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0); - - return LV_FS_RES_OK; -} - -/**************************************************************************** - * Name: fs_dir_read - * - * Description: - * Close the directory reading. - * - * Input Parameters: - * drv - pointer to a driver where this function belongs. - * dir_p - pointer to an initialized 'fs_read_dir_t' variable. - * - * Returned Value: - * LV_FS_RES_OK or any error from lv_fs_res_t enum. - * - ****************************************************************************/ - -static lv_fs_res_t fs_dir_close(lv_fs_drv_t *drv, void *dir_p) -{ - dir_t *dp = dir_p; - - return closedir(*dp) < 0 ? LV_FS_RES_FS_ERR : LV_FS_RES_OK; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: lv_fs_interface_init - * - * Description: - * Register a driver for the File system interface. - * - ****************************************************************************/ - -void lv_fs_interface_init(void) -{ - /* Add a simple drive to open images */ - - lv_fs_drv_t fs_drv; /* A driver descriptor */ - - lv_fs_drv_init(&fs_drv); - - /* Set up fields... */ - - fs_drv.file_size = sizeof(file_t); - fs_drv.letter = LV_FS_LETTER; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; - fs_drv.free_space_cb = fs_free; - fs_drv.size_cb = fs_size; - fs_drv.remove_cb = fs_remove; - fs_drv.rename_cb = fs_rename; - fs_drv.trunc_cb = fs_trunc; - - fs_drv.rddir_size = sizeof(dir_t); - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; - - lv_fs_drv_register(&fs_drv); -} diff --git a/graphics/lvgl/port/lv_port.c b/graphics/lvgl/port/lv_port.c new file mode 100644 index 000000000..c5056d927 --- /dev/null +++ b/graphics/lvgl/port/lv_port.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "lv_port.h" +#include "lv_port_button.h" +#include "lv_port_encoder.h" +#include "lv_port_fbdev.h" +#include "lv_port_lcddev.h" +#include "lv_port_mem.h" +#include "lv_port_keypad.h" +#include "lv_port_syslog.h" +#include "lv_port_touchpad.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_init + * + * Description: + * Initialize all porting. + * + ****************************************************************************/ + +void lv_port_init(void) +{ +#if defined(CONFIG_LV_USE_LOG) + lv_port_syslog_init(); +#endif + +#if defined(CONFIG_LV_PORT_USE_LCDDEV) + lv_port_lcddev_init(NULL, 0); +#endif + +#if defined(CONFIG_LV_PORT_USE_FBDEV) + lv_port_fbdev_init(NULL); +#endif + +#if defined(CONFIG_LV_PORT_USE_BUTTON) + lv_port_button_init(NULL); + +#if defined(CONFIG_UINPUT_BUTTON) + lv_port_button_init("/dev/ubutton"); +#endif + +#endif + +#if defined(CONFIG_LV_PORT_USE_KEYPAD) + lv_port_keypad_init(NULL); + +#if defined(CONFIG_UINPUT_BUTTON) + lv_port_keypad_init("/dev/ubutton"); +#endif + +#endif + +#if defined(CONFIG_LV_PORT_USE_TOUCHPAD) + lv_port_touchpad_init(NULL); + +#if defined(CONFIG_UINPUT_TOUCH) + lv_port_touchpad_init("/dev/utouch"); +#endif + +#endif + +#if defined(CONFIG_LV_PORT_USE_ENCODER) + lv_port_encoder_init(NULL); +#endif +} diff --git a/graphics/lvgl/lv_fs_interface.h b/graphics/lvgl/port/lv_port.h similarity index 82% rename from graphics/lvgl/lv_fs_interface.h rename to graphics/lvgl/port/lv_port.h index a02558ef7..3b48525b5 100644 --- a/graphics/lvgl/lv_fs_interface.h +++ b/graphics/lvgl/port/lv_port.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/graphics/lvgl/lv_fs_interface.h + * apps/graphics/lvgl/port/lv_port.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,22 +18,17 @@ * ****************************************************************************/ -#ifndef __APPS_GRAPHICS_LVGL_LV_FS_INTERFACE_H -#define __APPS_GRAPHICS_LVGL_LV_FS_INTERFACE_H +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_H /**************************************************************************** * Included Files ****************************************************************************/ -#include -#include - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#if LV_USE_FILESYSTEM - /**************************************************************************** * Type Definitions ****************************************************************************/ @@ -54,13 +49,19 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -void lv_fs_interface_init(void); +/**************************************************************************** + * Name: lv_port_init + * + * Description: + * Initialize all porting. + * + ****************************************************************************/ + +void lv_port_init(void); #undef EXTERN #ifdef __cplusplus } #endif -#endif /* LV_USE_FILESYSTEM */ - -#endif /* __APPS_GRAPHICS_LVGL_LV_FS_INTERFACE_H */ +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_H */ diff --git a/graphics/lvgl/port/lv_port_button.c b/graphics/lvgl/port/lv_port_button.c new file mode 100644 index 000000000..7bf215009 --- /dev/null +++ b/graphics/lvgl/port/lv_port_button.c @@ -0,0 +1,238 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_button.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_button.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define BUTTON_0_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_0_MAP_X +#define BUTTON_0_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_0_MAP_Y +#define BUTTON_1_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_1_MAP_X +#define BUTTON_1_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_1_MAP_Y +#define BUTTON_2_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_2_MAP_X +#define BUTTON_2_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_2_MAP_Y +#define BUTTON_3_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_3_MAP_X +#define BUTTON_3_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_3_MAP_Y +#define BUTTON_4_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_4_MAP_X +#define BUTTON_4_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_4_MAP_Y +#define BUTTON_5_MAP_X CONFIG_LV_PORT_BUTTON_BUTTON_5_MAP_X +#define BUTTON_5_MAP_Y CONFIG_LV_PORT_BUTTON_BUTTON_5_MAP_Y + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct button_obj_s +{ + int fd; + uint8_t last_btn; + lv_indev_drv_t indev_drv; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Assign buttons to points on the screen */ + +static const lv_point_t g_button_points_map[6] = +{ + {BUTTON_0_MAP_X, BUTTON_0_MAP_Y}, + {BUTTON_1_MAP_X, BUTTON_1_MAP_Y}, + {BUTTON_2_MAP_X, BUTTON_2_MAP_Y}, + {BUTTON_3_MAP_X, BUTTON_3_MAP_Y}, + {BUTTON_4_MAP_X, BUTTON_4_MAP_Y}, + {BUTTON_5_MAP_X, BUTTON_5_MAP_Y} +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: button_get_pressed_id + ****************************************************************************/ + +static int button_get_pressed_id(int fd) +{ + int btn_act = -1; + btn_buttonset_t buttonset; + const int buttonset_bits = sizeof(btn_buttonset_t) * 8; + int bit; + + int ret = read(fd, &buttonset, sizeof(btn_buttonset_t)); + if (ret < 0) + { + return -1; + } + + for (bit = 0; bit < buttonset_bits; bit++) + { + btn_buttonset_t mask = (btn_buttonset_t)(1 << bit); + + if ((buttonset & mask) != 0) + { + btn_act = bit; + break; + } + } + + return btn_act; +} + +/**************************************************************************** + * Name: button_read + ****************************************************************************/ + +static void button_read(FAR lv_indev_drv_t *drv, FAR lv_indev_data_t *data) +{ + FAR struct button_obj_s *button_obj = drv->user_data; + + /* Get the pressed button's ID */ + + int btn_act = button_get_pressed_id(button_obj->fd); + + if (btn_act >= 0) + { + data->state = LV_INDEV_STATE_PR; + button_obj->last_btn = btn_act; + } + else + { + data->state = LV_INDEV_STATE_REL; + } + + /* Save the last pressed button's ID */ + + data->btn_id = button_obj->last_btn; +} + +/**************************************************************************** + * Name: button_init + ****************************************************************************/ + +static FAR lv_indev_t *button_init(int fd) +{ + FAR struct button_obj_s *button_obj; + FAR lv_indev_t *indev_button; + + button_obj = malloc(sizeof(struct button_obj_s)); + + if (button_obj == NULL) + { + LV_LOG_ERROR("button_obj_s malloc failed"); + return NULL; + } + + button_obj->fd = fd; + button_obj->last_btn = 0; + + lv_indev_drv_init(&(button_obj->indev_drv)); + button_obj->indev_drv.type = LV_INDEV_TYPE_BUTTON; + button_obj->indev_drv.read_cb = button_read; +#if ( LV_USE_USER_DATA != 0 ) + button_obj->indev_drv.user_data = button_obj; +#else +#error LV_USE_USER_DATA must be enabled +#endif + indev_button = lv_indev_drv_register(&(button_obj->indev_drv)); + lv_indev_set_button_points(indev_button, g_button_points_map); + + return indev_button; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_button_init + * + * Description: + * Button interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_button_init(FAR const char *dev_path) +{ + FAR const char *device_path = dev_path; + FAR lv_indev_t *indev; + int fd; + btn_buttonset_t supported; + int ret; + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_BUTTON_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("button %s opening", device_path); + fd = open(device_path, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + LV_LOG_ERROR("button %s open failed: %d", device_path, errno); + return NULL; + } + + /* Get the set of BUTTONs supported */ + + ret = ioctl(fd, BTNIOC_SUPPORTED, + (unsigned long)((uintptr_t)&supported)); + if (ret < 0) + { + LV_LOG_ERROR("button ioctl(BTNIOC_SUPPORTED) failed: %d", errno); + return NULL; + } + + LV_LOG_INFO("button supported BUTTONs 0x%08x", (unsigned int)supported); + + indev = button_init(fd); + + if (indev == NULL) + { + close(fd); + } + + return indev; +} diff --git a/graphics/lvgl/port/lv_port_button.h b/graphics/lvgl/port/lv_port_button.h new file mode 100644 index 000000000..12bf133e3 --- /dev/null +++ b/graphics/lvgl/port/lv_port_button.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_button.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_BUTTON_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_BUTTON_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_BUTTON) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_button_init + * + * Description: + * Button interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_button_init(FAR const char *dev_path); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_BUTTON */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_BUTTON_H */ diff --git a/graphics/lvgl/port/lv_port_encoder.c b/graphics/lvgl/port/lv_port_encoder.c new file mode 100644 index 000000000..d079b886f --- /dev/null +++ b/graphics/lvgl/port/lv_port_encoder.c @@ -0,0 +1,162 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_encoder.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_encoder.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct encoder_obj_s +{ + int fd; + lv_indev_state_t last_state; + lv_indev_drv_t indev_drv; +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: encoder_read + ****************************************************************************/ + +static void encoder_read(FAR lv_indev_drv_t *drv, FAR lv_indev_data_t *data) +{ + FAR struct encoder_obj_s *encoder_obj = drv->user_data; + + /* Read one sample */ + + struct mouse_report_s sample; + int16_t wheel = 0; + + int nbytes = read(encoder_obj->fd, &sample, + sizeof(struct mouse_report_s)); + + /* Handle unexpected return values */ + + if (nbytes == sizeof(struct mouse_report_s)) + { + wheel = sample.wheel; + encoder_obj->last_state = (sample.buttons & MOUSE_BUTTON_3) ? + LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; + } + + /* Update encoder data */ + + data->enc_diff = wheel; + data->state = encoder_obj->last_state; +} + +/**************************************************************************** + * Name: encoder_init + ****************************************************************************/ + +static FAR lv_indev_t *encoder_init(int fd) +{ + FAR struct encoder_obj_s *encoder_obj; + encoder_obj = malloc(sizeof(struct encoder_obj_s)); + + if (encoder_obj == NULL) + { + LV_LOG_ERROR("encoder_obj_s malloc failed"); + return NULL; + } + + encoder_obj->fd = fd; + encoder_obj->last_state = LV_INDEV_STATE_RELEASED; + + lv_indev_drv_init(&(encoder_obj->indev_drv)); + encoder_obj->indev_drv.type = LV_INDEV_TYPE_ENCODER; + encoder_obj->indev_drv.read_cb = encoder_read; +#if ( LV_USE_USER_DATA != 0 ) + encoder_obj->indev_drv.user_data = encoder_obj; +#else +#error LV_USE_USER_DATA must be enabled +#endif + return lv_indev_drv_register(&(encoder_obj->indev_drv)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_encoder_init + * + * Description: + * Encoder interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path. + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_encoder_init(FAR const char *dev_path) +{ + FAR const char *device_path = dev_path; + FAR lv_indev_t *indev; + int fd; + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_ENCODER_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("encoder %s opening", device_path); + fd = open(device_path, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + LV_LOG_ERROR("encoder %s open failed: %d", device_path, errno); + return NULL; + } + + LV_LOG_INFO("encoder %s open success", device_path); + + indev = encoder_init(fd); + + if (indev == NULL) + { + close(fd); + } + + return indev; +} diff --git a/graphics/lvgl/port/lv_port_encoder.h b/graphics/lvgl/port/lv_port_encoder.h new file mode 100644 index 000000000..89465298f --- /dev/null +++ b/graphics/lvgl/port/lv_port_encoder.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_encoder.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_ENCODER_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_ENCODER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_ENCODER) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_encoder_init + * + * Description: + * Encoder interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path. + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_encoder_init(FAR const char *dev_path); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_ENCODER */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_ENCODER_H */ diff --git a/graphics/lvgl/port/lv_port_fbdev.c b/graphics/lvgl/port/lv_port_fbdev.c new file mode 100644 index 000000000..3200535b6 --- /dev/null +++ b/graphics/lvgl/port/lv_port_fbdev.c @@ -0,0 +1,673 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_fbdev.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_fbdev.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_FB_UPDATE) +# define FBDEV_UPDATE_AREA(obj, area) fbdev_update_area(obj, area) +#else +# define FBDEV_UPDATE_AREA(obj, area) +#endif + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct fbdev_obj_s +{ + lv_disp_draw_buf_t disp_draw_buf; + lv_disp_drv_t disp_drv; + FAR lv_disp_t *disp; + FAR void *last_buffer; + FAR void *act_buffer; + lv_area_t inv_areas[LV_INV_BUF_SIZE]; + uint16_t inv_areas_len; + lv_area_t final_area; + + int fd; + FAR void *fbmem; + uint32_t fbmem2_yoffset; + struct fb_videoinfo_s vinfo; + struct fb_planeinfo_s pinfo; + + bool double_buffer; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: buf_rotate_copy + ****************************************************************************/ + +#if defined(CONFIG_FB_UPDATE) +static void fbdev_update_area(FAR struct fbdev_obj_s *fbdev_obj, + FAR const lv_area_t *area_p) +{ + struct fb_area_s fb_area; + + fb_area.x = area_p->x1; + fb_area.y = area_p->y1; + fb_area.w = area_p->x2 - area_p->x1 + 1; + fb_area.h = area_p->y2 - area_p->y1 + 1; + + LV_LOG_TRACE("area: (%d, %d) %d x %d", + fb_area.x, fb_area.y, fb_area.w, fb_area.h); + + ioctl(fbdev_obj->fd, FBIO_UPDATE, + (unsigned long)((uintptr_t)&fb_area)); + + LV_LOG_TRACE("finished"); +} +#endif + +/**************************************************************************** + * Name: fbdev_copy_areas + ****************************************************************************/ + +static void fbdev_copy_areas(FAR lv_color_t *fb_dest, + FAR const lv_color_t *fb_src, + FAR const lv_area_t *areas, + uint16_t len, + int fb_width) +{ + int i; + LV_LOG_TRACE("%p -> %p, len = %d", fb_src, fb_dest, len); + + for (i = 0; i < len; i++) + { + int y; + FAR const lv_area_t *area = &(areas[i]); + int width = lv_area_get_width(area); + int height = lv_area_get_height(area); + FAR lv_color_t *dest_pos = + fb_dest + area->y1 * fb_width + area->x1; + FAR const lv_color_t *src_pos = + fb_src + area->y1 * fb_width + area->x1; + size_t hor_size = width * sizeof(lv_color_t); + + LV_LOG_TRACE("area[%d]: (%d, %d) %d x %d", + i, area->x1, area->y1, width, height); + + for (y = 0; y < height; y++) + { + lv_memcpy(dest_pos, src_pos, hor_size); + dest_pos += fb_width; + src_pos += fb_width; + } + } +} + +/**************************************************************************** + * Name: fbdev_switch_buffer + ****************************************************************************/ + +static void fbdev_switch_buffer(FAR struct fbdev_obj_s *fbdev_obj) +{ + FAR lv_disp_t *disp_refr = fbdev_obj->disp; + uint16_t inv_index; + + /* check inv_areas_len, it must == 0 */ + + if (fbdev_obj->inv_areas_len != 0) + { + LV_LOG_ERROR("Repeated flush action detected! " + "inv_areas_len(%d) != 0", + fbdev_obj->inv_areas_len); + fbdev_obj->inv_areas_len = 0; + } + + /* Save dirty area table for next synchronizationn */ + + for (inv_index = 0; inv_index < disp_refr->inv_p; inv_index++) + { + if (disp_refr->inv_area_joined[inv_index] == 0) + { + fbdev_obj->inv_areas[fbdev_obj->inv_areas_len] = + disp_refr->inv_areas[inv_index]; + fbdev_obj->inv_areas_len++; + } + } + + /* Save the buffer address for the next synchronization */ + + fbdev_obj->last_buffer = fbdev_obj->act_buffer; + + LV_LOG_TRACE("Commit buffer = %p, yoffset = %" PRIu32, + fbdev_obj->act_buffer, + fbdev_obj->pinfo.yoffset); + + if (fbdev_obj->act_buffer == fbdev_obj->fbmem) + { + fbdev_obj->pinfo.yoffset = 0; + fbdev_obj->act_buffer = fbdev_obj->fbmem + + fbdev_obj->fbmem2_yoffset * fbdev_obj->pinfo.stride; + } + else + { + fbdev_obj->pinfo.yoffset = fbdev_obj->fbmem2_yoffset; + fbdev_obj->act_buffer = fbdev_obj->fbmem; + } + + /* Commit buffer to fb driver */ + + ioctl(fbdev_obj->fd, FBIOPAN_DISPLAY, + (unsigned long)((uintptr_t)&(fbdev_obj->pinfo))); + + LV_LOG_TRACE("finished"); +} + +#if defined(CONFIG_FB_SYNC) + +/**************************************************************************** + * Name: fbdev_disp_vsync_refr + ****************************************************************************/ + +static void fbdev_disp_vsync_refr(FAR lv_timer_t *timer) +{ + int ret; + FAR struct fbdev_obj_s *fbdev_obj = timer->user_data; + + LV_LOG_TRACE("Check vsync..."); + + ret = ioctl(fbdev_obj->fd, FBIO_WAITFORVSYNC, NULL); + if (ret != OK) + { + LV_LOG_TRACE("No vsync signal detect"); + return; + } + + LV_LOG_TRACE("Refresh start"); + + _lv_disp_refr_timer(NULL); +} + +#endif /* CONFIG_FB_SYNC */ + +/**************************************************************************** + * Name: fbdev_render_start + ****************************************************************************/ + +static void fbdev_render_start(FAR lv_disp_drv_t *disp_drv) +{ + FAR struct fbdev_obj_s *fbdev_obj = disp_drv->user_data; + FAR lv_disp_t *disp_refr; + lv_coord_t hor_res; + lv_coord_t ver_res; + int i; + + /* No need sync buffer when inv_areas_len == 0 */ + + if (fbdev_obj->inv_areas_len == 0) + { + return; + } + + disp_refr = _lv_refr_get_disp_refreshing(); + hor_res = disp_drv->hor_res; + ver_res = disp_drv->ver_res; + + for (i = 0; i < disp_refr->inv_p; i++) + { + if (disp_refr->inv_area_joined[i] == 0) + { + FAR const lv_area_t *area_p = &disp_refr->inv_areas[i]; + + /* If a full screen redraw is detected, skip dirty areas sync */ + + if (lv_area_get_width(area_p) == hor_res + && lv_area_get_height(area_p) == ver_res) + { + LV_LOG_TRACE("Full screen redraw, skip dirty areas sync"); + fbdev_obj->inv_areas_len = 0; + return; + } + } + } + + /* Sync the dirty area of ​​the previous frame */ + + fbdev_copy_areas(fbdev_obj->act_buffer, fbdev_obj->last_buffer, + fbdev_obj->inv_areas, fbdev_obj->inv_areas_len, + fbdev_obj->vinfo.xres); + + fbdev_obj->inv_areas_len = 0; +} + +/**************************************************************************** + * Name: fbdev_flush_direct + ****************************************************************************/ + +static void fbdev_flush_direct(FAR lv_disp_drv_t *disp_drv, + FAR const lv_area_t *area_p, + FAR lv_color_t *color_p) +{ + FAR struct fbdev_obj_s *fbdev_obj = disp_drv->user_data; + + /* Commit the buffer after the last flush */ + + if (!lv_disp_flush_is_last(disp_drv)) + { + lv_disp_flush_ready(disp_drv); + return; + } + + fbdev_switch_buffer(fbdev_obj); + + FBDEV_UPDATE_AREA(fbdev_obj, area_p); + + /* Tell the flushing is ready */ + + lv_disp_flush_ready(disp_drv); +} + +/**************************************************************************** + * Name: fbdev_update_part + ****************************************************************************/ + +static void fbdev_update_part(FAR struct fbdev_obj_s *fbdev_obj, + FAR lv_disp_drv_t *disp_drv, + FAR const lv_area_t *area_p) +{ + FAR lv_area_t *final_area = &fbdev_obj->final_area; + + if (final_area->x1 < 0) + { + *final_area = *area_p; + } + else + { + _lv_area_join(final_area, final_area, area_p); + } + + if (!lv_disp_flush_is_last(disp_drv)) + { + lv_disp_flush_ready(disp_drv); + return; + } + + if (fbdev_obj->double_buffer) + { + fbdev_switch_buffer(fbdev_obj); + } + + FBDEV_UPDATE_AREA(fbdev_obj, final_area); + + /* Mark it is invalid */ + + final_area->x1 = -1; + + /* Tell the flushing is ready */ + + lv_disp_flush_ready(disp_drv); +} + +/**************************************************************************** + * Name: fbdev_flush_normal + ****************************************************************************/ + +static void fbdev_flush_normal(FAR lv_disp_drv_t *disp_drv, + FAR const lv_area_t *area_p, + FAR lv_color_t *color_p) +{ + FAR struct fbdev_obj_s *fbdev_obj = disp_drv->user_data; + + int x1 = area_p->x1; + int y1 = area_p->y1; + int y2 = area_p->y2; + int y; + int w = lv_area_get_width(area_p); + + FAR lv_color_t *fbp = fbdev_obj->act_buffer; + fb_coord_t fb_xres = fbdev_obj->vinfo.xres; + int hor_size = w * sizeof(lv_color_t); + FAR lv_color_t *cur_pos = fbp + y1 * fb_xres + x1; + + LV_LOG_TRACE("start copy"); + + for (y = y1; y <= y2; y++) + { + lv_memcpy(cur_pos, color_p, hor_size); + cur_pos += fb_xres; + color_p += w; + } + + LV_LOG_TRACE("end copy"); + + fbdev_update_part(fbdev_obj, disp_drv, area_p); +} + +/**************************************************************************** + * Name: fbdev_get_pinfo + ****************************************************************************/ + +static int fbdev_get_pinfo(int fd, FAR struct fb_planeinfo_s *pinfo) +{ + int ret = ioctl(fd, FBIOGET_PLANEINFO, + (unsigned long)((uintptr_t)pinfo)); + if (ret < 0) + { + LV_LOG_ERROR("ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d", errno); + return ret; + } + + LV_LOG_INFO("PlaneInfo (plane %d):", pinfo->display); + LV_LOG_INFO(" fbmem: %p", pinfo->fbmem); + LV_LOG_INFO(" fblen: %lu", (unsigned long)pinfo->fblen); + LV_LOG_INFO(" stride: %u", pinfo->stride); + LV_LOG_INFO(" display: %u", pinfo->display); + LV_LOG_INFO(" bpp: %u", pinfo->bpp); + + /* Only these pixel depths are supported. viinfo.fmt is ignored, only + * certain color formats are supported. + */ + + if (pinfo->bpp != 32 && pinfo->bpp != 16 && + pinfo->bpp != 8 && pinfo->bpp != 1) + { + LV_LOG_ERROR("bpp = %u not supported", pinfo->bpp); + return -1; + } + + return 0; +} + +/**************************************************************************** + * Name: fbdev_try_init_fbmem2 + ****************************************************************************/ + +static int fbdev_try_init_fbmem2(FAR struct fbdev_obj_s *state) +{ + uintptr_t buf_offset; + struct fb_planeinfo_s pinfo; + + memset(&pinfo, 0, sizeof(pinfo)); + + /* Get display[1] planeinfo */ + + pinfo.display = state->pinfo.display + 1; + + if (fbdev_get_pinfo(state->fd, &pinfo) < 0) + { + return -1; + } + + /* check display and match bpp */ + + if (!(pinfo.display != state->pinfo.display + && pinfo.bpp == state->pinfo.bpp)) + { + LV_LOG_INFO("fbmem2 is incorrect"); + return -1; + } + + /* Check the buffer address offset, + * It needs to be divisible by pinfo.stride + */ + + buf_offset = pinfo.fbmem - state->fbmem; + + if ((buf_offset % state->pinfo.stride) != 0) + { + LV_LOG_ERROR("The buf_offset(%" PRIuPTR ") is incorrect," + " it needs to be divisible" + " by pinfo.stride(%d)", + buf_offset, state->pinfo.stride); + return -1; + } + + /* Enable double buffer mode */ + + state->double_buffer = true; + state->fbmem2_yoffset = buf_offset / state->pinfo.stride; + + LV_LOG_INFO("Use non-consecutive fbmem2 = %p, yoffset = %" PRIu32, + pinfo.fbmem, state->fbmem2_yoffset); + + return 0; +} + +/**************************************************************************** + * Name: fbdev_init + ****************************************************************************/ + +static FAR lv_disp_t *fbdev_init(FAR struct fbdev_obj_s *state) +{ + FAR struct fbdev_obj_s *fbdev_obj = malloc(sizeof(struct fbdev_obj_s)); + FAR lv_disp_drv_t *disp_drv; + int fb_xres = state->vinfo.xres; + int fb_yres = state->vinfo.yres; + size_t fb_size = fb_xres * fb_yres; + FAR lv_color_t *buf1 = NULL; + FAR lv_color_t *buf2 = NULL; + + if (fbdev_obj == NULL) + { + LV_LOG_ERROR("fbdev_obj_s malloc failed"); + return NULL; + } + + *fbdev_obj = *state; + disp_drv = &(fbdev_obj->disp_drv); + + lv_disp_drv_init(disp_drv); + disp_drv->draw_buf = &(fbdev_obj->disp_draw_buf); + disp_drv->screen_transp = false; + disp_drv->user_data = fbdev_obj; + disp_drv->hor_res = fb_xres; + disp_drv->ver_res = fb_yres; + + if (fbdev_obj->double_buffer) + { + LV_LOG_INFO("Double buffer mode"); + + buf1 = fbdev_obj->fbmem; + buf2 = fbdev_obj->fbmem + + fbdev_obj->fbmem2_yoffset * fbdev_obj->pinfo.stride; + + disp_drv->direct_mode = true; + disp_drv->flush_cb = fbdev_flush_direct; + disp_drv->render_start_cb = fbdev_render_start; + } + else + { + LV_LOG_INFO("Single buffer mode"); + + buf1 = malloc(fb_size * sizeof(lv_color_t)); + LV_ASSERT_MALLOC(buf1); + + if (!buf1) + { + LV_LOG_ERROR("failed to malloc draw buffer"); + goto failed; + } + + disp_drv->flush_cb = fbdev_flush_normal; + } + + lv_disp_draw_buf_init(&(fbdev_obj->disp_draw_buf), buf1, buf2, fb_size); + fbdev_obj->act_buffer = fbdev_obj->fbmem; + fbdev_obj->disp = lv_disp_drv_register(&(fbdev_obj->disp_drv)); + +#if defined(CONFIG_FB_SYNC) + /* If double buffer and vsync is supported, use active refresh method */ + + if (fbdev_obj->disp_drv.direct_mode) + { + FAR lv_timer_t *refr_timer = _lv_disp_get_refr_timer(fbdev_obj->disp); + lv_timer_del(refr_timer); + fbdev_obj->disp->refr_timer = NULL; + lv_timer_create(fbdev_disp_vsync_refr, 1, fbdev_obj); + } +#endif + + return fbdev_obj->disp; + +failed: + free(fbdev_obj); + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_fbdev_init + * + * Description: + * Framebuffer device interface initialization. + * + * Input Parameters: + * dev_path - Framebuffer device path, set to NULL to use the default path. + * + * Returned Value: + * lv_disp object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_disp_t *lv_port_fbdev_init(FAR const char *dev_path) +{ + FAR const char *device_path = dev_path; + struct fbdev_obj_s state; + int ret; + FAR lv_disp_t *disp; + + memset(&state, 0, sizeof(state)); + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_FBDEV_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("fbdev %s opening", device_path); + + state.fd = open(device_path, O_RDWR); + if (state.fd < 0) + { + LV_LOG_ERROR("fbdev %s open failed: %d", device_path, errno); + return NULL; + } + + /* Get the characteristics of the framebuffer */ + + ret = ioctl(state.fd, FBIOGET_VIDEOINFO, + (unsigned long)((uintptr_t)&state.vinfo)); + if (ret < 0) + { + LV_LOG_ERROR("ioctl(FBIOGET_VIDEOINFO) failed: %d", errno); + close(state.fd); + return NULL; + } + + LV_LOG_INFO("VideoInfo:"); + LV_LOG_INFO(" fmt: %u", state.vinfo.fmt); + LV_LOG_INFO(" xres: %u", state.vinfo.xres); + LV_LOG_INFO(" yres: %u", state.vinfo.yres); + LV_LOG_INFO(" nplanes: %u", state.vinfo.nplanes); + + ret = fbdev_get_pinfo(state.fd, &state.pinfo); + + if (ret < 0) + { + close(state.fd); + return NULL; + } + + /* Check color depth */ + + if (!(state.pinfo.bpp == LV_COLOR_DEPTH || + (state.pinfo.bpp == 24 && LV_COLOR_DEPTH == 32))) + { + LV_LOG_ERROR("fbdev bpp = %d, LV_COLOR_DEPTH = %d, " + "color depth does not match.", + state.pinfo.bpp, LV_COLOR_DEPTH); + close(state.fd); + return NULL; + } + + state.double_buffer = (state.pinfo.yres_virtual == (state.vinfo.yres * 2)); + + /* mmap() the framebuffer. + * + * NOTE: In the FLAT build the frame buffer address returned by the + * FBIOGET_PLANEINFO IOCTL command will be the same as the framebuffer + * address. mmap(), however, is the preferred way to get the framebuffer + * address because in the KERNEL build, it will perform the necessary + * address mapping to make the memory accessible to the application. + */ + + state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FILE, state.fd, 0); + if (state.fbmem == MAP_FAILED) + { + LV_LOG_ERROR("ioctl(FBIOGET_PLANEINFO) failed: %d", errno); + close(state.fd); + return NULL; + } + + LV_LOG_INFO("Mapped FB: %p", state.fbmem); + + if (state.double_buffer) + { + state.fbmem2_yoffset = state.vinfo.yres; + } + else + { + fbdev_try_init_fbmem2(&state); + } + + disp = fbdev_init(&state); + + if (!disp) + { + munmap(state.fbmem, state.pinfo.fblen); + close(state.fd); + return NULL; + } + + return disp; +} diff --git a/graphics/lvgl/port/lv_port_fbdev.h b/graphics/lvgl/port/lv_port_fbdev.h new file mode 100644 index 000000000..8bb47c353 --- /dev/null +++ b/graphics/lvgl/port/lv_port_fbdev.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_fbdev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_FBDEV_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_FBDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_FBDEV) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_fbdev_init + * + * Description: + * Framebuffer device interface initialization. + * + * Input Parameters: + * dev_path - Framebuffer device path, set to NULL to use the default path. + * + * Returned Value: + * lv_disp object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_disp_t *lv_port_fbdev_init(FAR const char *dev_path); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_FBDEV */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_FBDEV_H */ diff --git a/graphics/lvgl/port/lv_port_keypad.c b/graphics/lvgl/port/lv_port_keypad.c new file mode 100644 index 000000000..f45099ca5 --- /dev/null +++ b/graphics/lvgl/port/lv_port_keypad.c @@ -0,0 +1,251 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_keypad.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_keypad.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LV_KEY_UP_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_UP_MAP_BIT +#define LV_KEY_DOWN_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_DOWN_MAP_BIT +#define LV_KEY_RIGHT_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_RIGHT_MAP_BIT +#define LV_KEY_LEFT_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_LEFT_MAP_BIT + +#define LV_KEY_ESC_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_ESC_MAP_BIT +#define LV_KEY_DEL_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_DEL_MAP_BIT +#define LV_KEY_BACKSPACE_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_BACKSPACE_MAP_BIT +#define LV_KEY_ENTER_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_ENTER_MAP_BIT + +#define LV_KEY_NEXT_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_NEXT_MAP_BIT +#define LV_KEY_PREV_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_PREV_MAP_BIT +#define LV_KEY_HOME_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_HOME_MAP_BIT +#define LV_KEY_END_MAP_BIT CONFIG_LV_PORT_KEYPAD_KEY_END_MAP_BIT + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct keypad_map_s +{ + const lv_key_t key; + int bit; +}; + +struct keypad_obj_s +{ + int fd; + uint32_t last_key; + lv_indev_drv_t indev_drv; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct keypad_map_s g_keypad_map[] = +{ + {LV_KEY_UP, LV_KEY_UP_MAP_BIT}, + {LV_KEY_DOWN, LV_KEY_DOWN_MAP_BIT}, + {LV_KEY_RIGHT, LV_KEY_RIGHT_MAP_BIT}, + {LV_KEY_LEFT, LV_KEY_LEFT_MAP_BIT}, + {LV_KEY_ESC, LV_KEY_ESC_MAP_BIT}, + {LV_KEY_DEL, LV_KEY_DEL_MAP_BIT}, + {LV_KEY_BACKSPACE, LV_KEY_BACKSPACE_MAP_BIT}, + {LV_KEY_ENTER, LV_KEY_ENTER_MAP_BIT}, + {LV_KEY_NEXT, LV_KEY_NEXT_MAP_BIT}, + {LV_KEY_PREV, LV_KEY_PREV_MAP_BIT}, + {LV_KEY_HOME, LV_KEY_HOME_MAP_BIT}, + {LV_KEY_END, LV_KEY_END_MAP_BIT} +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: keypad_get_key + ****************************************************************************/ + +static uint32_t keypad_get_key(int fd) +{ + uint32_t act_key = 0; + btn_buttonset_t buttonset; + const int buttonset_bits = sizeof(btn_buttonset_t) * 8; + int i; + + int ret = read(fd, &buttonset, sizeof(btn_buttonset_t)); + if (ret < 0) + { + return 0; + } + + for (i = 0; i < sizeof(g_keypad_map) / sizeof(struct keypad_map_s); i++) + { + int bit = g_keypad_map[i].bit; + + if (bit >= 0 && bit < buttonset_bits) + { + btn_buttonset_t mask = (btn_buttonset_t)(1 << bit); + if ((buttonset & mask) != 0) + { + act_key = g_keypad_map[i].key; + break; + } + } + } + + return act_key; +} + +/**************************************************************************** + * Name: keypad_read + ****************************************************************************/ + +static void keypad_read(FAR lv_indev_drv_t *drv, FAR lv_indev_data_t *data) +{ + FAR struct keypad_obj_s *keypad_obj = drv->user_data; + + /* Get whether the a key is pressed and save the pressed key */ + + uint32_t act_key = keypad_get_key(keypad_obj->fd); + + if (act_key != 0) + { + data->state = LV_INDEV_STATE_PR; + keypad_obj->last_key = act_key; + } + else + { + data->state = LV_INDEV_STATE_REL; + } + + data->key = keypad_obj->last_key; +} + +/**************************************************************************** + * Name: keypad_init + ****************************************************************************/ + +static FAR lv_indev_t *keypad_init(int fd) +{ + FAR struct keypad_obj_s *keypad_obj; + keypad_obj = malloc(sizeof(struct keypad_obj_s)); + + if (keypad_obj == NULL) + { + LV_LOG_ERROR("keypad_obj_s malloc failed"); + return NULL; + } + + keypad_obj->fd = fd; + keypad_obj->last_key = 0; + + /* Register a keypad input device */ + + lv_indev_drv_init(&(keypad_obj->indev_drv)); + keypad_obj->indev_drv.type = LV_INDEV_TYPE_KEYPAD; + keypad_obj->indev_drv.read_cb = keypad_read; +#if ( LV_USE_USER_DATA != 0 ) + keypad_obj->indev_drv.user_data = keypad_obj; +#else +#error LV_USE_USER_DATA must be enabled +#endif + return lv_indev_drv_register(&(keypad_obj->indev_drv)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_keypad_init + * + * Description: + * Keypad interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_keypad_init(FAR const char *dev_path) +{ + FAR const char *device_path = dev_path; + FAR lv_indev_t *indev; + int fd; + int ret; + btn_buttonset_t supported; + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_KEYPAD_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("keypad %s opening", device_path); + fd = open(device_path, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + LV_LOG_ERROR("keypad %s open failed: %d", device_path, errno); + return NULL; + } + + /* Get the set of BUTTONs supported */ + + ret = ioctl(fd, BTNIOC_SUPPORTED, + (unsigned long)((uintptr_t)&supported)); + if (ret < 0) + { + LV_LOG_ERROR("button ioctl(BTNIOC_SUPPORTED) failed: %d", + errno); + return NULL; + } + + LV_LOG_INFO("button supported BUTTONs 0x%08x", (unsigned int)supported); + + indev = keypad_init(fd); + + if (indev == NULL) + { + close(fd); + } + + return indev; +} diff --git a/graphics/lvgl/port/lv_port_keypad.h b/graphics/lvgl/port/lv_port_keypad.h new file mode 100644 index 000000000..d7be5158a --- /dev/null +++ b/graphics/lvgl/port/lv_port_keypad.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_keypad.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_KEYPAD_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_KEYPAD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_KEYPAD) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: lv_port_keypad_init + * + * Description: + * Keypad interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_keypad_init(FAR const char *dev_path); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_KEYPAD */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_KEYPAD_H */ diff --git a/graphics/lvgl/port/lv_port_lcddev.c b/graphics/lvgl/port/lv_port_lcddev.c new file mode 100644 index 000000000..689a5d200 --- /dev/null +++ b/graphics/lvgl/port/lv_port_lcddev.c @@ -0,0 +1,302 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_lcddev.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_lcddev.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct lcddev_obj_s +{ + int fd; + lv_disp_draw_buf_t disp_draw_buf; + lv_disp_drv_t disp_drv; + struct lcddev_area_s area; + + pthread_t write_thread; + sem_t flush_sem; + sem_t wait_sem; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lcddev_wait + ****************************************************************************/ + +static void lcddev_wait(FAR lv_disp_drv_t *disp_drv) +{ + FAR struct lcddev_obj_s *lcddev_obj = disp_drv->user_data; + + sem_wait(&(lcddev_obj->wait_sem)); + + /* Tell the flushing is ready */ + + lv_disp_flush_ready(disp_drv); +} + +/**************************************************************************** + * Name: lcddev_update_thread + ****************************************************************************/ + +static FAR void *lcddev_update_thread(FAR void *arg) +{ + int ret = OK; + int errcode = 0; + FAR struct lcddev_obj_s *lcddev_obj = arg; + + while (ret == OK) + { + sem_wait(&lcddev_obj->flush_sem); + + ret = ioctl(lcddev_obj->fd, LCDDEVIO_PUTAREA, + (unsigned long)&(lcddev_obj->area)); + if (ret < 0) + { + errcode = errno; + } + + sem_post(&lcddev_obj->wait_sem); + } + + LV_LOG_ERROR("ioctl(LCDDEVIO_PUTAREA) failed: %d", errcode); + close(lcddev_obj->fd); + lcddev_obj->fd = -1; + + return NULL; +} + +/**************************************************************************** + * Name: lcddev_flush + ****************************************************************************/ + +static void lcddev_flush(FAR lv_disp_drv_t *disp_drv, + FAR const lv_area_t *area_p, + FAR lv_color_t *color_p) +{ + FAR struct lcddev_obj_s *lcddev_obj = disp_drv->user_data; + + lcddev_obj->area.row_start = area_p->y1; + lcddev_obj->area.row_end = area_p->y2; + lcddev_obj->area.col_start = area_p->x1; + lcddev_obj->area.col_end = area_p->x2; + lcddev_obj->area.data = (FAR uint8_t *)color_p; + + sem_post(&lcddev_obj->flush_sem); +} + +/**************************************************************************** + * Name: lcddev_init + ****************************************************************************/ + +static FAR lv_disp_t *lcddev_init(int fd, + int hor_res, + int ver_res, + int line_buf) +{ + FAR lv_color_t *buf1 = NULL; + FAR lv_color_t *buf2 = NULL; + FAR struct lcddev_obj_s *lcddev_obj; + const size_t buf_size = hor_res * line_buf * sizeof(lv_color_t); + lcddev_obj = malloc(sizeof(struct lcddev_obj_s)); + + if (lcddev_obj == NULL) + { + LV_LOG_ERROR("lcddev_obj_s malloc failed"); + return NULL; + } + + buf1 = malloc(buf_size); + if (buf1 == NULL) + { + LV_LOG_ERROR("display buf1 malloc failed"); + free(lcddev_obj); + return NULL; + } + +#ifdef CONFIG_LV_PORT_LCDDEV_DOUBLE_BUFFER + buf2 = malloc(buf_size); + if (buf2 == NULL) + { + LV_LOG_ERROR("display buf2 malloc failed"); + free(lcddev_obj); + free(buf1); + return NULL; + } +#endif + + LV_LOG_INFO("display buffer malloc success, buf size = %lu", buf_size); + + lcddev_obj->fd = fd; + + lv_disp_draw_buf_init(&(lcddev_obj->disp_draw_buf), buf1, buf2, + hor_res * line_buf); + + lv_disp_drv_init(&(lcddev_obj->disp_drv)); + lcddev_obj->disp_drv.flush_cb = lcddev_flush; + lcddev_obj->disp_drv.draw_buf = &(lcddev_obj->disp_draw_buf); + lcddev_obj->disp_drv.hor_res = hor_res; + lcddev_obj->disp_drv.ver_res = ver_res; + lcddev_obj->disp_drv.screen_transp = false; +#if ( LV_USE_USER_DATA != 0 ) + lcddev_obj->disp_drv.user_data = lcddev_obj; +#else +#error LV_USE_USER_DATA must be enabled +#endif + lcddev_obj->disp_drv.wait_cb = lcddev_wait; + + /* Initialize the mutexes for buffer flushing synchronization */ + + sem_init(&lcddev_obj->flush_sem, 0, 0); + sem_init(&lcddev_obj->wait_sem, 0, 0); + + /* Initialize the buffer flushing thread */ + + pthread_create(&(lcddev_obj->write_thread), NULL, + lcddev_update_thread, lcddev_obj); + + return lv_disp_drv_register(&(lcddev_obj->disp_drv)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_lcddev_init + * + * Description: + * Lcd interface initialization. + * + * Input Parameters: + * dev_path - lcd device path, set to NULL to use the default path + * line_buf - Number of line buffers, + * set to 0 to use the default line buffer + * + * Returned Value: + * lv_disp object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_disp_t *lv_port_lcddev_init(FAR const char *dev_path, int line_buf) +{ + FAR const char *device_path = dev_path; + int line_buffer = line_buf; + int fd; + int ret; + FAR lv_disp_t *disp; + + struct fb_videoinfo_s vinfo; + struct lcd_planeinfo_s pinfo; + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_LCDDEV_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("lcddev %s opening", device_path); + fd = open(device_path, 0); + if (fd < 0) + { + LV_LOG_ERROR("lcddev open failed: %d", errno); + return NULL; + } + + LV_LOG_INFO("lcddev %s open success", device_path); + + ret = ioctl(fd, LCDDEVIO_GETVIDEOINFO, + (unsigned long)((uintptr_t)&vinfo)); + if (ret < 0) + { + LV_LOG_ERROR("ioctl(LCDDEVIO_GETVIDEOINFO) failed: %d", errno); + close(fd); + return NULL; + } + + LV_LOG_INFO("VideoInfo:"); + LV_LOG_INFO(" fmt: %u", vinfo.fmt); + LV_LOG_INFO(" xres: %u", vinfo.xres); + LV_LOG_INFO(" yres: %u", vinfo.yres); + LV_LOG_INFO(" nplanes: %u", vinfo.nplanes); + + ret = ioctl(fd, LCDDEVIO_GETPLANEINFO, + (unsigned long)((uintptr_t)&pinfo)); + if (ret < 0) + { + LV_LOG_ERROR("ERROR: ioctl(LCDDEVIO_GETPLANEINFO) failed: %d", + errno); + close(fd); + return NULL; + } + + LV_LOG_INFO("PlaneInfo:"); + LV_LOG_INFO(" bpp: %u", pinfo.bpp); + + if (pinfo.bpp != LV_COLOR_DEPTH) + { + LV_LOG_ERROR("lcddev bpp = %d, LV_COLOR_DEPTH = %d," + " color depth does not match", pinfo.bpp, LV_COLOR_DEPTH); + close(fd); + return NULL; + } + +#ifdef CONFIG_LV_PORT_LCDDEV_FULL_SCREEN_BUFFER + line_buffer = vinfo.yres; +#else + if (line_buffer <= 0) + { + line_buffer = CONFIG_LV_PORT_LCDDEV_LINE_BUFFER_DEFAULT; + } +#endif + + disp = lcddev_init(fd, vinfo.xres, vinfo.yres, + line_buffer); + if (disp == NULL) + { + close(fd); + } + + return disp; +} diff --git a/graphics/lvgl/port/lv_port_lcddev.h b/graphics/lvgl/port/lv_port_lcddev.h new file mode 100644 index 000000000..82efa6c65 --- /dev/null +++ b/graphics/lvgl/port/lv_port_lcddev.h @@ -0,0 +1,82 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_lcddev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_LCDDEV_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_LCDDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_LCDDEV) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_lcddev_init + * + * Description: + * lcddev interface initialization. + * + * Input Parameters: + * dev_path - lcd device path, set to NULL to use the default path + * line_buf - Number of line buffers, + * set to 0 to use the default line buffer + * + * Returned Value: + * lv_disp object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_disp_t *lv_port_lcddev_init(FAR const char *dev_path, int line_buf); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_LCDDEV */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_LCDDEV_H */ diff --git a/graphics/lvgl/port/lv_port_mem.c b/graphics/lvgl/port/lv_port_mem.c new file mode 100644 index 000000000..73308a1fb --- /dev/null +++ b/graphics/lvgl/port/lv_port_mem.c @@ -0,0 +1,173 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_mem.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include "lv_port_mem.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +typedef CODE void *(*malloc_func_t)(FAR struct mm_heap_s *heap, size_t size); +typedef CODE void *(*realloc_func_t)(FAR struct mm_heap_s *heap, + FAR void *oldmem, size_t size); +typedef CODE void *(*memalign_func_t)(FAR struct mm_heap_s *heap, + size_t alignment, size_t size); + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static FAR void *malloc_first(FAR struct mm_heap_s *heap, size_t size); +static FAR void *realloc_first(FAR struct mm_heap_s *heap, + FAR void *oldmem, size_t size); +static FAR void *memalign_first(FAR struct mm_heap_s *heap, + size_t alignment, size_t size); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static FAR struct mm_heap_s *g_lv_heap = NULL; +static malloc_func_t g_malloc_func = malloc_first; +static realloc_func_t g_realloc_func = realloc_first; +static memalign_func_t g_memalign_func = memalign_first; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_mem_init + * + * Description: + * Memory interface initialization. + * + ****************************************************************************/ + +static void lv_port_mem_init(void) +{ + static uint32_t heap_buf[CONFIG_LV_PORT_MEM_CUSTOM_SIZE + * 1024 / sizeof(uint32_t)]; + g_lv_heap = mm_initialize(CONFIG_LV_PORT_MEM_CUSTOM_NAME, + heap_buf, sizeof(heap_buf)); + LV_ASSERT_NULL(g_lv_heap); + if (g_lv_heap == NULL) + { + LV_LOG_ERROR("NO memory for " + CONFIG_LV_PORT_MEM_CUSTOM_NAME + " heap"); + } +} + +/**************************************************************************** + * Name: malloc_first + ****************************************************************************/ + +static FAR void *malloc_first(FAR struct mm_heap_s *heap, size_t size) +{ + if (g_lv_heap == NULL) + { + lv_port_mem_init(); + } + + g_malloc_func = mm_malloc; + return g_malloc_func(g_lv_heap, size); +} + +/**************************************************************************** + * Name: realloc_first + ****************************************************************************/ + +static FAR void *realloc_first(FAR struct mm_heap_s *heap, + FAR void *oldmem, size_t size) +{ + if (g_lv_heap == NULL) + { + lv_port_mem_init(); + } + + g_realloc_func = mm_realloc; + return g_realloc_func(g_lv_heap, oldmem, size); +} + +/**************************************************************************** + * Name: memalign_first + ****************************************************************************/ + +static FAR void *memalign_first(FAR struct mm_heap_s *heap, + size_t alignment, size_t size) +{ + if (g_lv_heap == NULL) + { + lv_port_mem_init(); + } + + g_memalign_func = mm_memalign; + return g_memalign_func(g_lv_heap, alignment, size); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_mem_alloc + ****************************************************************************/ + +FAR void *lv_port_mem_alloc(size_t size) +{ + return g_malloc_func(g_lv_heap, size); +} + +/**************************************************************************** + * Name: lv_port_mem_free + ****************************************************************************/ + +void lv_port_mem_free(FAR void *mem) +{ + mm_free(g_lv_heap, mem); +} + +/**************************************************************************** + * Name: lv_port_mem_realloc + ****************************************************************************/ + +FAR void *lv_port_mem_realloc(FAR void *oldmem, size_t size) +{ + return g_realloc_func(g_lv_heap, oldmem, size); +} + +/**************************************************************************** + * Name: lv_mem_custom_memalign + ****************************************************************************/ + +FAR void *lv_mem_custom_memalign(size_t alignment, size_t size) +{ + return g_memalign_func(g_lv_heap, alignment, size); +} diff --git a/graphics/lvgl/port/lv_port_mem.h b/graphics/lvgl/port/lv_port_mem.h new file mode 100644 index 000000000..d6f25fbbd --- /dev/null +++ b/graphics/lvgl/port/lv_port_mem.h @@ -0,0 +1,92 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_mem.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_MEM_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_MEM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_LV_PORT_MEM_CUSTOM_SIZE +# define CONFIG_LV_PORT_MEM_CUSTOM_SIZE 0 +#endif + +#if CONFIG_LV_PORT_MEM_CUSTOM_SIZE + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_mem_alloc + ****************************************************************************/ + +FAR void *lv_port_mem_alloc(size_t size); + +/**************************************************************************** + * Name: lv_port_mem_free + ****************************************************************************/ + +void lv_port_mem_free(FAR void *mem); + +/**************************************************************************** + * Name: lv_port_mem_realloc + ****************************************************************************/ + +FAR void *lv_port_mem_realloc(FAR void *oldmem, size_t size); + +/**************************************************************************** + * Name: lv_port_mem_memalign + ****************************************************************************/ + +FAR void *lv_port_mem_memalign(size_t alignment, size_t size); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_MEM_CUSTOM_SIZE */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_MEM_H */ diff --git a/examples/lvgldemo/lcddev.h b/graphics/lvgl/port/lv_port_syslog.c similarity index 59% rename from examples/lvgldemo/lcddev.h rename to graphics/lvgl/port/lv_port_syslog.c index 18d5b786e..c7a1ca999 100644 --- a/examples/lvgldemo/lcddev.h +++ b/graphics/lvgl/port/lv_port_syslog.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/lvgldemo/lcddev.h + * apps/graphics/lvgl/port/lv_port_syslog.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,29 +18,40 @@ * ****************************************************************************/ -#ifndef __APPS_EXAMPLES_LVGLDEMO_LCDDEV_H -#define __APPS_EXAMPLES_LVGLDEMO_LCDDEV_H - /**************************************************************************** * Included Files ****************************************************************************/ -#include #include - -#ifdef __cplusplus -extern "C" -{ -#endif +#include +#include "lv_port_syslog.h" /**************************************************************************** - * Public Function Prototypes + * Private Functions ****************************************************************************/ -int lcddev_init(lv_disp_drv_t *lv_drvr); +/**************************************************************************** + * Name: syslog_print_cb + ****************************************************************************/ -#ifdef __cplusplus +static void syslog_print_cb(FAR const char *buf) +{ + syslog(LOG_INFO, "[LVGL] %s", buf); } -#endif -#endif /* __APPS_EXAMPLES_LVGLDEMO_LCDDEV_H */ +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_syslog_init + * + * Description: + * Syslog interface initialization. + * + ****************************************************************************/ + +void lv_port_syslog_init(void) +{ + lv_log_register_print_cb(syslog_print_cb); +} diff --git a/examples/lvgldemo/tp_cal.h b/graphics/lvgl/port/lv_port_syslog.h similarity index 54% rename from examples/lvgldemo/tp_cal.h rename to graphics/lvgl/port/lv_port_syslog.h index 409f63223..c4f21a222 100644 --- a/examples/lvgldemo/tp_cal.h +++ b/graphics/lvgl/port/lv_port_syslog.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/lvgldemo/tp_cal.h + * apps/graphics/lvgl/port/lv_port_syslog.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,36 +18,56 @@ * ****************************************************************************/ -#ifndef __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H -#define __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_SYSLOG_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_SYSLOG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_USE_LOG) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif /**************************************************************************** * Public Function Prototypes ****************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - /**************************************************************************** - * Name: tp_cal_create + * Name: lv_port_syslog_init * * Description: - * Create a touchpad calibration screen - * - * Input Parameters: - * None - * - * Returned Value: - * None + * Syslog interface initialization. * ****************************************************************************/ -void tp_cal_create(void); +void lv_port_syslog_init(void); +#undef EXTERN #ifdef __cplusplus } #endif -#endif /* __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H */ +#endif /* CONFIG_LV_USE_LOG */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_SYSLOG_H */ diff --git a/graphics/lvgl/lv_tick_interface.c b/graphics/lvgl/port/lv_port_tick.c similarity index 82% rename from graphics/lvgl/lv_tick_interface.c rename to graphics/lvgl/port/lv_port_tick.c index d0757d4db..659e7c74f 100644 --- a/graphics/lvgl/lv_tick_interface.c +++ b/graphics/lvgl/port/lv_port_tick.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/graphics/lvgl/lv_tick_interface.c + * apps/graphics/lvgl/port/lv_port_tick.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,8 +23,8 @@ ****************************************************************************/ #include -#include -#include "lv_tick_interface.h" +#include +#include "lv_port_tick.h" /**************************************************************************** * Pre-processor Definitions @@ -50,24 +50,12 @@ * Public Functions ****************************************************************************/ -uint32_t lv_tick_interface(void) +uint32_t millis(void) { - static bool first_time = true; - static struct timeval t0; + struct timespec ts; - if (first_time) - { - gettimeofday(&t0, NULL); - first_time = false; - return 0; - } - else - { - struct timeval t; - struct timeval delta; + clock_gettime(CLOCK_MONOTONIC, &ts); + uint32_t tick = ts.tv_sec * 1000 + ts.tv_nsec / 1000000; - gettimeofday(&t, NULL); - timersub(&t, &t0, &delta); - return delta.tv_sec * 1000 + delta.tv_usec / 1000; - } + return tick; } diff --git a/graphics/lvgl/lv_tick_interface.h b/graphics/lvgl/port/lv_port_tick.h similarity index 89% rename from graphics/lvgl/lv_tick_interface.h rename to graphics/lvgl/port/lv_port_tick.h index 2a9546553..d662481f7 100644 --- a/graphics/lvgl/lv_tick_interface.h +++ b/graphics/lvgl/port/lv_port_tick.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/graphics/lvgl/lv_tick_interface.h + * apps/graphics/lvgl/port/lv_port_tick.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,15 +18,14 @@ * ****************************************************************************/ -#ifndef __APPS_GRAPHICS_LV_TICK_INTERFACE_H -#define __APPS_GRAPHICS_LV_TICK_INTERFACE_H +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TICK_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TICK_H /**************************************************************************** * Included Files ****************************************************************************/ #include -#include /**************************************************************************** * Pre-processor Definitions @@ -52,11 +51,11 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -uint32_t lv_tick_interface(void); +uint32_t millis(void); #undef EXTERN #ifdef __cplusplus } #endif -#endif // __APPS_GRAPHICS_LV_TICK_INTERFACE_H +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TICK_H */ diff --git a/graphics/lvgl/port/lv_port_touchpad.c b/graphics/lvgl/port/lv_port_touchpad.c new file mode 100644 index 000000000..c54763f9f --- /dev/null +++ b/graphics/lvgl/port/lv_port_touchpad.c @@ -0,0 +1,178 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_touchpad.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lv_port_touchpad.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Type Declarations + ****************************************************************************/ + +struct touchpad_obj_s +{ + int fd; + lv_coord_t last_x; + lv_coord_t last_y; + lv_indev_state_t last_state; + lv_indev_drv_t indev_drv; +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: touchpad_read + ****************************************************************************/ + +static void touchpad_read(FAR lv_indev_drv_t *drv, FAR lv_indev_data_t *data) +{ + FAR struct touchpad_obj_s *touchpad_obj = drv->user_data; + struct touch_sample_s sample; + + /* Read one sample */ + + int nbytes = read(touchpad_obj->fd, &sample, + sizeof(struct touch_sample_s)); + + /* Handle unexpected return values */ + + if (nbytes == sizeof(struct touch_sample_s)) + { + uint8_t touch_flags = sample.point[0].flags; + + if (touch_flags & TOUCH_DOWN || touch_flags & TOUCH_MOVE) + { + const FAR lv_disp_drv_t *disp_drv = drv->disp->driver; + lv_coord_t ver_max = disp_drv->ver_res - 1; + lv_coord_t hor_max = disp_drv->hor_res - 1; + + touchpad_obj->last_x = LV_CLAMP(0, sample.point[0].x, hor_max); + touchpad_obj->last_y = LV_CLAMP(0, sample.point[0].y, ver_max); + touchpad_obj->last_state = LV_INDEV_STATE_PR; + } + else if (touch_flags & TOUCH_UP) + { + touchpad_obj->last_state = LV_INDEV_STATE_REL; + } + } + + /* Update touchpad data */ + + data->point.x = touchpad_obj->last_x; + data->point.y = touchpad_obj->last_y; + data->state = touchpad_obj->last_state; +} + +/**************************************************************************** + * Name: touchpad_init + ****************************************************************************/ + +static FAR lv_indev_t *touchpad_init(int fd) +{ + FAR struct touchpad_obj_s *touchpad_obj; + touchpad_obj = malloc(sizeof(struct touchpad_obj_s)); + + if (touchpad_obj == NULL) + { + LV_LOG_ERROR("touchpad_obj_s malloc failed"); + return NULL; + } + + touchpad_obj->fd = fd; + touchpad_obj->last_x = 0; + touchpad_obj->last_y = 0; + touchpad_obj->last_state = LV_INDEV_STATE_REL; + + lv_indev_drv_init(&(touchpad_obj->indev_drv)); + touchpad_obj->indev_drv.type = LV_INDEV_TYPE_POINTER; + touchpad_obj->indev_drv.read_cb = touchpad_read; +#if ( LV_USE_USER_DATA != 0 ) + touchpad_obj->indev_drv.user_data = touchpad_obj; +#else +#error LV_USE_USER_DATA must be enabled +#endif + return lv_indev_drv_register(&(touchpad_obj->indev_drv)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_touchpad_init + * + * Description: + * Touchpad interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_touchpad_init(FAR const char *dev_path) +{ + FAR const char *device_path = dev_path; + FAR lv_indev_t *indev; + int fd; + + if (device_path == NULL) + { + device_path = CONFIG_LV_PORT_TOUCHPAD_DEFAULT_DEVICEPATH; + } + + LV_LOG_INFO("touchpad %s opening", device_path); + fd = open(device_path, O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + LV_LOG_ERROR("touchpad %s open failed: %d", device_path, errno); + return NULL; + } + + LV_LOG_INFO("touchpad %s open success", device_path); + + indev = touchpad_init(fd); + + if (indev == NULL) + { + close(fd); + } + + return indev; +} diff --git a/graphics/lvgl/port/lv_port_touchpad.h b/graphics/lvgl/port/lv_port_touchpad.h new file mode 100644 index 000000000..cbcce2ea8 --- /dev/null +++ b/graphics/lvgl/port/lv_port_touchpad.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * apps/graphics/lvgl/port/lv_port_touchpad.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TOUCHPAD_H +#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TOUCHPAD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if defined(CONFIG_LV_PORT_USE_TOUCHPAD) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: lv_port_touchpad_init + * + * Description: + * Touchpad interface initialization. + * + * Input Parameters: + * dev_path - input device path, set to NULL to use the default path + * + * Returned Value: + * lv_indev object address on success; NULL on failure. + * + ****************************************************************************/ + +FAR lv_indev_t *lv_port_touchpad_init(FAR const char *dev_path); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_LV_PORT_USE_TOUCHPAD */ + +#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TOUCHPAD_H */