apps/lvgl: upgrade to lvgl version v9
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
parent
29028d480b
commit
c53abc5fdb
@ -29,7 +29,7 @@ if(CONFIG_EXAMPLES_LVGLDEMO)
|
||||
MODULE
|
||||
${CONFIG_EXAMPLES_LVGLDEMO}
|
||||
DEPENDS
|
||||
lvgl_nuttx
|
||||
lvgl
|
||||
SRCS
|
||||
lvgldemo.c)
|
||||
endif()
|
||||
|
@ -23,30 +23,20 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <debug.h>
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <port/lv_port.h>
|
||||
#include <lvgl/demos/lv_demos.h>
|
||||
|
||||
#ifdef CONFIG_LIBUV
|
||||
# include <uv.h>
|
||||
# include <port/lv_port_libuv.h>
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
#include <uv.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Should we perform board-specific driver initialization? There are two
|
||||
/* Should we perform board-specific driver initialization? There are two
|
||||
* ways that board initialization can occur: 1) automatically via
|
||||
* board_late_initialize() during bootupif CONFIG_BOARD_LATE_INITIALIZE
|
||||
* or 2).
|
||||
@ -67,100 +57,42 @@
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
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: show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void show_usage(void)
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
static void lv_nuttx_uv_loop(uv_loop_t *loop, lv_nuttx_result_t *result)
|
||||
{
|
||||
int i;
|
||||
const int len = nitems(func_key_pair) - 1;
|
||||
lv_nuttx_uv_t uv_info;
|
||||
void *data;
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
printf("lvgldemo: no demo available!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return;
|
||||
}
|
||||
uv_loop_init(loop);
|
||||
|
||||
printf("\nUsage: lvgldemo demo_name\n");
|
||||
printf("\ndemo_name:\n");
|
||||
lv_memset(&uv_info, 0, sizeof(uv_info));
|
||||
uv_info.loop = loop;
|
||||
uv_info.disp = result->disp;
|
||||
uv_info.indev = result->indev;
|
||||
#ifdef CONFIG_UINPUT_TOUCH
|
||||
uv_info.uindev = result->utouch_indev;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
printf(" %s\n", func_key_pair[i].name);
|
||||
}
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: find_demo_create_func
|
||||
****************************************************************************/
|
||||
|
||||
static demo_create_func_t find_demo_create_func(FAR const char *name)
|
||||
{
|
||||
int i;
|
||||
const int len = nitems(func_key_pair) - 1;
|
||||
|
||||
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;
|
||||
data = lv_nuttx_uv_init(&uv_info);
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
lv_nuttx_uv_deinit(&data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: main or lvgldemo_main
|
||||
* Name: main or lv_demos_main
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
@ -174,68 +106,47 @@ static demo_create_func_t find_demo_create_func(FAR const char *name)
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
demo_create_func_t demo_create_func;
|
||||
FAR const char *demo = NULL;
|
||||
const int func_key_pair_len = nitems(func_key_pair);
|
||||
lv_nuttx_dsc_t info;
|
||||
lv_nuttx_result_t result;
|
||||
|
||||
#ifdef CONFIG_LIBUV
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
uv_loop_t ui_loop;
|
||||
#endif
|
||||
|
||||
/* If no arguments are specified and only 1 demo exists, select the demo */
|
||||
|
||||
if (argc == 1 && func_key_pair_len == 2) /* 2 because of NULL sentinel */
|
||||
{
|
||||
demo = func_key_pair[0].name;
|
||||
}
|
||||
else if (argc != 2)
|
||||
{
|
||||
show_usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
demo = argv[1];
|
||||
}
|
||||
|
||||
demo_create_func = find_demo_create_func(demo);
|
||||
|
||||
if (demo_create_func == NULL)
|
||||
{
|
||||
show_usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NEED_BOARDINIT
|
||||
/* Perform board-specific driver initialization */
|
||||
|
||||
boardctl(BOARDIOC_INIT, 0);
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_FINALINIT
|
||||
/* Perform architecture-specific final-initialization (if configured) */
|
||||
|
||||
boardctl(BOARDIOC_FINALINIT, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* LVGL initialization */
|
||||
|
||||
lv_init();
|
||||
|
||||
/* LVGL port initialization */
|
||||
lv_nuttx_dsc_init(&info);
|
||||
|
||||
lv_port_init();
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LCD
|
||||
info.fb_path = "/dev/lcd0";
|
||||
#endif
|
||||
|
||||
/* LVGL demo creation */
|
||||
lv_nuttx_init(&info, &result);
|
||||
|
||||
demo_create_func();
|
||||
if (result.disp == NULL)
|
||||
{
|
||||
LV_LOG_ERROR("lv_demos initialization failure!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Handle LVGL tasks */
|
||||
if (!lv_demos_create(&argv[1], argc - 1))
|
||||
{
|
||||
lv_demos_show_help();
|
||||
|
||||
#ifdef CONFIG_LIBUV
|
||||
uv_loop_init(&ui_loop);
|
||||
lv_port_libuv_init(&ui_loop);
|
||||
uv_run(&ui_loop, UV_RUN_DEFAULT);
|
||||
/* we can add custom demos here */
|
||||
|
||||
goto demo_end;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LV_USE_NUTTX_LIBUV
|
||||
lv_nuttx_uv_loop(&ui_loop, &result);
|
||||
#else
|
||||
while (1)
|
||||
{
|
||||
@ -249,5 +160,9 @@ int main(int argc, FAR char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
demo_end:
|
||||
lv_disp_remove(result.disp);
|
||||
lv_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ if(CONFIG_GRAPHICS_LVGL)
|
||||
FetchContent_Declare(
|
||||
lvgl_fetch
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
|
||||
URL "https://github.com/lvgl/lvgl/archive/refs/tags/v${CONFIG_LVGL_VERSION}.zip"
|
||||
URL "https://github.com/lvgl/lvgl/archive/refs/tags/v9.1.0.zip"
|
||||
SOURCE_DIR
|
||||
${CMAKE_CURRENT_LIST_DIR}/lvgl
|
||||
BINARY_DIR
|
||||
@ -56,81 +56,21 @@ if(CONFIG_GRAPHICS_LVGL)
|
||||
# Flags and Sources
|
||||
# ############################################################################
|
||||
|
||||
# Relax LVGL's format checking and unused variable checking to avoid errors
|
||||
|
||||
set(CFLAGS -Wno-format -Wno-format-security -Wno-unused-variable)
|
||||
|
||||
# Since this change is only merged into the lvgl.v9, let us workaround for v8
|
||||
# ./lvgl/src/core/lv_obj.c:363:25: warning: variable 'x' set but not used
|
||||
# [-Wunused-but-set-variable] 363 | static uint32_t x = 0; | ^ 1
|
||||
# warning generated.
|
||||
|
||||
list(APPEND CFLAGS -Wno-unused-but-set-variable)
|
||||
|
||||
set(CSRCS port/lv_port.c port/lv_port_tick.c)
|
||||
|
||||
if(CONFIG_LIBUV)
|
||||
list(APPEND CSRCS port/lv_port_libuv.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_LCDDEV)
|
||||
list(APPEND CSRCS port/lv_port_lcddev.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_FBDEV)
|
||||
list(APPEND CSRCS port/lv_port_fbdev.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_TOUCHPAD)
|
||||
list(APPEND CSRCS port/lv_port_touchpad.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_BUTTON)
|
||||
list(APPEND CSRCS port/lv_port_button.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_KEYPAD)
|
||||
list(APPEND CSRCS port/lv_port_keypad.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_PORT_USE_ENCODER)
|
||||
list(APPEND CSRCS port/lv_port_encoder.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_USE_LOG)
|
||||
list(APPEND CSRCS port/lv_port_syslog.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_MEM_CUSTOM)
|
||||
if(NOT CONFIG_LV_PORT_MEM_CUSTOM_SIZE EQUAL 0)
|
||||
list(APPEND CFLAGS -DLV_MEM_CUSTOM_ALLOC=lv_port_mem_alloc)
|
||||
list(APPEND CFLAGS -DLV_MEM_CUSTOM_FREE=lv_port_mem_free)
|
||||
list(APPEND CFLAGS -DLV_MEM_CUSTOM_REALLOC=lv_port_mem_realloc)
|
||||
list(APPEND CSRCS port/lv_port_mem.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ############################################################################
|
||||
# Library Configuration
|
||||
# ############################################################################
|
||||
|
||||
set(INCDIR ${CMAKE_CURRENT_LIST_DIR} ${NUTTX_DIR}/include)
|
||||
|
||||
add_subdirectory(${LVGL_DIR})
|
||||
nuttx_add_external_library(lvgl)
|
||||
nuttx_add_external_library(lvgl_demos)
|
||||
nuttx_add_external_library(lvgl_examples)
|
||||
|
||||
target_include_directories(lvgl PRIVATE ${INCDIR})
|
||||
target_include_directories(lvgl PUBLIC ${CMAKE_BINARY_DIR}/include)
|
||||
target_compile_options(lvgl PRIVATE ${CFLAGS})
|
||||
if(NOT CONFIG_LV_ASSERT_HANDLER_INCLUDE STREQUAL "")
|
||||
target_compile_definitions(lvgl PRIVATE "LV_ASSERT_HANDLER=ASSERT(0)\;")
|
||||
endif()
|
||||
|
||||
nuttx_add_library(lvgl_nuttx)
|
||||
target_sources(lvgl_nuttx PRIVATE ${CSRCS})
|
||||
target_link_libraries(lvgl_nuttx lvgl)
|
||||
|
||||
# allow to include via lvgl/lvgl.h
|
||||
target_include_directories(lvgl_nuttx PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(lvgl PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
endif()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,69 +25,8 @@ include $(APPDIR)/Make.defs
|
||||
LVGL_DIR = .
|
||||
LVGL_DIR_NAME = lvgl
|
||||
|
||||
# Relax LVGL's format checking and unused variable checking to avoid errors
|
||||
|
||||
CFLAGS += -Wno-format -Wno-format-security -Wno-unused-variable
|
||||
|
||||
# Since this change is only merged into the lvgl.v9, let us workaround for v8
|
||||
# ./lvgl/src/core/lv_obj.c:363:25: warning: variable 'x' set but not used [-Wunused-but-set-variable]
|
||||
# 363 | static uint32_t x = 0;
|
||||
# | ^
|
||||
# 1 warning generated.
|
||||
|
||||
CFLAGS += -Wno-unused-but-set-variable
|
||||
|
||||
-include ./lvgl/lvgl.mk
|
||||
|
||||
CSRCS += port/lv_port.c
|
||||
CSRCS += port/lv_port_tick.c
|
||||
|
||||
ifeq ($(CONFIG_LIBUV),y)
|
||||
CSRCS += port/lv_port_libuv.c
|
||||
endif
|
||||
|
||||
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
|
||||
@ -98,7 +37,7 @@ WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
|
||||
|
||||
CONFIG_GRAPH_LVGL_URL ?= "https://github.com/lvgl/lvgl/archive/refs/tags"
|
||||
|
||||
LVGL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LVGL_VERSION)))
|
||||
LVGL_VERSION = 9.1.0
|
||||
LVGL_TARBALL = v$(LVGL_VERSION).zip
|
||||
|
||||
LVGL_UNPACKNAME = lvgl
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,91 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* 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_H
|
||||
#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize all porting.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lv_port_init(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_H */
|
@ -1,238 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
#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;
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,162 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/input/mouse.h>
|
||||
#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;
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,675 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/video/fb.h>
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#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
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FB_UPDATE)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_update_area
|
||||
****************************************************************************/
|
||||
|
||||
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_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_check_inv_area_covered
|
||||
****************************************************************************/
|
||||
|
||||
static bool fbdev_check_inv_area_covered(FAR lv_disp_t *disp_refr,
|
||||
FAR const lv_area_t *area_p)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < disp_refr->inv_p; i++)
|
||||
{
|
||||
FAR const lv_area_t *cur_area;
|
||||
|
||||
/* Skip joined area */
|
||||
|
||||
if (disp_refr->inv_area_joined[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cur_area = &disp_refr->inv_areas[i];
|
||||
|
||||
/* Check cur_area is coverd area_p */
|
||||
|
||||
if (_lv_area_is_in(area_p, cur_area, 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
FAR lv_draw_ctx_t *draw_ctx;
|
||||
lv_coord_t hor_res;
|
||||
int i;
|
||||
|
||||
/* No need sync buffer when inv_areas_len == 0 */
|
||||
|
||||
if (fbdev_obj->inv_areas_len == 0)
|
||||
{
|
||||
LV_LOG_TRACE("No sync area");
|
||||
return;
|
||||
}
|
||||
|
||||
LV_LOG_TRACE("Start sync %d areas...", fbdev_obj->inv_areas_len);
|
||||
|
||||
disp_refr = _lv_refr_get_disp_refreshing();
|
||||
draw_ctx = disp_drv->draw_ctx;
|
||||
hor_res = disp_drv->hor_res;
|
||||
|
||||
for (i = 0; i < fbdev_obj->inv_areas_len; i++)
|
||||
{
|
||||
FAR const lv_area_t *last_area = &fbdev_obj->inv_areas[i];
|
||||
|
||||
LV_LOG_TRACE("Check area[%d]: (%d, %d) %d x %d",
|
||||
i,
|
||||
(int)last_area->x1, (int)last_area->y1,
|
||||
(int)lv_area_get_width(last_area),
|
||||
(int)lv_area_get_height(last_area));
|
||||
|
||||
if (fbdev_check_inv_area_covered(disp_refr, last_area))
|
||||
{
|
||||
LV_LOG_TRACE("Skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Sync the inv area of the previous frame */
|
||||
|
||||
draw_ctx->buffer_copy(
|
||||
draw_ctx,
|
||||
fbdev_obj->act_buffer, hor_res, last_area,
|
||||
fbdev_obj->last_buffer, hor_res, last_area);
|
||||
|
||||
LV_LOG_TRACE("Copied");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,252 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/input/buttons.h>
|
||||
#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 < nitems(g_keypad_map); 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;
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,304 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/lcd/lcd_dev.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
memset(lcddev_obj, 0, sizeof(struct lcddev_obj_s));
|
||||
|
||||
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;
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,186 +0,0 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/lvgl/port/lv_port_libuv.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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <uv.h>
|
||||
#include <stdlib.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "lv_port_libuv.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
struct lv_uv_ctx_s
|
||||
{
|
||||
int fd;
|
||||
uv_timer_t ui_timer;
|
||||
uv_poll_t ui_refr;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ui_timer_cb
|
||||
****************************************************************************/
|
||||
|
||||
static void ui_timer_cb(FAR uv_timer_t *handle)
|
||||
{
|
||||
uint32_t sleep_ms;
|
||||
LV_LOG_TRACE("start");
|
||||
|
||||
sleep_ms = lv_timer_handler();
|
||||
|
||||
/* Prevent busy loops. */
|
||||
|
||||
if (sleep_ms == 0)
|
||||
{
|
||||
sleep_ms = 1;
|
||||
}
|
||||
|
||||
uv_timer_start(handle, ui_timer_cb, sleep_ms, 0);
|
||||
LV_LOG_TRACE("stop, sleep %" PRIu32 " ms", sleep_ms);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ui_refr_cb
|
||||
****************************************************************************/
|
||||
|
||||
static void ui_refr_cb(FAR uv_poll_t *handle, int status, int events)
|
||||
{
|
||||
LV_LOG_TRACE("start");
|
||||
_lv_disp_refr_timer(NULL);
|
||||
LV_LOG_TRACE("stop");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_libuv_init
|
||||
*
|
||||
* Description:
|
||||
* Add the UI event loop to the uv_loop.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loop - Pointer to uv_loop.
|
||||
*
|
||||
* Returned Value:
|
||||
* Pointer to UI event context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *lv_port_libuv_init(FAR void *loop)
|
||||
{
|
||||
int fd;
|
||||
FAR uv_loop_t *ui_loop = loop;
|
||||
FAR lv_disp_t *disp;
|
||||
FAR struct lv_uv_ctx_s *uv_ctx;
|
||||
|
||||
LV_LOG_INFO("dev: " CONFIG_LV_PORT_UV_POLL_DEVICEPATH " opening...");
|
||||
fd = open(CONFIG_LV_PORT_UV_POLL_DEVICEPATH, O_WRONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
LV_LOG_ERROR(CONFIG_LV_PORT_UV_POLL_DEVICEPATH
|
||||
" open failed: %d", errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
disp = lv_disp_get_default();
|
||||
LV_ASSERT_NULL(disp);
|
||||
|
||||
if (disp->refr_timer == NULL)
|
||||
{
|
||||
LV_LOG_ERROR("disp->refr_timer is NULL");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remove default refr timer. */
|
||||
|
||||
lv_timer_del(disp->refr_timer);
|
||||
disp->refr_timer = NULL;
|
||||
|
||||
uv_ctx = malloc(sizeof(struct lv_uv_ctx_s));
|
||||
LV_ASSERT_MALLOC(uv_ctx);
|
||||
|
||||
memset(uv_ctx, 0, sizeof(struct lv_uv_ctx_s));
|
||||
uv_ctx->fd = fd;
|
||||
|
||||
LV_LOG_INFO("init ui_timer...");
|
||||
uv_timer_init(ui_loop, &uv_ctx->ui_timer);
|
||||
uv_timer_start(&uv_ctx->ui_timer, ui_timer_cb, 1, 1);
|
||||
|
||||
LV_LOG_INFO("init ui_refr...");
|
||||
uv_poll_init(ui_loop, &uv_ctx->ui_refr, fd);
|
||||
uv_poll_start(&uv_ctx->ui_refr, UV_WRITABLE, ui_refr_cb);
|
||||
|
||||
LV_LOG_INFO("ui loop start OK");
|
||||
return uv_ctx;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_libuv_uninit
|
||||
*
|
||||
* Description:
|
||||
* Remove the UI event loop.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Pointer to UI event context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lv_port_libuv_uninit(FAR void *ctx)
|
||||
{
|
||||
FAR struct lv_uv_ctx_s *uv_ctx = ctx;
|
||||
|
||||
if (uv_ctx == NULL)
|
||||
{
|
||||
LV_LOG_WARN("uv_ctx is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
uv_close((FAR uv_handle_t *)&uv_ctx->ui_timer, NULL);
|
||||
uv_close((FAR uv_handle_t *)&uv_ctx->ui_refr, NULL);
|
||||
close(uv_ctx->fd);
|
||||
free(ctx);
|
||||
LV_LOG_INFO("ui loop close OK");
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/lvgl/port/lv_port_libuv.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_LIBUV_H
|
||||
#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_LIBUV_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_LIBUV)
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_libuv_init
|
||||
*
|
||||
* Description:
|
||||
* Add the UI event loop to the uv_loop.
|
||||
*
|
||||
* Input Parameters:
|
||||
* loop - Pointer to uv_loop.
|
||||
*
|
||||
* Returned Value:
|
||||
* Pointer to UI event context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *lv_port_libuv_init(FAR void *loop);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_libuv_uninit
|
||||
*
|
||||
* Description:
|
||||
* Remove the UI event loop.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Pointer to UI event context.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lv_port_libuv_uninit(FAR void *ctx);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_LIBUV */
|
||||
|
||||
#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_LIBUV_H */
|
@ -1,173 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/mm/mm.h>
|
||||
#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);
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
@ -1,57 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* 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 <lvgl/lvgl.h>
|
||||
#include <syslog.h>
|
||||
#include "lv_port_syslog.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_print_cb
|
||||
****************************************************************************/
|
||||
|
||||
static void syslog_print_cb(FAR const char *buf)
|
||||
{
|
||||
syslog(LOG_INFO, "[LVGL] %s", buf);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* 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_SYSLOG_H
|
||||
#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_SYSLOG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lv_port_syslog_init
|
||||
*
|
||||
* Description:
|
||||
* Syslog interface initialization.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lv_port_syslog_init(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_LV_USE_LOG */
|
||||
|
||||
#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_SYSLOG_H */
|
@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* 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 <nuttx/config.h>
|
||||
#include <time.h>
|
||||
#include "lv_port_tick.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t millis(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
uint32_t tick = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
|
||||
return tick;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
* 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_TICK_H
|
||||
#define __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TICK_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t millis(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_GRAPHICS_LVGL_PORT_LV_PORT_TICK_H */
|
@ -1,207 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <nuttx/input/touchscreen.h>
|
||||
#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));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: touchpad_cursor_init
|
||||
****************************************************************************/
|
||||
|
||||
static void touchpad_cursor_init(FAR lv_indev_t *indev, lv_coord_t size)
|
||||
{
|
||||
FAR lv_obj_t *cursor;
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cursor = lv_obj_create(lv_layer_sys());
|
||||
lv_obj_remove_style_all(cursor);
|
||||
|
||||
lv_obj_set_size(cursor, size, size);
|
||||
lv_obj_set_style_translate_x(cursor, -size / 2, 0);
|
||||
lv_obj_set_style_translate_y(cursor, -size / 2, 0);
|
||||
lv_obj_set_style_radius(cursor, LV_RADIUS_CIRCLE, 0);
|
||||
lv_obj_set_style_bg_opa(cursor, LV_OPA_50, 0);
|
||||
lv_obj_set_style_bg_color(cursor, lv_color_black(), 0);
|
||||
lv_obj_set_style_border_width(cursor, 2, 0);
|
||||
lv_obj_set_style_border_color(cursor, lv_palette_main(LV_PALETTE_GREY), 0);
|
||||
lv_indev_set_cursor(indev, cursor);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
}
|
||||
|
||||
touchpad_cursor_init(indev, CONFIG_LV_PORT_TOUCHPAD_CURSOR_SIZE);
|
||||
|
||||
return indev;
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* 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 <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
Loading…
x
Reference in New Issue
Block a user