Add nuttx to the system framework, which is 10.1.0
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menuconfig EXAMPLES_LVGLDEMO
|
||||
tristate "LVGL Demo"
|
||||
default n
|
||||
---help---
|
||||
Enable build the Light and Versatile Graphics Library Demo programs
|
||||
|
||||
if EXAMPLES_LVGLDEMO
|
||||
|
||||
config EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
bool "Calibrate touchscreen"
|
||||
default y
|
||||
---help---
|
||||
Calibrate touchscreen before demo start, but some touchscreen
|
||||
don't need it, like capacitive touchscreen.
|
||||
|
||||
config EXAMPLES_LVGLDEMO_BUFF_SIZE
|
||||
int "Display buffer size (in line)"
|
||||
default 20
|
||||
|
||||
config EXAMPLES_LVGLDEMO_DOUBLE_BUFFERING
|
||||
bool "Enable double buffering"
|
||||
default n
|
||||
---help---
|
||||
When double buffering is enabled, LVGL expects the size of both
|
||||
buffers as:
|
||||
CONFIG_LV_HOR_RES * CONFIG_EXAMPLES_LVGLDEMO_BUFF_SIZE.
|
||||
True double buffering support is enabled if both buffers have the
|
||||
same dimensions as the display device resolution. Otherwise,
|
||||
LVGL will perform a number of partial refreshes according to the
|
||||
defined buffer size.
|
||||
|
||||
config EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
bool "Flush the display buffer asynchronously"
|
||||
default n
|
||||
---help---
|
||||
Enable this option to perform an asynchronous write of the buffer
|
||||
contents to the display device.
|
||||
|
||||
choice
|
||||
prompt "Select a demo application"
|
||||
default EXAMPLES_LVGLDEMO_WIDGETS
|
||||
|
||||
config EXAMPLES_LVGLDEMO_BENCHMARK
|
||||
bool "Benchmark"
|
||||
|
||||
config EXAMPLES_LVGLDEMO_PRINTER
|
||||
bool "Printer"
|
||||
---help---
|
||||
This demo is optimized for 800 * 480 resolution
|
||||
|
||||
config EXAMPLES_LVGLDEMO_STRESS
|
||||
bool "Stress"
|
||||
|
||||
config EXAMPLES_LVGLDEMO_WIDGETS
|
||||
bool "Widgets"
|
||||
|
||||
endchoice
|
||||
|
||||
if EXAMPLES_LVGLDEMO_WIDGETS
|
||||
|
||||
config EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW
|
||||
bool "Enable Slideshow mode for Widgets example"
|
||||
default n
|
||||
---help---
|
||||
Slideshow mode consists of a non-interactive demonstration of the
|
||||
Widgets example.
|
||||
|
||||
endif # EXAMPLES_LVGLDEMO_WIDGETS
|
||||
|
||||
config EXAMPLES_LVGLDEMO_PRIORITY
|
||||
int "lvgl task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_LVGLDEMO_STACKSIZE
|
||||
int "lvgldemo stack size"
|
||||
default 16384
|
||||
|
||||
config EXAMPLES_LGVLDEMO_MINOR
|
||||
int "Touchscreen minor device number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number. Minor=N corresponds to touchscreen device
|
||||
/dev/inputN. Note this value must with EXAMPLES_LGVLDEMO_DEVPATH.
|
||||
Default 0.
|
||||
|
||||
config EXAMPLES_LGVLDEMO_DEVPATH
|
||||
string "Touchscreen device path"
|
||||
default "/dev/input0"
|
||||
---help---
|
||||
The path to the touchscreen device. This must be consistent with
|
||||
EXAMPLES_LGVLDEMO_MINOR. Default: "/dev/input0"
|
||||
|
||||
config EXAMPLES_LGVLDEMO_MOUSE
|
||||
bool "Mouse interface"
|
||||
default n
|
||||
---help---
|
||||
The LittleVGL demo can also be configured to work with a mouse
|
||||
driver by setting this option.
|
||||
|
||||
endif
|
||||
@@ -0,0 +1,39 @@
|
||||
############################################################################
|
||||
# apps/examples/lvgdemo/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_LVGLDEMO),)
|
||||
CONFIGURED_APPS += $(APPDIR)/examples/lvgldemo
|
||||
endif
|
||||
@@ -0,0 +1,111 @@
|
||||
############################################################################
|
||||
# apps/examples/lgvldemo/Makefile
|
||||
#
|
||||
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# LittleVGL demo built-in application info
|
||||
|
||||
CONFIG_LV_EXAMPLES_URL ?= https://github.com/lvgl/lv_examples/archive
|
||||
|
||||
LVGL_EXAMPLES_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LVGL_VERSION)))
|
||||
LVGL_EXAMPLES_TARBALL = v$(LVGL_EXAMPLES_VERSION).zip
|
||||
|
||||
LVGL_EXAMPLES_UNPACKNAME = lv_examples
|
||||
UNPACK ?= unzip -o
|
||||
|
||||
PROGNAME = lvgldemo
|
||||
PRIORITY = $(CONFIG_EXAMPLES_LVGLDEMO_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_LVGLDEMO_STACKSIZE)
|
||||
MODULE = $(CONFIG_EXAMPLES_LVGLDEMO)
|
||||
|
||||
# LittleVGL demo Example
|
||||
|
||||
CSRCS += fbdev.c lcddev.c
|
||||
|
||||
ifneq ($(CONFIG_INPUT),)
|
||||
CSRCS += tp.c tp_cal.c
|
||||
endif
|
||||
|
||||
# static common assets used in multiple examples
|
||||
|
||||
LV_EXAMPLE_ASSETS = $(wildcard ./lv_examples/assets/*.c)
|
||||
CSRCS += $(notdir $(LV_EXAMPLE_ASSETS))
|
||||
VPATH += lv_examples/assets
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_BENCHMARK),)
|
||||
CSRCS += lv_demo_benchmark.c
|
||||
VPATH += lv_examples/src/lv_demo_benchmark
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_PRINTER),)
|
||||
LV_PRINTER_IMAGES = $(wildcard ./lv_examples/src/lv_demo_printer/images/*.c)
|
||||
CSRCS += lv_demo_printer.c lv_demo_printer_theme.c
|
||||
CSRCS += $(notdir $(LV_PRINTER_IMAGES))
|
||||
VPATH += lv_examples/src/lv_demo_printer
|
||||
VPATH += lv_examples/src/lv_demo_printer/images
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_STRESS),)
|
||||
CSRCS += lv_demo_stress.c
|
||||
VPATH += lv_examples/src/lv_demo_stress
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_LVGLDEMO_WIDGETS),)
|
||||
CSRCS += lv_demo_widgets.c
|
||||
VPATH += lv_examples/src/lv_demo_widgets
|
||||
endif
|
||||
|
||||
MAINSRC = lvgldemo.c
|
||||
|
||||
CFLAGS += ${shell $(DEFINE) "$(CC)" LV_LVGL_H_INCLUDE_SIMPLE} -Wno-format
|
||||
CXXFLAGS += ${shell $(DEFINE) "$(CC)" LV_LVGL_H_INCLUDE_SIMPLE} -Wno-format
|
||||
|
||||
$(LVGL_EXAMPLES_TARBALL):
|
||||
@echo "Downloading: $(LVGL_EXAMPLES_TARBALL)"
|
||||
$(Q) curl -O -L $(CONFIG_LV_EXAMPLES_URL)/$(LVGL_EXAMPLES_TARBALL)
|
||||
|
||||
$(LVGL_EXAMPLES_UNPACKNAME): $(LVGL_EXAMPLES_TARBALL)
|
||||
@echo "Unpacking: $(LVGL_EXAMPLES_TARBALL) -> $(LVGL_EXAMPLES_UNPACKNAME)"
|
||||
$(Q) $(UNPACK) $(LVGL_EXAMPLES_TARBALL)
|
||||
$(Q) mv lv_examples-$(LVGL_EXAMPLES_VERSION) $(LVGL_EXAMPLES_UNPACKNAME)
|
||||
$(Q) touch $(LVGL_EXAMPLES_UNPACKNAME)
|
||||
|
||||
context:: $(LVGL_EXAMPLES_UNPACKNAME)
|
||||
|
||||
distclean::
|
||||
$(call DELDIR, $(LVGL_EXAMPLES_UNPACKNAME))
|
||||
$(call DELFILE, $(LVGL_EXAMPLES_TARBALL))
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
@@ -0,0 +1,484 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/fbdev.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "fbdev.h"
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/video/fb.h>
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef FBDEV_PATH
|
||||
# define FBDEV_PATH "/dev/fb0"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct fb_state_s
|
||||
{
|
||||
int fd;
|
||||
struct fb_videoinfo_s vinfo;
|
||||
struct fb_planeinfo_s pinfo;
|
||||
FAR void *fbmem;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
struct fb_state_s state;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
static pthread_t fb_write_thread;
|
||||
static sem_t flush_sem;
|
||||
static sem_t wait_sem;
|
||||
|
||||
static lv_area_t lv_area;
|
||||
static lv_color_t *lv_color_p;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_wait
|
||||
*
|
||||
* Description:
|
||||
* Wait for the flushing operation conclusion to notify LVGL.
|
||||
*
|
||||
* Input Parameters:
|
||||
* disp_drv - LVGL driver interface
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static void fbdev_wait(lv_disp_drv_t *disp_drv)
|
||||
{
|
||||
sem_wait(&wait_sem);
|
||||
|
||||
/* Tell the flushing is ready */
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_flush_internal
|
||||
*
|
||||
* Description:
|
||||
* Write the buffer to Framebuffer interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* area - Area of the screen to be flushed
|
||||
* color_p - A n array of colors
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int fbdev_flush_internal(const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
#ifdef CONFIG_FB_UPDATE
|
||||
struct fb_area_s fb_area;
|
||||
#endif
|
||||
int32_t x1 = area->x1;
|
||||
int32_t y1 = area->y1;
|
||||
int32_t x2 = area->x2;
|
||||
int32_t y2 = area->y2;
|
||||
int32_t act_x1;
|
||||
int32_t act_y1;
|
||||
int32_t act_x2;
|
||||
int32_t act_y2;
|
||||
long int location = 0;
|
||||
|
||||
if (state.fbmem == NULL)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Return if the area is out the screen */
|
||||
|
||||
if (x2 < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (y2 < 0)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (x1 > state.vinfo.xres - 1)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (y1 > state.vinfo.yres - 1)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Truncate the area to the screen */
|
||||
|
||||
act_x1 = x1 < 0 ? 0 : x1;
|
||||
act_y1 = y1 < 0 ? 0 : y1;
|
||||
act_x2 = x2 > state.vinfo.xres - 1 ? state.vinfo.xres - 1 : x2;
|
||||
act_y2 = y2 > state.vinfo.yres - 1 ? state.vinfo.yres - 1 : y2;
|
||||
|
||||
if (state.pinfo.bpp == 8)
|
||||
{
|
||||
uint8_t *fbp8 = (uint8_t *)state.fbmem;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
|
||||
for (y = act_y1; y <= act_y2; y++)
|
||||
{
|
||||
for (x = act_x1; x <= act_x2; x++)
|
||||
{
|
||||
location = x + (y * state.vinfo.xres);
|
||||
fbp8[location] = color_p->full;
|
||||
color_p++;
|
||||
}
|
||||
|
||||
color_p += x2 - act_x2;
|
||||
}
|
||||
}
|
||||
|
||||
if (state.pinfo.bpp == 16)
|
||||
{
|
||||
uint16_t *fbp16 = (uint16_t *)state.fbmem;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
|
||||
for (y = act_y1; y <= act_y2; y++)
|
||||
{
|
||||
for (x = act_x1; x <= act_x2; x++)
|
||||
{
|
||||
location = x + (y * state.vinfo.xres);
|
||||
fbp16[location] = color_p->full;
|
||||
color_p++;
|
||||
}
|
||||
|
||||
color_p += x2 - act_x2;
|
||||
}
|
||||
}
|
||||
|
||||
if (state.pinfo.bpp == 24 || state.pinfo.bpp == 32)
|
||||
{
|
||||
uint32_t *fbp32 = (uint32_t *)state.fbmem;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
|
||||
for (y = act_y1; y <= act_y2; y++)
|
||||
{
|
||||
for (x = act_x1; x <= act_x2; x++)
|
||||
{
|
||||
location = x + (y * state.vinfo.xres);
|
||||
fbp32[location] = color_p->full;
|
||||
color_p++;
|
||||
}
|
||||
|
||||
color_p += x2 - act_x2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FB_UPDATE
|
||||
fb_area.x = act_x1;
|
||||
fb_area.y = act_y1;
|
||||
fb_area.w = act_x2 - act_x1 + 1;
|
||||
fb_area.h = act_y2 - act_y1 + 1;
|
||||
ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&fb_area));
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_async_flush
|
||||
*
|
||||
* Description:
|
||||
* Flush a buffer to the marked area asynchronously.
|
||||
*
|
||||
* Input Parameters:
|
||||
* disp_drv - LVGL driver interface
|
||||
* area - Area of the screen to be flushed
|
||||
* color_p - A n array of colors
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static void fbdev_async_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
||||
lv_color_t *color_p)
|
||||
{
|
||||
UNUSED(disp_drv);
|
||||
|
||||
lv_area.y1 = area->y1;
|
||||
lv_area.y2 = area->y2;
|
||||
lv_area.x1 = area->x1;
|
||||
lv_area.x2 = area->x2;
|
||||
|
||||
lv_color_p = color_p;
|
||||
|
||||
sem_post(&flush_sem);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_sync_flush
|
||||
*
|
||||
* Description:
|
||||
* Flush a buffer to the marked area synchronously.
|
||||
*
|
||||
* Input Parameters:
|
||||
* disp_drv - LVGL driver interface
|
||||
* area - Area of the screen to be flushed
|
||||
* color_p - A n array of colors
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static void fbdev_sync_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
||||
lv_color_t *color_p)
|
||||
{
|
||||
fbdev_flush_internal(area, color_p);
|
||||
|
||||
/* Tell the flushing is ready */
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_write
|
||||
*
|
||||
* Description:
|
||||
* Thread for writing the buffer to Framebuffer interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* arg - Context data from the parent thread
|
||||
*
|
||||
* Returned Value:
|
||||
* Context data to the parent thread
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static pthread_addr_t fbdev_write(pthread_addr_t arg)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
while (ret == OK)
|
||||
{
|
||||
sem_wait(&flush_sem);
|
||||
|
||||
ret = fbdev_flush_internal(&lv_area, lv_color_p);
|
||||
|
||||
sem_post(&wait_sem);
|
||||
}
|
||||
|
||||
gerr("Failed to write buffer contents to display device\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fbdev_init
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input Parameters:
|
||||
* lv_drvr -- LVGL driver interface
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int fbdev_init(lv_disp_drv_t *lv_drvr)
|
||||
{
|
||||
FAR const char *fbdev = "/dev/fb0";
|
||||
int ret;
|
||||
|
||||
/* Open the framebuffer driver */
|
||||
|
||||
state.fd = open(fbdev, O_RDWR);
|
||||
if (state.fd < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
gerr("Failed to open %s: %d\n", fbdev, errcode);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Get the characteristics of the framebuffer */
|
||||
|
||||
ret = ioctl(state.fd, FBIOGET_VIDEOINFO,
|
||||
(unsigned long)((uintptr_t)&state.vinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
||||
gerr("ioctl(FBIOGET_VIDEOINFO) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ginfo("VideoInfo:\n\tfmt: %u\n\txres: %u\n\tyres: %u\n\tnplanes: %u\n",
|
||||
state.vinfo.fmt, state.vinfo.xres, state.vinfo.yres,
|
||||
state.vinfo.nplanes);
|
||||
|
||||
ret = ioctl(state.fd, FBIOGET_PLANEINFO,
|
||||
(unsigned long)((uintptr_t)&state.pinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
gerr("ioctl(FBIOGET_PLANEINFO) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ginfo("PlaneInfo (plane 0):\n"
|
||||
"\tfbmem: %p\n\tfblen: %l\n\tstride: %u\n"
|
||||
"\tdisplay: %u\n\tbpp: %u\n\t",
|
||||
state.pinfo.fbmem, (unsigned long)state.pinfo.fblen,
|
||||
state.pinfo.stride, state.pinfo.display, state.pinfo.bpp);
|
||||
|
||||
lv_drvr->hor_res = state.vinfo.xres;
|
||||
lv_drvr->ver_res = state.vinfo.yres;
|
||||
#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
lv_drvr->flush_cb = fbdev_sync_flush;
|
||||
#else
|
||||
lv_drvr->flush_cb = fbdev_async_flush;
|
||||
lv_drvr->wait_cb = fbdev_wait;
|
||||
|
||||
/* Initialize the mutexes for buffer flushing synchronization */
|
||||
|
||||
sem_init(&flush_sem, 0, 0);
|
||||
sem_init(&wait_sem, 0, 0);
|
||||
|
||||
/* Initialize the buffer flushing thread */
|
||||
|
||||
pthread_create(&fb_write_thread, NULL, fbdev_write, NULL);
|
||||
#endif
|
||||
|
||||
/* Only these pixel depths are supported. viinfo.fmt is ignored, only
|
||||
* certain color formats are supported.
|
||||
*/
|
||||
|
||||
if (state.pinfo.bpp != 32 && state.pinfo.bpp != 16 &&
|
||||
state.pinfo.bpp != 8 && state.pinfo.bpp != 1)
|
||||
{
|
||||
gerr("bpp=%u not supported\n", state.pinfo.bpp);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* mmap() the framebuffer.
|
||||
*
|
||||
* NOTE: In the FLAT build the frame buffer address returned by the
|
||||
* FBIOGET_PLANEINFO IOCTL command will be the same as the framebuffer
|
||||
* address. mmap(), however, is the preferred way to get the framebuffer
|
||||
* address because in the KERNEL build, it will perform the necessary
|
||||
* address mapping to make the memory accessible to the application.
|
||||
*/
|
||||
|
||||
state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_FILE, state.fd, 0);
|
||||
if (state.fbmem == MAP_FAILED)
|
||||
{
|
||||
int errcode = errno;
|
||||
gerr("ioctl(FBIOGET_PLANEINFO) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ginfo("Mapped FB: %p\n", state.fbmem);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/fbdev.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_LVGLDEMO_FBDEV_H
|
||||
#define __APPS_EXAMPLES_LVGLDEMO_FBDEV_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int fbdev_init(lv_disp_drv_t *lv_drvr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_EXAMPLES_LVGLDEMO_FBDEV_H */
|
||||
@@ -0,0 +1,315 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/lcddev.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "lcddev.h"
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/lcd/lcd_dev.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LCDDEV_PATH
|
||||
# define LCDDEV_PATH "/dev/lcd0"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct lcd_state_s
|
||||
{
|
||||
int fd;
|
||||
struct fb_videoinfo_s vinfo;
|
||||
struct lcd_planeinfo_s pinfo;
|
||||
bool rotated;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct lcd_state_s state;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
static pthread_t lcd_write_thread;
|
||||
static sem_t flush_sem;
|
||||
static sem_t wait_sem;
|
||||
static struct lcddev_area_s lcd_area;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lcddev_wait
|
||||
*
|
||||
* Description:
|
||||
* Wait for the flushing operation conclusion to notify LVGL.
|
||||
*
|
||||
* Input Parameters:
|
||||
* disp_drv - LVGL driver interface
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static void lcddev_wait(lv_disp_drv_t *disp_drv)
|
||||
{
|
||||
sem_wait(&wait_sem);
|
||||
|
||||
/* Tell the flushing is ready */
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lcddev_flush
|
||||
*
|
||||
* Description:
|
||||
* Flush a buffer to the marked area.
|
||||
*
|
||||
* Input Parameters:
|
||||
* disp_drv - LVGL driver interface
|
||||
* lv_area_t - Area of the screen to be flushed
|
||||
* color_p - A n array of colors
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static void lcddev_async_flush(lv_disp_drv_t *disp_drv,
|
||||
const lv_area_t *area,
|
||||
lv_color_t *color_p)
|
||||
{
|
||||
UNUSED(disp_drv);
|
||||
|
||||
lcd_area.row_start = area->y1;
|
||||
lcd_area.row_end = area->y2;
|
||||
lcd_area.col_start = area->x1;
|
||||
lcd_area.col_end = area->x2;
|
||||
|
||||
lcd_area.data = (uint8_t *)color_p;
|
||||
|
||||
sem_post(&flush_sem);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void lcddev_sync_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area,
|
||||
lv_color_t *color_p)
|
||||
{
|
||||
int ret;
|
||||
struct lcddev_area_s lcd_area;
|
||||
|
||||
lcd_area.row_start = area->y1;
|
||||
lcd_area.row_end = area->y2;
|
||||
lcd_area.col_start = area->x1;
|
||||
lcd_area.col_end = area->x2;
|
||||
|
||||
lcd_area.data = (uint8_t *)color_p;
|
||||
|
||||
ret = ioctl(state.fd, LCDDEVIO_PUTAREA,
|
||||
(unsigned long)((uintptr_t)&lcd_area));
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
||||
gerr("ioctl(LCDDEVIO_PUTAREA) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Tell the flushing is ready */
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lcddev_write
|
||||
*
|
||||
* Description:
|
||||
* Write the buffer to LCD interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
|
||||
static pthread_addr_t lcddev_write(pthread_addr_t addr)
|
||||
{
|
||||
int ret = OK;
|
||||
int errcode;
|
||||
|
||||
while (ret == OK)
|
||||
{
|
||||
sem_wait(&flush_sem);
|
||||
ret = ioctl(state.fd, LCDDEVIO_PUTAREA, (unsigned long)&lcd_area);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = errno;
|
||||
}
|
||||
|
||||
sem_post(&wait_sem);
|
||||
}
|
||||
|
||||
if (ret != OK)
|
||||
{
|
||||
gerr("ioctl(LCDDEVIO_PUTAREA) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lcddev_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize LCD device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lv_drvr -- LVGL driver interface
|
||||
*
|
||||
* Returned Value:
|
||||
* EXIT_SUCCESS on success; EXIT_FAILURE on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lcddev_init(lv_disp_drv_t *lv_drvr)
|
||||
{
|
||||
FAR const char *lcddev = LCDDEV_PATH;
|
||||
int ret;
|
||||
|
||||
/* Open the framebuffer driver */
|
||||
|
||||
state.fd = open(lcddev, 0);
|
||||
if (state.fd < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
gerr("Failed to open %s: %d\n", state.fd, errcode);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Get the characteristics of the framebuffer */
|
||||
|
||||
ret = ioctl(state.fd, LCDDEVIO_GETVIDEOINFO,
|
||||
(unsigned long)((uintptr_t)&state.vinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
||||
gerr("ioctl(LCDDEVIO_GETVIDEOINFO) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ginfo("VideoInfo:\n\tfmt: %u\n\txres: %u\n\tyres: %u\n\tnplanes: %u\n",
|
||||
state.vinfo.fmt, state.vinfo.xres, state.vinfo.yres,
|
||||
state.vinfo.nplanes);
|
||||
|
||||
ret = ioctl(state.fd, LCDDEVIO_GETPLANEINFO,
|
||||
(unsigned long)((uintptr_t)&state.pinfo));
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
gerr("ioctl(LCDDEVIO_GETPLANEINFO) failed: %d\n", errcode);
|
||||
close(state.fd);
|
||||
state.fd = -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ginfo("PlaneInfo (plane 0):\n\tbpp: %u\n", state.pinfo.bpp);
|
||||
|
||||
if (state.pinfo.bpp != CONFIG_LV_COLOR_DEPTH)
|
||||
{
|
||||
/* For the LCD driver we do not have a great way to translate this
|
||||
* so fail to initialize.
|
||||
*/
|
||||
|
||||
gerr("Display bpp (%u) did not match CONFIG_LV_COLOR_DEPTH (%u)\n",
|
||||
state.pinfo.bpp, CONFIG_LV_COLOR_DEPTH);
|
||||
}
|
||||
|
||||
lv_drvr->hor_res = state.vinfo.xres;
|
||||
lv_drvr->ver_res = state.vinfo.yres;
|
||||
#ifndef CONFIG_EXAMPLES_LVGLDEMO_ASYNC_FLUSH
|
||||
lv_drvr->flush_cb = lcddev_sync_flush;
|
||||
#else
|
||||
lv_drvr->flush_cb = lcddev_async_flush;
|
||||
lv_drvr->wait_cb = lcddev_wait;
|
||||
|
||||
/* Initialize the mutexes for buffer flushing synchronization */
|
||||
|
||||
sem_init(&flush_sem, 0, 0);
|
||||
sem_init(&wait_sem, 0, 0);
|
||||
|
||||
/* Initialize the buffer flushing thread */
|
||||
|
||||
pthread_create(&lcd_write_thread, NULL, lcddev_write, NULL);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/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_EXAMPLES_LVGLDEMO_LCDDEV_H
|
||||
#define __APPS_EXAMPLES_LVGLDEMO_LCDDEV_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int lcddev_init(lv_disp_drv_t *lv_drvr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_EXAMPLES_LVGLDEMO_LCDDEV_H */
|
||||
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/lv_ex_conf.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H
|
||||
#define __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Enable printf-ing data in demoes and examples */
|
||||
|
||||
#define LV_EX_PRINTF 1
|
||||
|
||||
/* Add PC keyboard support to some examples
|
||||
* (`lv_drivers` repository is required)
|
||||
*/
|
||||
|
||||
#define LV_EX_KEYBOARD 0
|
||||
|
||||
/* Add 'encoder' (mouse wheel) support to some examples
|
||||
* (`lv_drivers` repository is required)
|
||||
*/
|
||||
|
||||
#define LV_EX_MOUSEWHEEL 0
|
||||
|
||||
/* Show some widget */
|
||||
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW CONFIG_EXAMPLES_LVGLDEMO_WIDGETS_SLIDESHOW
|
||||
#else
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Printer demo, optimized for 800x480 */
|
||||
|
||||
#define LV_USE_DEMO_PRINTER 1
|
||||
|
||||
/* Demonstrate the usage of encoder and keyboard */
|
||||
|
||||
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1
|
||||
|
||||
/* Benchmark your system */
|
||||
|
||||
#define LV_USE_DEMO_BENCHMARK 1
|
||||
|
||||
/* Stress test for LVGL */
|
||||
|
||||
#define LV_USE_DEMO_STRESS 1
|
||||
|
||||
#endif /* __APPS_EXAMPLES_LVGLDEMO_LV_EX_CONF_H */
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/lvgldemo.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
#include "fbdev.h"
|
||||
#include "lcddev.h"
|
||||
|
||||
#ifdef CONFIG_INPUT
|
||||
#include "tp.h"
|
||||
#include "tp_cal.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* 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).
|
||||
* via a call to boardctl() if the interface is enabled
|
||||
* (CONFIG_LIB_BOARDCTL=y).
|
||||
* If this task is running as an NSH built-in application, then that
|
||||
* initialization has probably already been performed otherwise we do it
|
||||
* here.
|
||||
*/
|
||||
|
||||
#undef NEED_BOARDINIT
|
||||
|
||||
#if defined(CONFIG_LIB_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
|
||||
# define NEED_BOARDINIT 1
|
||||
#endif
|
||||
|
||||
#define DISPLAY_BUFFER_SIZE (CONFIG_LV_HOR_RES * \
|
||||
CONFIG_EXAMPLES_LVGLDEMO_BUFF_SIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void lv_demo_benchmark(void);
|
||||
void lv_demo_printer(void);
|
||||
void lv_demo_stress(void);
|
||||
void lv_demo_widgets(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: monitor_cb
|
||||
*
|
||||
* Description:
|
||||
* Monitoring callback from lvgl every time the screen is flushed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void monitor_cb(lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px)
|
||||
{
|
||||
ginfo("%" PRIu32 " px refreshed in %" PRIu32 " ms\n", px, time);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static lv_color_t buffer1[DISPLAY_BUFFER_SIZE];
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_DOUBLE_BUFFERING
|
||||
static lv_color_t buffer2[DISPLAY_BUFFER_SIZE];
|
||||
#else
|
||||
# define buffer2 NULL
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: main or lvgldemo_main
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input Parameters:
|
||||
* Standard argc and argv
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a positive, non-zero value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_buf_t disp_buf;
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
lv_point_t p[4];
|
||||
|
||||
/* top left */
|
||||
|
||||
p[0].x = 0;
|
||||
p[0].y = 0;
|
||||
|
||||
/* top right */
|
||||
|
||||
p[1].x = LV_HOR_RES;
|
||||
p[1].y = 0;
|
||||
|
||||
/* bottom left */
|
||||
|
||||
p[2].x = 0;
|
||||
p[2].y = LV_VER_RES;
|
||||
|
||||
/* bottom right */
|
||||
|
||||
p[3].x = LV_HOR_RES;
|
||||
p[3].y = LV_VER_RES;
|
||||
#endif
|
||||
|
||||
#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();
|
||||
|
||||
/* Basic LVGL display driver initialization */
|
||||
|
||||
lv_disp_buf_init(&disp_buf, buffer1, buffer2, DISPLAY_BUFFER_SIZE);
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.buffer = &disp_buf;
|
||||
disp_drv.monitor_cb = monitor_cb;
|
||||
|
||||
/* Display interface initialization */
|
||||
|
||||
if (fbdev_init(&disp_drv) != EXIT_SUCCESS)
|
||||
{
|
||||
/* Failed to use framebuffer falling back to lcd driver */
|
||||
|
||||
if (lcddev_init(&disp_drv) != EXIT_SUCCESS)
|
||||
{
|
||||
/* No possible drivers left, fail */
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
#ifdef CONFIG_INPUT
|
||||
/* Touchpad Initialization */
|
||||
|
||||
tp_init();
|
||||
lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
|
||||
/* This function will be called periodically (by the library) to get the
|
||||
* mouse position and state.
|
||||
*/
|
||||
|
||||
indev_drv.read_cb = tp_read;
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_LVGLDEMO_BENCHMARK)
|
||||
lv_demo_benchmark();
|
||||
#elif defined(CONFIG_EXAMPLES_LVGLDEMO_PRINTER)
|
||||
lv_demo_printer();
|
||||
#elif defined(CONFIG_EXAMPLES_LVGLDEMO_STRESS)
|
||||
lv_demo_stress();
|
||||
#elif defined(CONFIG_EXAMPLES_LVGLDEMO_WIDGETS)
|
||||
lv_demo_widgets();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INPUT
|
||||
/* Start TP calibration */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
tp_cal_create();
|
||||
#else
|
||||
tp_set_cal_values(p, p + 1, p + 2, p + 3);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Handle LVGL tasks */
|
||||
|
||||
while (1)
|
||||
{
|
||||
lv_task_handler();
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/lvgldemo/tp.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LGVLDEMO_MOUSE
|
||||
# include <nuttx/input/mouse.h>
|
||||
#endif
|
||||
|
||||
#include <nuttx/input/touchscreen.h>
|
||||
|
||||
#include "tp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static int fd;
|
||||
static bool calibrated = false;
|
||||
static int x_range;
|
||||
static int y_range;
|
||||
static int x_offset;
|
||||
static int y_offset;
|
||||
static bool xy_inv;
|
||||
static bool x_inv;
|
||||
static bool y_inv;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize The Touch pad
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a positive error code on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int tp_init(void)
|
||||
{
|
||||
int errval = 0;
|
||||
|
||||
/* Open the touchscreen device for reading */
|
||||
|
||||
printf("tp_init: Opening %s\n", CONFIG_EXAMPLES_LGVLDEMO_DEVPATH);
|
||||
fd = open(CONFIG_EXAMPLES_LGVLDEMO_DEVPATH, O_RDONLY | O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("tp_init: open %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_LGVLDEMO_DEVPATH, errno);
|
||||
errval = 2;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
printf("Terminating!\n");
|
||||
fflush(stdout);
|
||||
return errval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_read
|
||||
*
|
||||
* Description:
|
||||
* Read a TP data and store in 'data' argument
|
||||
*
|
||||
* Input Parameters:
|
||||
* indev_drv - Input device handler
|
||||
* data - Store the x, y and state information here
|
||||
*
|
||||
* Returned Value:
|
||||
* false: no more data to read; true: there are more data to read.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool tp_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
|
||||
{
|
||||
struct touch_sample_s sample;
|
||||
int nbytes;
|
||||
static int last_x = 0;
|
||||
static int last_y = 0;
|
||||
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
||||
|
||||
/* Be sure at least the previous state is set */
|
||||
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = last_state;
|
||||
|
||||
/* Read one sample */
|
||||
|
||||
nbytes = read(fd, &sample, sizeof(struct touch_sample_s));
|
||||
|
||||
/* Handle unexpected return values */
|
||||
|
||||
if (nbytes < 0 || nbytes != sizeof(struct touch_sample_s))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sample.point[0].flags & TOUCH_DOWN
|
||||
|| sample.point[0].flags & TOUCH_MOVE)
|
||||
{
|
||||
if (calibrated)
|
||||
{
|
||||
if (xy_inv)
|
||||
{
|
||||
last_x = sample.point[0].y;
|
||||
last_y = sample.point[0].x;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_x = sample.point[0].x;
|
||||
last_y = sample.point[0].y;
|
||||
}
|
||||
|
||||
/* Remove offset */
|
||||
|
||||
last_x -= x_offset;
|
||||
last_y -= y_offset;
|
||||
|
||||
last_x = (int)((int)last_x * LV_HOR_RES) / x_range;
|
||||
last_y = (int)((int)last_y * LV_VER_RES) / y_range;
|
||||
|
||||
if (x_inv)
|
||||
{
|
||||
last_x = LV_HOR_RES - last_x;
|
||||
}
|
||||
|
||||
if (y_inv)
|
||||
{
|
||||
last_y = LV_VER_RES - last_y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last_x = sample.point[0].x;
|
||||
last_y = sample.point[0].y;
|
||||
}
|
||||
|
||||
last_state = LV_INDEV_STATE_PR;
|
||||
}
|
||||
else if (sample.point[0].flags & TOUCH_UP)
|
||||
{
|
||||
last_state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
else if (sample.point[0].flags & TOUCH_UP)
|
||||
{
|
||||
last_state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/* Update touchpad data */
|
||||
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = last_state;
|
||||
|
||||
fflush(stdout);
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_read
|
||||
*
|
||||
* Description:
|
||||
* Set calibration data
|
||||
*
|
||||
* Input Parameters:
|
||||
* ul - Upper left hand corner TP value
|
||||
* ur - Upper right hand corner TP value
|
||||
* lr - Lower right hand corner TP value
|
||||
* ll - Lower left hand corner TP value
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur,
|
||||
FAR lv_point_t *lr, FAR lv_point_t *ll)
|
||||
{
|
||||
/* Is x/y inverted? */
|
||||
|
||||
if (abs(ul->x - ur->x) < LV_HOR_RES / 2)
|
||||
{
|
||||
/* No real change in x horizontally */
|
||||
|
||||
xy_inv = true;
|
||||
}
|
||||
|
||||
if (xy_inv)
|
||||
{
|
||||
/* Is x inverted */
|
||||
|
||||
if (ur->y < ul->y)
|
||||
{
|
||||
x_inv = true;
|
||||
}
|
||||
|
||||
/* Is y inverted */
|
||||
|
||||
if (ll->x < ul->x)
|
||||
{
|
||||
y_inv = true;
|
||||
}
|
||||
|
||||
x_range = abs(ul->y - ur->y);
|
||||
y_range = abs(ul->x - ll->x);
|
||||
x_offset = x_inv ? ur->y : ul->y;
|
||||
y_offset = y_inv ? ll->x : ul->x;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Is x inverted */
|
||||
|
||||
if (ur->x < ul->x)
|
||||
{
|
||||
x_inv = true;
|
||||
}
|
||||
|
||||
/* Is y inverted */
|
||||
|
||||
if (ll->y < ul->y)
|
||||
{
|
||||
y_inv = true;
|
||||
}
|
||||
|
||||
x_range = abs(ul->x - ur->x);
|
||||
y_range = abs(ul->y - ll->y);
|
||||
x_offset = x_inv ? ur->x : ul->x;
|
||||
y_offset = y_inv ? ll->y : ul->y;
|
||||
}
|
||||
|
||||
calibrated = true;
|
||||
|
||||
printf("tp_cal result\n");
|
||||
printf("offset x:%d, y:%d\n", x_offset, y_offset);
|
||||
printf("range x:%d, y:%d\n", x_range, y_range);
|
||||
printf("invert x/y:%d, x:%d, y:%d\n\n", xy_inv, x_inv, y_inv);
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/****************************************************************************
|
||||
* examples/touchscreen/tc.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_LVGLDEMO_TP_H
|
||||
#define __APPS_EXAMPLES_LVGLDEMO_TP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* CONFIG_EXAMPLES_LGVLDEMO_MINOR - The minor device number. Minor=N
|
||||
* corresponds to touchscreen device /dev/input0. Note this value must
|
||||
* with CONFIG_EXAMPLES_LGVLDEMO_DEVPATH. Default 0.
|
||||
* CONFIG_EXAMPLES_LGVLDEMO_DEVPATH - The path to the touchscreen
|
||||
* device. This must be consistent with CONFIG_EXAMPLES_LGVLDEMO_MINOR.
|
||||
* Default: "/dev/input0"
|
||||
* CONFIG_EXAMPLES_LGVLDEMO_MOUSE - The touchscreen test can also be
|
||||
* configured to work with a mouse driver by setting this option.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_INPUT
|
||||
# error "Input device support is not enabled (CONFIG_INPUT)"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_LGVLDEMO_MINOR
|
||||
# undef CONFIG_EXAMPLES_LGVLDEMO_DEVPATH
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_MINOR 0
|
||||
# ifdef CONFIG_EXAMPLES_LGVLDEMO_MOUSE
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_DEVPATH "/dev/mouse0"
|
||||
# else
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_DEVPATH "/dev/input0"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_LGVLDEMO_DEVPATH
|
||||
# undef CONFIG_EXAMPLES_LGVLDEMO_MINOR
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_MINOR 0
|
||||
# ifdef CONFIG_EXAMPLES_LGVLDEMO_MOUSE
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_DEVPATH "/dev/mouse0"
|
||||
# else
|
||||
# define CONFIG_EXAMPLES_LGVLDEMO_DEVPATH "/dev/input0"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize The Touch pad
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a positive error code on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int tp_init(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_read
|
||||
*
|
||||
* Description:
|
||||
* Read a TP data and store in 'data' argument
|
||||
*
|
||||
* Input Parameters:
|
||||
* indev_drv - Input device handler
|
||||
* data - Store the x, y and state information here
|
||||
*
|
||||
* Returned Value:
|
||||
* false: no more data to read; true: there are more data to read.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool tp_read(FAR struct _lv_indev_drv_t *indev_drv,
|
||||
FAR lv_indev_data_t *data);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_read
|
||||
*
|
||||
* Description:
|
||||
* Set calibration data
|
||||
*
|
||||
* Input Parameters:
|
||||
* ul - Upper left hand corner TP value
|
||||
* ur - Upper right hand corner TP value
|
||||
* lr - Lower right hand corner TP value
|
||||
* ll - Lower left hand corner TP value
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur,
|
||||
FAR lv_point_t *lr, FAR lv_point_t *ll);
|
||||
|
||||
#endif /* __APPS_EXAMPLES_LVGLDEMO_TP_H */
|
||||
@@ -0,0 +1,347 @@
|
||||
/****************************************************************************
|
||||
* examples/touchscreen/tp_cal.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "tp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CIRCLE_SIZE 20
|
||||
#define TP_MAX_VALUE 5000
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
enum tp_cal_state_e
|
||||
{
|
||||
TP_CAL_STATE_INIT,
|
||||
TP_CAL_STATE_WAIT_TOP_LEFT,
|
||||
TP_CAL_STATE_WAIT_TOP_RIGHT,
|
||||
TP_CAL_STATE_WAIT_BOTTOM_RIGHT,
|
||||
TP_CAL_STATE_WAIT_BOTTOM_LEFT,
|
||||
TP_CAL_STATE_WAIT_LEAVE,
|
||||
TP_CAL_STATE_READY,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static enum tp_cal_state_e state;
|
||||
static lv_point_t p[4];
|
||||
static lv_obj_t *prev_scr;
|
||||
static lv_obj_t *big_btn;
|
||||
static lv_obj_t *label_main;
|
||||
static lv_obj_t *circ_area;
|
||||
static lv_theme_t *prev_theme;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: btn_click_action
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Input Parameters:
|
||||
* scr
|
||||
* event
|
||||
*
|
||||
* Returned Value:
|
||||
* ?
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event)
|
||||
{
|
||||
if (event == LV_EVENT_CLICKED)
|
||||
{
|
||||
if (state == TP_CAL_STATE_WAIT_TOP_LEFT)
|
||||
{
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
char buf[64];
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
#endif
|
||||
|
||||
lv_indev_get_point(indev, &p[0]);
|
||||
|
||||
sprintf(buf, "x: %d\ny: %d", p[0].x, p[0].y);
|
||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_coord, buf);
|
||||
|
||||
lv_label_set_text(label_main, "Click the circle in\n"
|
||||
"upper right-hand corner");
|
||||
|
||||
lv_obj_set_pos(label_main,
|
||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, circ_area);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_set_time(&a, 500);
|
||||
lv_anim_set_values(&a, 0, LV_HOR_RES - CIRCLE_SIZE);
|
||||
lv_anim_set_delay(&a, 200);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_pos(circ_area, LV_HOR_RES - CIRCLE_SIZE, 0);
|
||||
#endif
|
||||
|
||||
state = TP_CAL_STATE_WAIT_TOP_RIGHT;
|
||||
}
|
||||
else if (state == TP_CAL_STATE_WAIT_TOP_RIGHT)
|
||||
{
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
char buf[64];
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
#endif
|
||||
|
||||
lv_indev_get_point(indev, &p[1]);
|
||||
|
||||
sprintf(buf, "x: %d\ny: %d", p[1].x, p[1].y);
|
||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_coord, buf);
|
||||
lv_obj_set_pos(label_coord,
|
||||
LV_HOR_RES - lv_obj_get_width(label_coord),
|
||||
0);
|
||||
|
||||
lv_label_set_text(label_main, "Click the circle in\n"
|
||||
"lower right-hand corner");
|
||||
|
||||
lv_obj_set_pos(label_main,
|
||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, circ_area);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_time(&a, 500);
|
||||
lv_anim_set_values(&a, 0, LV_VER_RES - CIRCLE_SIZE);
|
||||
lv_anim_set_delay(&a, 200);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_pos(circ_area,
|
||||
LV_HOR_RES - CIRCLE_SIZE, LV_VER_RES - CIRCLE_SIZE);
|
||||
#endif
|
||||
|
||||
state = TP_CAL_STATE_WAIT_BOTTOM_RIGHT;
|
||||
}
|
||||
else if (state == TP_CAL_STATE_WAIT_BOTTOM_RIGHT)
|
||||
{
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
char buf[64];
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
#endif
|
||||
lv_indev_get_point(indev, &p[2]);
|
||||
|
||||
sprintf(buf, "x: %d\ny: %d", p[2].x, p[2].y);
|
||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_coord, buf);
|
||||
lv_obj_set_pos(label_coord,
|
||||
LV_HOR_RES - lv_obj_get_width(label_coord),
|
||||
LV_VER_RES - lv_obj_get_height(label_coord));
|
||||
|
||||
lv_label_set_text(label_main, "Click the circle in\n"
|
||||
"lower left-hand corner");
|
||||
|
||||
lv_obj_set_pos(label_main,
|
||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, circ_area);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_set_time(&a, 500);
|
||||
lv_anim_set_values(&a, LV_HOR_RES - CIRCLE_SIZE, 0);
|
||||
lv_anim_set_delay(&a, 200);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_pos(circ_area, 0, LV_VER_RES - CIRCLE_SIZE);
|
||||
#endif
|
||||
|
||||
state = TP_CAL_STATE_WAIT_BOTTOM_LEFT;
|
||||
}
|
||||
else if (state == TP_CAL_STATE_WAIT_BOTTOM_LEFT)
|
||||
{
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
char buf[64];
|
||||
|
||||
lv_indev_get_point(indev, &p[3]);
|
||||
|
||||
lv_label_set_text(label_main, "Click the screen\n"
|
||||
"to leave calibration");
|
||||
|
||||
lv_obj_set_pos(label_main,
|
||||
(LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||
|
||||
sprintf(buf, "x: %d\ny: %d", p[3].x, p[3].y);
|
||||
lv_obj_t *label_coord = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_coord, buf);
|
||||
lv_obj_set_pos(label_coord, 0,
|
||||
LV_VER_RES - lv_obj_get_height(label_coord));
|
||||
|
||||
lv_obj_del(circ_area);
|
||||
|
||||
state = TP_CAL_STATE_WAIT_LEAVE;
|
||||
}
|
||||
else if (state == TP_CAL_STATE_WAIT_LEAVE)
|
||||
{
|
||||
lv_theme_set_act(prev_theme);
|
||||
lv_scr_load(prev_scr);
|
||||
tp_set_cal_values(&p[0], &p[1], &p[2], &p[3]);
|
||||
state = TP_CAL_STATE_READY;
|
||||
}
|
||||
else if (state == TP_CAL_STATE_READY)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_cal_create
|
||||
*
|
||||
* Description:
|
||||
* Create a touchpad calibration screen
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void tp_cal_create(void)
|
||||
{
|
||||
static lv_style_t style_circ;
|
||||
static lv_style_t style_big_btn;
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_t a;
|
||||
#endif
|
||||
|
||||
state = TP_CAL_STATE_INIT;
|
||||
|
||||
prev_scr = lv_scr_act();
|
||||
|
||||
lv_theme_t *theme = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY,
|
||||
LV_THEME_DEFAULT_COLOR_SECONDARY,
|
||||
LV_THEME_DEFAULT_FLAG,
|
||||
LV_THEME_DEFAULT_FONT_SMALL,
|
||||
LV_THEME_DEFAULT_FONT_NORMAL,
|
||||
LV_THEME_DEFAULT_FONT_SUBTITLE,
|
||||
LV_THEME_DEFAULT_FONT_TITLE);
|
||||
|
||||
prev_theme = lv_theme_get_act();
|
||||
lv_theme_set_act(theme);
|
||||
|
||||
lv_obj_t *scr = lv_obj_create(NULL, NULL);
|
||||
lv_obj_set_size(scr, TP_MAX_VALUE, TP_MAX_VALUE);
|
||||
lv_scr_load(scr);
|
||||
|
||||
/* Create a big transparent button screen to receive clicks */
|
||||
|
||||
big_btn = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(big_btn, TP_MAX_VALUE, TP_MAX_VALUE);
|
||||
|
||||
lv_style_init(&style_big_btn);
|
||||
|
||||
lv_style_set_bg_opa(&style_big_btn, LV_STATE_DEFAULT | LV_STATE_PRESSED,
|
||||
LV_OPA_TRANSP);
|
||||
lv_obj_add_style(big_btn, LV_BTN_PART_MAIN, &style_big_btn);
|
||||
|
||||
lv_obj_set_event_cb(big_btn, btn_click_action);
|
||||
lv_btn_set_layout(big_btn, LV_LAYOUT_OFF);
|
||||
|
||||
label_main = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_label_set_text(label_main, "Click the circle in\n"
|
||||
"upper left-hand corner");
|
||||
lv_label_set_align(label_main, LV_LABEL_ALIGN_CENTER);
|
||||
|
||||
lv_obj_set_pos(label_main, (LV_HOR_RES - lv_obj_get_width(label_main)) / 2,
|
||||
(LV_VER_RES - lv_obj_get_height(label_main)) / 2);
|
||||
|
||||
lv_style_init(&style_circ);
|
||||
lv_style_set_radius(&style_circ, LV_STATE_DEFAULT,
|
||||
LV_RADIUS_CIRCLE);
|
||||
lv_style_set_bg_color(&style_circ, LV_STATE_DEFAULT,
|
||||
LV_COLOR_BLUE);
|
||||
circ_area = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(circ_area, CIRCLE_SIZE, CIRCLE_SIZE);
|
||||
lv_obj_add_style(circ_area, LV_OBJ_PART_MAIN, &style_circ);
|
||||
lv_obj_set_click(circ_area, false);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, circ_area);
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
|
||||
lv_anim_set_time(&a, 200);
|
||||
lv_anim_set_values(&a, LV_HOR_RES / 2, 0);
|
||||
lv_anim_set_delay(&a, 200);
|
||||
lv_anim_start(&a);
|
||||
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||
lv_anim_set_values(&a, LV_VER_RES / 2, 0);
|
||||
lv_anim_start(&a);
|
||||
#endif
|
||||
state = TP_CAL_STATE_WAIT_TOP_LEFT;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* examples/touchscreen/tp_cal.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gábor Kiss-Vámosi <kisvegabor@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H
|
||||
#define __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tp_cal_create
|
||||
*
|
||||
* Description:
|
||||
* Create a touchpad calibration screen
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void tp_cal_create(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*__APPS_EXAMPLES_LVGLDEMO_TP_CAL_H*/
|
||||
Reference in New Issue
Block a user