examples/lvgldemo: Change to latest official release
This commit is contained in:
parent
7a85bc75dc
commit
32a2207e86
2
examples/lvgldemo/.gitignore
vendored
Normal file
2
examples/lvgldemo/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*.zip
|
||||
/lv_examples
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
|
||||
menuconfig EXAMPLES_LVGLDEMO
|
||||
tristate "Littlev Graphics Library Demo"
|
||||
tristate "LVGL Demo"
|
||||
default n
|
||||
---help---
|
||||
Enable build the Littlev Graphics Library Demo programs
|
||||
Enable build the Light and Versatile Graphics Library Demo programs
|
||||
|
||||
if EXAMPLES_LVGLDEMO
|
||||
|
||||
@ -18,82 +18,30 @@ config EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
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
|
||||
|
||||
choice
|
||||
prompt "Select a demo application"
|
||||
default EXAMPLES_LVGLDEMO_SIMPLE
|
||||
default EXAMPLES_LVGLDEMO_WIDGETS
|
||||
|
||||
config EXAMPLES_LVGLDEMO_SIMPLE
|
||||
bool "Simple"
|
||||
config EXAMPLES_LVGLDEMO_BENCHMARK
|
||||
bool "Benchmark"
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1
|
||||
bool "Single Theme"
|
||||
config EXAMPLES_LVGLDEMO_PRINTER
|
||||
bool "Printer"
|
||||
---help---
|
||||
Create a test screen with a lot objects and apply
|
||||
the given theme on them
|
||||
This demo is optimized for 800 * 480 resolution
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_2
|
||||
bool "Multiple Themes"
|
||||
select LV_THEME_LIVE_UPDATE
|
||||
---help---
|
||||
Switch themes on the fly to demonstrate each different
|
||||
themes. Configure multiple themes in the littlevgl
|
||||
settings to use.
|
||||
config EXAMPLES_LVGLDEMO_STRESS
|
||||
bool "Stress"
|
||||
|
||||
config EXAMPLES_LVGLDEMO_WIDGETS
|
||||
bool "Widgets"
|
||||
|
||||
endchoice
|
||||
|
||||
config EXAMPLES_LVGLDEMO_WALLPAPER
|
||||
bool "Use wallpaper"
|
||||
depends on EXAMPLES_LVGLDEMO_SIMPLE
|
||||
default y
|
||||
|
||||
config EXAMPLES_LVGLDEMO_SLIDE_SHOW
|
||||
bool "Use slide"
|
||||
depends on EXAMPLES_LVGLDEMO_SIMPLE
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Selected Theme"
|
||||
depends on EXAMPLES_LVGLDEMO_THEME_1
|
||||
default EXAMPLES_LVGLDEMO_THEME_1_DEFAULT
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_DEFAULT
|
||||
bool "Default Theme"
|
||||
select USE_LV_THEME_DEFAULT
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_ALIEN
|
||||
bool "Alien"
|
||||
select USE_LV_THEME_ALIEN
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_NIGHT
|
||||
bool "Night"
|
||||
select USE_LV_THEME_NIGHT
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_MONO
|
||||
bool "Mono"
|
||||
select USE_LV_THEME_MONO
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_MATERIAL
|
||||
bool "Material"
|
||||
select USE_LV_THEME_MATERIAL
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_ZEN
|
||||
bool "Zen"
|
||||
select USE_LV_THEME_ZEN
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_NEMO
|
||||
bool "Nemo"
|
||||
select USE_LV_THEME_NEMO
|
||||
|
||||
endchoice
|
||||
|
||||
config EXAMPLES_LVGLDEMO_THEME_1_HUE
|
||||
int "Theme hue"
|
||||
range 0 360
|
||||
depends on EXAMPLES_LVGLDEMO_THEME_1
|
||||
default 30
|
||||
---help---
|
||||
Choose a hue color from the HSV color space
|
||||
|
||||
config EXAMPLES_LVGLDEMO_PRIORITY
|
||||
int "lvgl task priority"
|
||||
default 100
|
||||
|
@ -37,6 +37,15 @@ include $(TOPDIR)/Make.defs
|
||||
|
||||
# LittleVGL demo built-in application info
|
||||
|
||||
CONFIG_LV_EXAMPLES_URL ?= https://github.com/lvgl/lv_examples/archive
|
||||
|
||||
LVGL_EXAMPLES_VERSION ?= 7.0.2
|
||||
LVGL_EXAMPLES_TARBALL = v$(LVGL_EXAMPLES_VERSION).zip
|
||||
|
||||
WGET ?= wget
|
||||
LVGL_EXAMPLES_UNPACKNAME = lv_examples
|
||||
UNPACK ?= unzip -o
|
||||
|
||||
PROGNAME = lvgldemo
|
||||
PRIORITY = $(CONFIG_EXAMPLES_LVGLDEMO_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_LVGLDEMO_STACKSIZE)
|
||||
@ -46,11 +55,60 @@ MODULE = $(CONFIG_EXAMPLES_LVGLDEMO)
|
||||
|
||||
CSRCS += fbdev.c tp.c tp_cal.c
|
||||
|
||||
# static common assets used in mutiple example
|
||||
|
||||
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
|
||||
|
||||
LVGL_SRC_DIR=$(APPDIR)/graphics/lvgl/lvgl
|
||||
LVGL_DIR=$(APPDIR)/graphics/lvgl
|
||||
|
||||
CFLAGS += ${shell $(INCDIR) "$(CC)" "$(LVGL_SRC_DIR)" "$(LVGL_DIR)"}
|
||||
CXXFLAGS += ${shell $(INCDIR) "$(CC)" "$(LVGL_SRC_DIR)" "$(LVGL_DIR)"}
|
||||
|
||||
$(LVGL_EXAMPLES_TARBALL):
|
||||
@echo "Downloading: $(LVGL_EXAMPLES_TARBALL)"
|
||||
$(Q) $(WGET) $(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)
|
||||
|
||||
clean::
|
||||
$(call DELDIR, build)
|
||||
|
||||
distclean::
|
||||
$(call DELDIR, $(LVGL_EXAMPLES_UNPACKNAME))
|
||||
$(call DELFILE, $(LVGL_EXAMPLES_TARBALL))
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
68
examples/lvgldemo/lv_ex_conf.h
Normal file
68
examples/lvgldemo/lv_ex_conf.h
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 0
|
||||
#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 */
|
||||
|
@ -73,6 +73,18 @@
|
||||
# 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
|
||||
****************************************************************************/
|
||||
@ -148,7 +160,7 @@ int main(int argc, FAR char *argv[])
|
||||
pthread_t tick_thread;
|
||||
|
||||
lv_disp_buf_t disp_buf;
|
||||
static lv_color_t buf[CONFIG_LV_VDB_SIZE];
|
||||
static lv_color_t buf[DISPLAY_BUFFER_SIZE];
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
lv_point_t p[4];
|
||||
@ -196,7 +208,7 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Basic LittlevGL display driver initialization */
|
||||
|
||||
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
|
||||
lv_disp_buf_init(&disp_buf, buf, NULL, DISPLAY_BUFFER_SIZE);
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.flush_cb = fbdev_flush;
|
||||
disp_drv.buffer = &disp_buf;
|
||||
@ -220,6 +232,16 @@ int main(int argc, FAR char *argv[])
|
||||
indev_drv.read_cb = tp_read;
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
|
||||
#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
|
||||
|
||||
/* Start TP calibration */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_LVGLDEMO_CALIBRATE
|
||||
@ -227,7 +249,7 @@ int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
tp_set_cal_values(p, p + 1, p + 2, p + 3);
|
||||
#endif
|
||||
/* Handle LittlevGL tasks */
|
||||
/* Handle LVGL tasks */
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -76,10 +76,11 @@ static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event);
|
||||
|
||||
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_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
|
||||
@ -166,15 +167,10 @@ static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event)
|
||||
#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,
|
||||
LV_HOR_RES - CIRCLE_SIZE);
|
||||
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_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,
|
||||
@ -214,11 +210,6 @@ static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event)
|
||||
lv_anim_set_values(&a, LV_HOR_RES - CIRCLE_SIZE, 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 - CIRCLE_SIZE,
|
||||
LV_VER_RES - CIRCLE_SIZE);
|
||||
lv_anim_start(&a);
|
||||
#else
|
||||
lv_obj_set_pos(circ_area, 0, LV_VER_RES - CIRCLE_SIZE);
|
||||
#endif
|
||||
@ -251,6 +242,7 @@ static void btn_click_action(FAR lv_obj_t *scr, lv_event_t event)
|
||||
}
|
||||
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;
|
||||
@ -291,6 +283,17 @@ void tp_cal_create(void)
|
||||
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user