From c18dae2c2e5cdac6443b4ec0f0ba3f5e6d4f34f6 Mon Sep 17 00:00:00 2001 From: Wayne Lin Date: Tue, 21 Dec 2021 19:06:02 +0800 Subject: Migrate lv porting folder. --- .../libraries/nu_packages/ILI9341/lcd_ili9341.c | 4 +- bsp/nuvoton/nk-980iot/applications/lvgl/SConscript | 17 +-- bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h | 30 +++++ bsp/nuvoton/nk-980iot/applications/lvgl/lv_demo.c | 49 ++++++++ .../nk-980iot/applications/lvgl/lv_port_disp.c | 106 +++++++++++++++++ .../nk-980iot/applications/lvgl/lv_port_disp.h | 23 ++++ .../nk-980iot/applications/lvgl/lv_port_indev.c | 57 +++++++++ .../nk-980iot/applications/lvgl/lv_port_indev.h | 28 +++++ .../nk-980iot/applications/lvgl/port/SConscript | 10 -- .../nk-980iot/applications/lvgl/port/lv_conf.h | 31 ----- .../nk-980iot/applications/lvgl/port/lv_demo.c | 49 -------- .../applications/lvgl/port/lv_port_disp.c | 106 ----------------- .../applications/lvgl/port/lv_port_disp.h | 23 ---- .../applications/lvgl/port/lv_port_indev.c | 57 --------- .../applications/lvgl/port/lv_port_indev.h | 28 ----- bsp/nuvoton/nk-n9h30/applications/lvgl/SConscript | 17 +-- bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h | 31 +++++ bsp/nuvoton/nk-n9h30/applications/lvgl/lv_demo.c | 49 ++++++++ .../nk-n9h30/applications/lvgl/lv_port_disp.c | 131 +++++++++++++++++++++ .../nk-n9h30/applications/lvgl/lv_port_disp.h | 23 ++++ .../nk-n9h30/applications/lvgl/lv_port_indev.c | 57 +++++++++ .../nk-n9h30/applications/lvgl/lv_port_indev.h | 28 +++++ .../nk-n9h30/applications/lvgl/port/SConscript | 10 -- .../nk-n9h30/applications/lvgl/port/lv_conf.h | 32 ----- .../nk-n9h30/applications/lvgl/port/lv_demo.c | 49 -------- .../nk-n9h30/applications/lvgl/port/lv_port_disp.c | 131 --------------------- .../nk-n9h30/applications/lvgl/port/lv_port_disp.h | 23 ---- .../applications/lvgl/port/lv_port_indev.c | 57 --------- .../applications/lvgl/port/lv_port_indev.h | 28 ----- 29 files changed, 624 insertions(+), 660 deletions(-) create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_demo.c create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.c create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.h create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.c create mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.h delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/SConscript delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_conf.h delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_demo.c delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.c delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.h delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.c delete mode 100644 bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.h create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_demo.c create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.c create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.h create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.c create mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.h delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/SConscript delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_conf.h delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_demo.c delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.c delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.h delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.c delete mode 100644 bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.h diff --git a/bsp/nuvoton/libraries/nu_packages/ILI9341/lcd_ili9341.c b/bsp/nuvoton/libraries/nu_packages/ILI9341/lcd_ili9341.c index 1ea99cb886..31cb6c6d02 100644 --- a/bsp/nuvoton/libraries/nu_packages/ILI9341/lcd_ili9341.c +++ b/bsp/nuvoton/libraries/nu_packages/ILI9341/lcd_ili9341.c @@ -177,8 +177,8 @@ static rt_err_t ili9341_lcd_init(rt_device_t dev) #if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER) static void ili9341_fillrect(uint16_t *pixels, struct rt_device_rect_info *pRectInfo) { - ili9341_set_column(pRectInfo->x, pRectInfo->x + pRectInfo->width); - ili9341_set_page(pRectInfo->y, pRectInfo->y + pRectInfo->height); + ili9341_set_column(pRectInfo->x, pRectInfo->x + pRectInfo->width - 1); + ili9341_set_page(pRectInfo->y, pRectInfo->y + pRectInfo->height - 1); ili9341_send_cmd(0x2c); ili9341_send_pixels(pixels, pRectInfo->height * pRectInfo->width * 2); diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/SConscript b/bsp/nuvoton/nk-980iot/applications/lvgl/SConscript index 4cb03b1c72..18f793dbe0 100644 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/SConscript +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/SConscript @@ -1,17 +1,10 @@ -Import('RTT_ROOT') from building import * -import os +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] -objs = [] +group = DefineGroup('LVGL-port', src, depend = ['PKG_USING_LVGL'], CPPPATH = CPPPATH) -if GetDepend('PKG_USING_LVGL'): - cwd = GetCurrentDir() - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') +Return('group') diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h new file mode 100644 index 0000000000..b89513bc70 --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man First version + */ + +#ifndef LV_CONF_H +#define LV_CONF_H + + +#define LV_USE_PERF_MONITOR 1 +#define LV_COLOR_DEPTH 16 + +#define LV_HOR_RES_MAX (320) +#define LV_VER_RES_MAX (240) + + +#define LV_USE_DEMO_RTT_MUSIC 1 +#define LV_USE_DEMO_MUSIC 1 +#define LV_FONT_MONTSERRAT_12 1 +#define LV_FONT_MONTSERRAT_16 1 +#define LV_DEMO_MUSIC_AUTO_PLAY 1 +#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1 + +//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE +#endif diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_demo.c b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_demo.c new file mode 100644 index 0000000000..7ac1eab9e5 --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_demo.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-17 Meco Man First version + */ +#include +#include +#define DBG_TAG "LVGL" +#define DBG_LVL DBG_INFO +#include + +#ifndef LV_THREAD_STACK_SIZE + #define LV_THREAD_STACK_SIZE 4096 +#endif + +#ifndef LV_THREAD_PRIO + #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3) +#endif + +static void lvgl_thread(void *parameter) +{ + extern void lv_demo_music(void); + lv_demo_music(); + + while (1) + { + lv_task_handler(); + rt_thread_mdelay(1); + } +} + +static int lvgl_demo_init(void) +{ + rt_thread_t tid; + + tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10); + if (tid == RT_NULL) + { + LOG_E("Fail to create 'LVGL' thread"); + } + rt_thread_startup(tid); + + return 0; +} +INIT_APP_EXPORT(lvgl_demo_init); diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.c b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.c new file mode 100644 index 0000000000..cc72d47337 --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-17 Wayne The first version + */ +#include + +#define LOG_TAG "lvgl.disp" +#define DBG_ENABLE +#define DBG_SECTION_NAME LOG_TAG +#define DBG_LEVEL DBG_ERROR +#define DBG_COLOR +#include + +/*A static or global variable to store the buffers*/ +static lv_disp_draw_buf_t disp_buf; +static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ + +static rt_device_t lcd_device = 0; +static struct rt_device_graphic_info info; + +static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) +{ + /* Rendering */ + struct rt_device_rect_info rect; + + rect.x = area->x1; + rect.y = area->y1; + rect.width = area->x2 - area->x1 + 1; + rect.height = area->y2 - area->y1 + 1; + + if ((uint32_t)info.framebuffer != (uint32_t)color_p) + { + rect.y += info.height; + } + + rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect); + lv_disp_flush_ready(disp_drv); +} + +void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) +{ + rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t)); +} + +void lv_port_disp_init(void) +{ + rt_err_t result; + void *buf_1 = RT_NULL; + void *buf_2 = RT_NULL; + + lcd_device = rt_device_find("lcd"); + if (lcd_device == 0) + { + LOG_E("error!"); + return; + } + + /* get framebuffer address */ + result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info); + if (result != RT_EOK) + { + LOG_E("error!"); + /* get device information failed */ + return; + } + + RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 || + info.bits_per_pixel == 24 || info.bits_per_pixel == 32); + + buf_1 = (void *)info.framebuffer; + buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8); + rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2); + + /*Initialize `disp_buf` with the buffer(s).*/ + lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height); + + result = rt_device_open(lcd_device, 0); + if (result != RT_EOK) + { + LOG_E("error!"); + return; + } + + lv_disp_drv_init(&disp_drv); /*Basic initialization*/ + + /*Set the resolution of the display*/ + disp_drv.hor_res = info.width; + disp_drv.ver_res = info.height; + + /*Set a display buffer*/ + disp_drv.draw_buf = &disp_buf; + + /*Write the internal buffer (draw_buf) to the display*/ + disp_drv.flush_cb = lcd_fb_flush; + + /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ + //disp_drv.monitor_cb = lcd_perf_monitor; + + /*Finally register the driver*/ + lv_disp_drv_register(&disp_drv); +} diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.h b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.h new file mode 100644 index 0000000000..ef39eb03cd --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_disp.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + */ +#ifndef LV_PORT_DISP_H +#define LV_PORT_DISP_H + +#ifdef __cplusplus +extern "C" { +#endif + +void lv_port_disp_init(void); + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.c b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.c new file mode 100644 index 0000000000..4451ad4f84 --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + * 2021-12-17 Wayne Add input event + */ +#include +#include +#include +#include "touch.h" + +static lv_indev_state_t last_state = LV_INDEV_STATE_REL; +static rt_int16_t last_x = 0; +static rt_int16_t last_y = 0; + +static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) +{ + data->point.x = last_x; + data->point.y = last_y; + data->state = last_state; +} + +void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state) +{ + switch (state) + { + case RT_TOUCH_EVENT_UP: + last_state = LV_INDEV_STATE_RELEASED; + break; + case RT_TOUCH_EVENT_DOWN: + last_x = x; + last_y = y; + last_state = LV_INDEV_STATE_PRESSED; + break; + case RT_TOUCH_EVENT_MOVE: + last_x = x; + last_y = y; + break; + } +} + +void lv_port_indev_init(void) +{ + static lv_indev_drv_t indev_drv; + + /* Basic initialization */ + lv_indev_drv_init(&indev_drv); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = input_read; + + /* Register the driver in LVGL and save the created input device object */ + lv_indev_drv_register(&indev_drv); +} diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.h b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.h new file mode 100644 index 0000000000..dec92bccbc --- /dev/null +++ b/bsp/nuvoton/nk-980iot/applications/lvgl/lv_port_indev.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + */ +#ifndef LV_PORT_INDEV_H +#define LV_PORT_INDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +extern lv_indev_t *button_indev; + +void lv_port_indev_init(void); +void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/SConscript b/bsp/nuvoton/nk-980iot/applications/lvgl/port/SConscript deleted file mode 100644 index 0ca25f18d4..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') -CPPPATH = [cwd] - -group = DefineGroup('LVGL-port', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') - diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_conf.h b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_conf.h deleted file mode 100644 index 1ea0ae2016..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_conf.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man First version - */ - -#ifndef LV_CONF_H -#define LV_CONF_H - -//#define LV_USE_EXTERNAL_RENDERER 1 - -#define LV_USE_PERF_MONITOR 1 -#define LV_COLOR_DEPTH 16 - -#define LV_HOR_RES_MAX (320) -#define LV_VER_RES_MAX (240) - - -#define LV_USE_DEMO_RTT_MUSIC 1 -#define LV_USE_DEMO_MUSIC 1 -#define LV_FONT_MONTSERRAT_12 1 -#define LV_FONT_MONTSERRAT_16 1 -#define LV_DEMO_MUSIC_AUTO_PLAY 1 -#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1 - -//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE -#endif diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_demo.c b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_demo.c deleted file mode 100644 index 7ac1eab9e5..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_demo.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-17 Meco Man First version - */ -#include -#include -#define DBG_TAG "LVGL" -#define DBG_LVL DBG_INFO -#include - -#ifndef LV_THREAD_STACK_SIZE - #define LV_THREAD_STACK_SIZE 4096 -#endif - -#ifndef LV_THREAD_PRIO - #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3) -#endif - -static void lvgl_thread(void *parameter) -{ - extern void lv_demo_music(void); - lv_demo_music(); - - while (1) - { - lv_task_handler(); - rt_thread_mdelay(1); - } -} - -static int lvgl_demo_init(void) -{ - rt_thread_t tid; - - tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10); - if (tid == RT_NULL) - { - LOG_E("Fail to create 'LVGL' thread"); - } - rt_thread_startup(tid); - - return 0; -} -INIT_APP_EXPORT(lvgl_demo_init); diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.c b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.c deleted file mode 100644 index cc72d47337..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-12-17 Wayne The first version - */ -#include - -#define LOG_TAG "lvgl.disp" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG -#define DBG_LEVEL DBG_ERROR -#define DBG_COLOR -#include - -/*A static or global variable to store the buffers*/ -static lv_disp_draw_buf_t disp_buf; -static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ - -static rt_device_t lcd_device = 0; -static struct rt_device_graphic_info info; - -static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) -{ - /* Rendering */ - struct rt_device_rect_info rect; - - rect.x = area->x1; - rect.y = area->y1; - rect.width = area->x2 - area->x1 + 1; - rect.height = area->y2 - area->y1 + 1; - - if ((uint32_t)info.framebuffer != (uint32_t)color_p) - { - rect.y += info.height; - } - - rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect); - lv_disp_flush_ready(disp_drv); -} - -void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) -{ - rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t)); -} - -void lv_port_disp_init(void) -{ - rt_err_t result; - void *buf_1 = RT_NULL; - void *buf_2 = RT_NULL; - - lcd_device = rt_device_find("lcd"); - if (lcd_device == 0) - { - LOG_E("error!"); - return; - } - - /* get framebuffer address */ - result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info); - if (result != RT_EOK) - { - LOG_E("error!"); - /* get device information failed */ - return; - } - - RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 || - info.bits_per_pixel == 24 || info.bits_per_pixel == 32); - - buf_1 = (void *)info.framebuffer; - buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8); - rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2); - - /*Initialize `disp_buf` with the buffer(s).*/ - lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height); - - result = rt_device_open(lcd_device, 0); - if (result != RT_EOK) - { - LOG_E("error!"); - return; - } - - lv_disp_drv_init(&disp_drv); /*Basic initialization*/ - - /*Set the resolution of the display*/ - disp_drv.hor_res = info.width; - disp_drv.ver_res = info.height; - - /*Set a display buffer*/ - disp_drv.draw_buf = &disp_buf; - - /*Write the internal buffer (draw_buf) to the display*/ - disp_drv.flush_cb = lcd_fb_flush; - - /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ - //disp_drv.monitor_cb = lcd_perf_monitor; - - /*Finally register the driver*/ - lv_disp_drv_register(&disp_drv); -} diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.h b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.h deleted file mode 100644 index ef39eb03cd..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_disp.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - */ -#ifndef LV_PORT_DISP_H -#define LV_PORT_DISP_H - -#ifdef __cplusplus -extern "C" { -#endif - -void lv_port_disp_init(void); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.c b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.c deleted file mode 100644 index 4451ad4f84..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - * 2021-12-17 Wayne Add input event - */ -#include -#include -#include -#include "touch.h" - -static lv_indev_state_t last_state = LV_INDEV_STATE_REL; -static rt_int16_t last_x = 0; -static rt_int16_t last_y = 0; - -static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) -{ - data->point.x = last_x; - data->point.y = last_y; - data->state = last_state; -} - -void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state) -{ - switch (state) - { - case RT_TOUCH_EVENT_UP: - last_state = LV_INDEV_STATE_RELEASED; - break; - case RT_TOUCH_EVENT_DOWN: - last_x = x; - last_y = y; - last_state = LV_INDEV_STATE_PRESSED; - break; - case RT_TOUCH_EVENT_MOVE: - last_x = x; - last_y = y; - break; - } -} - -void lv_port_indev_init(void) -{ - static lv_indev_drv_t indev_drv; - - /* Basic initialization */ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = input_read; - - /* Register the driver in LVGL and save the created input device object */ - lv_indev_drv_register(&indev_drv); -} diff --git a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.h b/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.h deleted file mode 100644 index dec92bccbc..0000000000 --- a/bsp/nuvoton/nk-980iot/applications/lvgl/port/lv_port_indev.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - */ -#ifndef LV_PORT_INDEV_H -#define LV_PORT_INDEV_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern lv_indev_t *button_indev; - -void lv_port_indev_init(void); -void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/SConscript b/bsp/nuvoton/nk-n9h30/applications/lvgl/SConscript index 4cb03b1c72..18f793dbe0 100644 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/SConscript +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/SConscript @@ -1,17 +1,10 @@ -Import('RTT_ROOT') from building import * -import os +cwd = GetCurrentDir() +src = Glob('*.c') +CPPPATH = [cwd] -objs = [] +group = DefineGroup('LVGL-port', src, depend = ['PKG_USING_LVGL'], CPPPATH = CPPPATH) -if GetDepend('PKG_USING_LVGL'): - cwd = GetCurrentDir() - list = os.listdir(cwd) - for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') +Return('group') diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h new file mode 100644 index 0000000000..9b96e21b8d --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man First version + */ + +#ifndef LV_CONF_H +#define LV_CONF_H + +#define LV_USE_GPU_N9H30_GE2D 1 + +#define LV_USE_PERF_MONITOR 1 +#define LV_COLOR_DEPTH 32 + +#define LV_HOR_RES_MAX (800) +#define LV_VER_RES_MAX (480) + + +#define LV_USE_DEMO_RTT_MUSIC 1 +#define LV_USE_DEMO_MUSIC 1 +#define LV_FONT_MONTSERRAT_12 1 +#define LV_FONT_MONTSERRAT_16 1 +#define LV_DEMO_MUSIC_AUTO_PLAY 1 +#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1 + +//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE +#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_demo.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_demo.c new file mode 100644 index 0000000000..7ac1eab9e5 --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_demo.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-17 Meco Man First version + */ +#include +#include +#define DBG_TAG "LVGL" +#define DBG_LVL DBG_INFO +#include + +#ifndef LV_THREAD_STACK_SIZE + #define LV_THREAD_STACK_SIZE 4096 +#endif + +#ifndef LV_THREAD_PRIO + #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3) +#endif + +static void lvgl_thread(void *parameter) +{ + extern void lv_demo_music(void); + lv_demo_music(); + + while (1) + { + lv_task_handler(); + rt_thread_mdelay(1); + } +} + +static int lvgl_demo_init(void) +{ + rt_thread_t tid; + + tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10); + if (tid == RT_NULL) + { + LOG_E("Fail to create 'LVGL' thread"); + } + rt_thread_startup(tid); + + return 0; +} +INIT_APP_EXPORT(lvgl_demo_init); diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.c new file mode 100644 index 0000000000..51615b09b7 --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-17 Wayne The first version + */ +#include + +#define LOG_TAG "lvgl.disp" +#define DBG_ENABLE +#define DBG_SECTION_NAME LOG_TAG +#define DBG_LEVEL DBG_ERROR +#define DBG_COLOR +#include + +/*A static or global variable to store the buffers*/ +static lv_disp_draw_buf_t disp_buf; +static rt_device_t lcd_device = 0; +static struct rt_device_graphic_info info; +static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ + +extern void ge2dInit(int bpp, int width, int height, void *destination); +extern void ge2dSpriteBlt_Screen(int destx, int desty, int sprite_width, int sprite_height, void *buf); +extern int ge2dBitblt_SetAlphaMode(int opt, int ks, int kd); +extern void ge2dSpriteBltx_Screen(int x, int y, int sprite_sx, int sprite_sy, int width, int height, int sprite_width, int sprite_height, void *buf); +extern void ge2dClip_SetClip(int x1, int y1, int x2, int y2); +extern void ge2dFill_Solid_RGB565(int dx, int dy, int width, int height, int color); +extern void ge2dFill_Solid(int dx, int dy, int width, int height, int color); + +static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) +{ + /* Use ping-pong buffer updating without memory-copy. */ + rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, color_p); + + lv_disp_flush_ready(disp_drv); +} + +void ge2d_fill_cb(struct _lv_disp_drv_t *disp_drv, lv_color_t *dest_buf, lv_coord_t dest_width, + const lv_area_t *fill_area, lv_color_t color) +{ + int32_t act_x1 = fill_area->x1 < 0 ? 0 : fill_area->x1; + int32_t act_y1 = fill_area->y1 < 0 ? 0 : fill_area->y1; + int32_t act_x2 = fill_area->x2 > info.width - 1 ? info.width - 1 : fill_area->x2; + int32_t act_y2 = fill_area->y2 > info.height - 1 ? info.height - 1 : fill_area->y2; + int32_t fill_area_w = act_x2 - act_x1 + 1; + int32_t fill_area_h = act_y2 - act_y1 + 1; + + // Enter GE2D -> + ge2dInit(sizeof(lv_color_t) * 8, info.width, info.height, (void *)dest_buf); + ge2dClip_SetClip(act_x1, act_y1, act_x2, act_y2); + if (sizeof(lv_color_t) == 4) + { + ge2dFill_Solid(act_x1, act_y1, fill_area_w, fill_area_h, color.full); + } + else if (sizeof(lv_color_t) == 2) + { + ge2dFill_Solid_RGB565(act_x1, act_y1, fill_area_w, fill_area_h, color.full); + } + ge2dClip_SetClip(-1, 0, 0, 0); + // -> Leave GE2D +} + +void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) +{ + rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t)); +} + +void lv_port_disp_init(void) +{ + rt_err_t result; + void *buf_1 = RT_NULL; + void *buf_2 = RT_NULL; + + lcd_device = rt_device_find("lcd"); + if (lcd_device == 0) + { + LOG_E("error!"); + return; + } + + /* get framebuffer address */ + result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info); + if (result != RT_EOK) + { + LOG_E("error!"); + /* get device information failed */ + return; + } + + RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 || + info.bits_per_pixel == 24 || info.bits_per_pixel == 32); + + buf_1 = (void *)info.framebuffer; + buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8); + rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2); + + /*Initialize `disp_buf` with the buffer(s).*/ + lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height); + + result = rt_device_open(lcd_device, 0); + if (result != RT_EOK) + { + LOG_E("error!"); + return; + } + + lv_disp_drv_init(&disp_drv); /*Basic initialization*/ + + /*Set the resolution of the display*/ + disp_drv.hor_res = info.width; + disp_drv.ver_res = info.height; + disp_drv.full_refresh = 1; + + /*Set a display buffer*/ + disp_drv.draw_buf = &disp_buf; + + /*Write the internal buffer (draw_buf) to the display*/ + disp_drv.flush_cb = lcd_fb_flush; + + /*Fill a memory with a color (GPU only)*/ + disp_drv.gpu_fill_cb = ge2d_fill_cb; + + /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ + //disp_drv.monitor_cb = lcd_perf_monitor; + + /*Finally register the driver*/ + lv_disp_drv_register(&disp_drv); +} diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.h new file mode 100644 index 0000000000..ef39eb03cd --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_disp.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + */ +#ifndef LV_PORT_DISP_H +#define LV_PORT_DISP_H + +#ifdef __cplusplus +extern "C" { +#endif + +void lv_port_disp_init(void); + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.c new file mode 100644 index 0000000000..4451ad4f84 --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + * 2021-12-17 Wayne Add input event + */ +#include +#include +#include +#include "touch.h" + +static lv_indev_state_t last_state = LV_INDEV_STATE_REL; +static rt_int16_t last_x = 0; +static rt_int16_t last_y = 0; + +static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) +{ + data->point.x = last_x; + data->point.y = last_y; + data->state = last_state; +} + +void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state) +{ + switch (state) + { + case RT_TOUCH_EVENT_UP: + last_state = LV_INDEV_STATE_RELEASED; + break; + case RT_TOUCH_EVENT_DOWN: + last_x = x; + last_y = y; + last_state = LV_INDEV_STATE_PRESSED; + break; + case RT_TOUCH_EVENT_MOVE: + last_x = x; + last_y = y; + break; + } +} + +void lv_port_indev_init(void) +{ + static lv_indev_drv_t indev_drv; + + /* Basic initialization */ + lv_indev_drv_init(&indev_drv); + indev_drv.type = LV_INDEV_TYPE_POINTER; + indev_drv.read_cb = input_read; + + /* Register the driver in LVGL and save the created input device object */ + lv_indev_drv_register(&indev_drv); +} diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.h new file mode 100644 index 0000000000..dec92bccbc --- /dev/null +++ b/bsp/nuvoton/nk-n9h30/applications/lvgl/lv_port_indev.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + */ +#ifndef LV_PORT_INDEV_H +#define LV_PORT_INDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +extern lv_indev_t *button_indev; + +void lv_port_indev_init(void); +void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/SConscript b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/SConscript deleted file mode 100644 index 0ca25f18d4..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -src = Glob('*.c') -CPPPATH = [cwd] - -group = DefineGroup('LVGL-port', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') - diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_conf.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_conf.h deleted file mode 100644 index dd3e3c4b88..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_conf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man First version - */ - -#ifndef LV_CONF_H -#define LV_CONF_H - -//#define LV_USE_EXTERNAL_RENDERER 1 -#define LV_USE_GPU_N9H30_GE2D 1 - -//#define LV_USE_PERF_MONITOR 1 -#define LV_COLOR_DEPTH 32 - -#define LV_HOR_RES_MAX (800) -#define LV_VER_RES_MAX (480) - - -#define LV_USE_DEMO_RTT_MUSIC 1 -#define LV_USE_DEMO_MUSIC 1 -#define LV_FONT_MONTSERRAT_12 1 -#define LV_FONT_MONTSERRAT_16 1 -#define LV_DEMO_MUSIC_AUTO_PLAY 1 -#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1 - -//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE -#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_demo.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_demo.c deleted file mode 100644 index 7ac1eab9e5..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_demo.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-17 Meco Man First version - */ -#include -#include -#define DBG_TAG "LVGL" -#define DBG_LVL DBG_INFO -#include - -#ifndef LV_THREAD_STACK_SIZE - #define LV_THREAD_STACK_SIZE 4096 -#endif - -#ifndef LV_THREAD_PRIO - #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3) -#endif - -static void lvgl_thread(void *parameter) -{ - extern void lv_demo_music(void); - lv_demo_music(); - - while (1) - { - lv_task_handler(); - rt_thread_mdelay(1); - } -} - -static int lvgl_demo_init(void) -{ - rt_thread_t tid; - - tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10); - if (tid == RT_NULL) - { - LOG_E("Fail to create 'LVGL' thread"); - } - rt_thread_startup(tid); - - return 0; -} -INIT_APP_EXPORT(lvgl_demo_init); diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.c deleted file mode 100644 index a781817e36..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-12-17 Wayne The first version - */ -#include - -#define LOG_TAG "lvgl.disp" -#define DBG_ENABLE -#define DBG_SECTION_NAME LOG_TAG -#define DBG_LEVEL DBG_ERROR -#define DBG_COLOR -#include - -/*A static or global variable to store the buffers*/ -static lv_disp_draw_buf_t disp_buf; -static rt_device_t lcd_device = 0; -static struct rt_device_graphic_info info; -static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ - -extern void ge2dInit(int bpp, int width, int height, void *destination); -extern void ge2dSpriteBlt_Screen(int destx, int desty, int sprite_width, int sprite_height, void *buf); -extern int ge2dBitblt_SetAlphaMode(int opt, int ks, int kd); -extern void ge2dSpriteBltx_Screen(int x, int y, int sprite_sx, int sprite_sy, int width, int height, int sprite_width, int sprite_height, void *buf); -extern void ge2dClip_SetClip(int x1, int y1, int x2, int y2); -extern void ge2dFill_Solid_RGB565(int dx, int dy, int width, int height, int color); -extern void ge2dFill_Solid(int dx, int dy, int width, int height, int color); - -static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) -{ - /* Use ping-pong buffer updating without memory-copy. */ - rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, color_p); - - lv_disp_flush_ready(disp_drv); -} - -void ge2d_fill_cb(struct _lv_disp_drv_t *disp_drv, lv_color_t *dest_buf, lv_coord_t dest_width, - const lv_area_t *fill_area, lv_color_t color) -{ - int32_t act_x1 = fill_area->x1 < 0 ? 0 : fill_area->x1; - int32_t act_y1 = fill_area->y1 < 0 ? 0 : fill_area->y1; - int32_t act_x2 = fill_area->x2 > info.width - 1 ? info.width - 1 : fill_area->x2; - int32_t act_y2 = fill_area->y2 > info.height - 1 ? info.height - 1 : fill_area->y2; - int32_t fill_area_w = act_x2 - act_x1 + 1; - int32_t fill_area_h = act_y2 - act_y1 + 1; - - // Enter GE2D -> - ge2dInit(sizeof(lv_color_t) * 8, info.width, info.height, (void *)dest_buf); - ge2dClip_SetClip(act_x1, act_y1, act_x2, act_y2); - if (sizeof(lv_color_t) == 4) - { - ge2dFill_Solid(act_x1, act_y1, fill_area_w, fill_area_h, color.full); - } - else if (sizeof(lv_color_t) == 2) - { - ge2dFill_Solid_RGB565(act_x1, act_y1, fill_area_w, fill_area_h, color.full); - } - ge2dClip_SetClip(-1, 0, 0, 0); - // -> Leave GE2D -} - -void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px) -{ - rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t)); -} - -void lv_port_disp_init(void) -{ - rt_err_t result; - void *buf_1 = RT_NULL; - void *buf_2 = RT_NULL; - - lcd_device = rt_device_find("lcd"); - if (lcd_device == 0) - { - LOG_E("error!"); - return; - } - - /* get framebuffer address */ - result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info); - if (result != RT_EOK) - { - LOG_E("error!"); - /* get device information failed */ - return; - } - - RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 || - info.bits_per_pixel == 24 || info.bits_per_pixel == 32); - - buf_1 = (void *)info.framebuffer; - buf_2 = (void *)((uint32_t)buf_1 + info.height * info.width * info.bits_per_pixel / 8); - rt_kprintf("LVGL: Use two buffers - buf_1@%08x, buf_2@%08x\n", buf_1, buf_2); - - /*Initialize `disp_buf` with the buffer(s).*/ - lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, info.width * info.height); - - result = rt_device_open(lcd_device, 0); - if (result != RT_EOK) - { - LOG_E("error!"); - return; - } - - lv_disp_drv_init(&disp_drv); /*Basic initialization*/ - - /*Set the resolution of the display*/ - disp_drv.hor_res = info.width; - disp_drv.ver_res = info.height; - disp_drv.full_refresh = 1; - - /*Set a display buffer*/ - disp_drv.draw_buf = &disp_buf; - - /*Write the internal buffer (draw_buf) to the display*/ - disp_drv.flush_cb = lcd_fb_flush; - - /*Fill a memory with a color (GPU only)*/ - disp_drv.gpu_fill_cb = ge2d_fill_cb; - - /* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */ - //disp_drv.monitor_cb = lcd_perf_monitor; - - /*Finally register the driver*/ - lv_disp_drv_register(&disp_drv); -} diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.h deleted file mode 100644 index ef39eb03cd..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_disp.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - */ -#ifndef LV_PORT_DISP_H -#define LV_PORT_DISP_H - -#ifdef __cplusplus -extern "C" { -#endif - -void lv_port_disp_init(void); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.c b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.c deleted file mode 100644 index 4451ad4f84..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - * 2021-12-17 Wayne Add input event - */ -#include -#include -#include -#include "touch.h" - -static lv_indev_state_t last_state = LV_INDEV_STATE_REL; -static rt_int16_t last_x = 0; -static rt_int16_t last_y = 0; - -static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) -{ - data->point.x = last_x; - data->point.y = last_y; - data->state = last_state; -} - -void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state) -{ - switch (state) - { - case RT_TOUCH_EVENT_UP: - last_state = LV_INDEV_STATE_RELEASED; - break; - case RT_TOUCH_EVENT_DOWN: - last_x = x; - last_y = y; - last_state = LV_INDEV_STATE_PRESSED; - break; - case RT_TOUCH_EVENT_MOVE: - last_x = x; - last_y = y; - break; - } -} - -void lv_port_indev_init(void) -{ - static lv_indev_drv_t indev_drv; - - /* Basic initialization */ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = input_read; - - /* Register the driver in LVGL and save the created input device object */ - lv_indev_drv_register(&indev_drv); -} diff --git a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.h b/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.h deleted file mode 100644 index dec92bccbc..0000000000 --- a/bsp/nuvoton/nk-n9h30/applications/lvgl/port/lv_port_indev.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2021-10-18 Meco Man The first version - */ -#ifndef LV_PORT_INDEV_H -#define LV_PORT_INDEV_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern lv_indev_t *button_indev; - -void lv_port_indev_init(void); -void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif -- cgit v1.3.1