mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
Support LVGLv81 RTT music demo for N9H30 and NUC980.
This commit is contained in:
1 parent
57165329ac
commit
9966f195b4
35 files changed
+2003
-476
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -322,6 +322,10 @@ uint32_t QSPI_SetBusClock(QSPI_T *qspi, uint32_t u32BusClock)
|
||||
u32ClkSrc = __HIRC; /* Clock source is HIRC */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (u32BusClock >= u32HCLKFreq)
|
||||
{
|
||||
|
||||
@@ -231,6 +231,9 @@ void vpostMPUWriteAddr(uint16_t uscmd);
|
||||
void vpostMPUWriteData(uint16_t usdata);
|
||||
uint32_t vpostMPUReadData(void);
|
||||
VPOST_T *vpostLCMGetInstance(uint32_t u32DisplayPanelID);
|
||||
void vpostSetFrameBuffer(uint8_t *pu8BufPtr);
|
||||
void vpostSetOSDBuffer(uint8_t *pu8BufPtr);
|
||||
uint8_t *vpostGetMultiOSDBuffer(uint32_t u32Cnt);
|
||||
|
||||
/*@}*/ /* end of group N9H30_LCD_EXPORTED_FUNCTIONS */
|
||||
|
||||
|
||||
@@ -234,6 +234,12 @@ uint8_t *vpostGetFrameBuffer(void)
|
||||
return (uint8_t *)((uint32_t)u8BufPtr | 0x80000000);
|
||||
}
|
||||
|
||||
void vpostSetFrameBuffer(uint8_t *pu8BufPtr)
|
||||
{
|
||||
outpw(REG_LCM_VA_BADDR0, (uint32_t)((uint32_t)pu8BufPtr | 0x80000000));
|
||||
outpw(REG_LCM_VA_FBCTRL, inpw(REG_LCM_VA_FBCTRL) & ~(1 << 30) & ~VPOSTB_DB_EN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of frame buffer
|
||||
@@ -535,6 +541,56 @@ uint8_t *vpostGetOSDBuffer(void)
|
||||
return (uint8_t *)((uint32_t)u8BufPtr | 0x80000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of OSD buffer
|
||||
* @param[in] u32Cnt is the frame buffer count to allocate. Min value is 1.
|
||||
* @return pointer of frame buffer
|
||||
* @retval NULL fail.
|
||||
* @note before calling this function, display width, height and source format must be set first.
|
||||
*/
|
||||
uint8_t *vpostGetMultiOSDBuffer(uint32_t u32Cnt)
|
||||
{
|
||||
uint32_t u32BytePerPixel;
|
||||
uint8_t *u8BufPtr;
|
||||
|
||||
if ((curOSDDev.nOSDWidth == 0) || (curOSDDev.nOSDHeight == 0))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (curOSDDev.ucOSDSrcFormat)
|
||||
{
|
||||
case OSD_SRC_YUV422:
|
||||
case OSD_SRC_YCBCR422:
|
||||
case OSD_SRC_RGB565:
|
||||
u32BytePerPixel = 2;
|
||||
break;
|
||||
|
||||
case OSD_SRC_RGB666:
|
||||
case OSD_SRC_RGB888:
|
||||
u32BytePerPixel = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
u32BytePerPixel = 2;
|
||||
}
|
||||
|
||||
u8BufPtr = (uint8_t *)malloc((curOSDDev.nOSDWidth * curOSDDev.nOSDHeight * u32BytePerPixel) * u32Cnt + 32);
|
||||
if (u8BufPtr == NULL)
|
||||
return NULL;
|
||||
u8BufPtr = (uint8_t *)shift_pointer((uint32_t)u8BufPtr, 32);
|
||||
|
||||
outpw(REG_LCM_OSD_BADDR, (uint32_t)((uint32_t)u8BufPtr | 0x80000000));
|
||||
|
||||
return (uint8_t *)((uint32_t)u8BufPtr | 0x80000000);
|
||||
|
||||
}
|
||||
|
||||
void vpostSetOSDBuffer(uint8_t *u8BufPtr)
|
||||
{
|
||||
outpw(REG_LCM_OSD_BADDR, (uint32_t)((uint32_t)u8BufPtr | 0x80000000));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable OSD function
|
||||
* @param none
|
||||
|
||||
@@ -283,6 +283,10 @@ uint32_t SDH_CardDetection(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t card_num)
|
||||
u32INTSTS_CDSTS_Msk = SDH_INTSTS_CDSTS1_Msk;
|
||||
u32CTL_CLKKEEP_Msk = SDH_CTL_CLKKEEP1_Msk;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((sdh->INTEN & u32INTEN_CDSRC_Msk) == u32INTEN_CDSRC_Msk) /* Card detect pin from GPIO */
|
||||
{
|
||||
|
||||
@@ -216,7 +216,7 @@ static void adc_touch_entry(void *parameter)
|
||||
|| touch_point.event == RT_TOUCH_EVENT_UP
|
||||
|| touch_point.event == RT_TOUCH_EVENT_MOVE)
|
||||
{
|
||||
#if defined(PKG_USING_LITTLEVGL2RTT)
|
||||
#if defined(PKG_USING_LITTLEVGL2RTT) || defined(PKG_USING_LVGL)
|
||||
extern void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
|
||||
littlevgl2rtt_send_input_event(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,8 @@
|
||||
|
||||
/* Private typedef --------------------------------------------------------------*/
|
||||
|
||||
#define DEF_VPOST_BUFFER_NUMBER 2
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eVpost_LCD,
|
||||
@@ -43,6 +45,10 @@ struct nu_vpost
|
||||
};
|
||||
typedef struct nu_vpost *nu_vpost_t;
|
||||
|
||||
static volatile uint32_t g_u32VSyncBlank = 0;
|
||||
static volatile uint32_t g_u32VSyncLastCommit = 0;
|
||||
static struct rt_completion vsync_wq;
|
||||
|
||||
static struct nu_vpost nu_fbdev[eVpost_Cnt] =
|
||||
{
|
||||
{
|
||||
@@ -151,6 +157,43 @@ static rt_err_t vpost_layer_control(rt_device_t dev, int cmd, void *args)
|
||||
}
|
||||
break;
|
||||
|
||||
/* FBIO_PANDISPLAY + WAIT_VSYNC Mechanism */
|
||||
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
||||
{
|
||||
if (args != RT_NULL)
|
||||
{
|
||||
uint8_t *pu8BufPtr = (uint8_t *)args;
|
||||
g_u32VSyncLastCommit = g_u32VSyncBlank;
|
||||
|
||||
/* Pan display */
|
||||
switch (psVpost->layer)
|
||||
{
|
||||
case eVpost_LCD:
|
||||
vpostSetFrameBuffer(pu8BufPtr);
|
||||
break;
|
||||
|
||||
#if defined(BSP_USING_VPOST_OSD)
|
||||
case eVpost_OSD:
|
||||
vpostSetOSDBuffer(pu8BufPtr);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/*Wait sync*/
|
||||
while (g_u32VSyncLastCommit == g_u32VSyncBlank)
|
||||
{
|
||||
rt_completion_init(&vsync_wq);
|
||||
rt_completion_wait(&vsync_wq, RT_TICK_PER_SECOND / 60);
|
||||
}
|
||||
}
|
||||
else
|
||||
return -RT_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -166,9 +209,43 @@ static rt_err_t vpost_layer_init(rt_device_t dev)
|
||||
/* Enable VPOST engine clock. */
|
||||
nu_sys_ipclk_enable(LCDCKEN);
|
||||
|
||||
rt_completion_init(&vsync_wq);
|
||||
outpw(REG_LCM_INT_CS, VPOSTB_UNDERRUN_EN | VPOSTB_DISP_F_EN);
|
||||
outpw(REG_LCM_DCCS, (inpw(REG_LCM_DCCS) | (1 << 4)));
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static void nu_vpost_isr(int vector, void *param)
|
||||
{
|
||||
/*
|
||||
#define VPOSTB_DISP_F_INT ((UINT32)1<<31)
|
||||
#define VPOSTB_DISP_F_STATUS (1<<30)
|
||||
#define VPOSTB_UNDERRUN_INT (1<<29)
|
||||
#define VPOSTB_BUS_ERROR_INT (1<<28)
|
||||
#define VPOSTB_FLY_ERR (1<<27)
|
||||
#define VPOSTB_UNDERRUN_EN (1<<1)
|
||||
#define VPOSTB_DISP_F_EN (1)
|
||||
*/
|
||||
|
||||
uint32_t u32VpostIRQStatus = inpw(REG_LCM_INT_CS);
|
||||
if (u32VpostIRQStatus & VPOSTB_DISP_F_STATUS)
|
||||
{
|
||||
outpw(REG_LCM_INT_CS, inpw(REG_LCM_INT_CS) | VPOSTB_DISP_F_STATUS);
|
||||
|
||||
g_u32VSyncBlank++;
|
||||
rt_completion_done(&vsync_wq);
|
||||
}
|
||||
else if (u32VpostIRQStatus & VPOSTB_UNDERRUN_INT)
|
||||
{
|
||||
outpw(REG_LCM_INT_CS, inpw(REG_LCM_INT_CS) | VPOSTB_UNDERRUN_INT);
|
||||
}
|
||||
else if (u32VpostIRQStatus & VPOSTB_BUS_ERROR_INT)
|
||||
{
|
||||
outpw(REG_LCM_INT_CS, inpw(REG_LCM_INT_CS) | VPOSTB_BUS_ERROR_INT);
|
||||
}
|
||||
}
|
||||
|
||||
int rt_hw_vpost_init(void)
|
||||
{
|
||||
int i = -1;
|
||||
@@ -177,13 +254,8 @@ int rt_hw_vpost_init(void)
|
||||
VPOST_T *psVpostLcmInst = vpostLCMGetInstance(VPOST_USING_LCD_IDX);
|
||||
RT_ASSERT(psVpostLcmInst != RT_NULL);
|
||||
|
||||
#if (LCM_USING_BPP==4 )
|
||||
/* LCD clock is selected from UPLL and divide to 30MHz */
|
||||
outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0x918);
|
||||
#else
|
||||
/* LCD clock is selected from UPLL and divide to 20MHz */
|
||||
outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0xE18);
|
||||
#endif
|
||||
|
||||
/* Initial LCM */
|
||||
vpostLCMInit(VPOST_USING_LCD_IDX);
|
||||
@@ -213,7 +285,7 @@ int rt_hw_vpost_init(void)
|
||||
#else
|
||||
vpostSetVASrc(VA_SRC_RGB565);
|
||||
#endif
|
||||
psVpost->info.framebuffer = (rt_uint8_t *)vpostGetFrameBuffer();
|
||||
psVpost->info.framebuffer = (rt_uint8_t *)vpostGetMultiFrameBuffer(DEF_VPOST_BUFFER_NUMBER);
|
||||
}
|
||||
#if defined(BSP_USING_VPOST_OSD)
|
||||
else if (psVpost->layer == eVpost_OSD)
|
||||
@@ -225,7 +297,7 @@ int rt_hw_vpost_init(void)
|
||||
#else
|
||||
vpostSetOSDSrc(OSD_SRC_RGB565);
|
||||
#endif
|
||||
psVpost->info.framebuffer = (rt_uint8_t *)vpostGetOSDBuffer();
|
||||
psVpost->info.framebuffer = (rt_uint8_t *)vpostGetMultiOSDBuffer(DEF_VPOST_BUFFER_NUMBER);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -242,10 +314,16 @@ int rt_hw_vpost_init(void)
|
||||
psVpost->dev.close = vpost_layer_close;
|
||||
psVpost->dev.control = vpost_layer_control;
|
||||
|
||||
/* register graphic device driver */
|
||||
/* Register graphic device driver */
|
||||
ret = rt_device_register(&psVpost->dev, psVpost->name, RT_DEVICE_FLAG_RDWR);
|
||||
RT_ASSERT(ret == RT_EOK);
|
||||
|
||||
if (psVpost->layer == eVpost_LCD)
|
||||
{
|
||||
rt_hw_interrupt_install(psVpost->irqn, nu_vpost_isr, psVpost, psVpost->name);
|
||||
rt_hw_interrupt_umask(psVpost->irqn);
|
||||
}
|
||||
|
||||
rt_kprintf("%s's fbmem at 0x%08x.\n", psVpost->name, psVpost->info.framebuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
#include <rtdevice.h>
|
||||
#include <lcd_ili9341.h>
|
||||
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
#define DEF_VRAM_BUFFER_NUMBER 2
|
||||
#endif
|
||||
|
||||
static struct rt_device_graphic_info g_Ili9341Info =
|
||||
{
|
||||
.bits_per_pixel = 16,
|
||||
@@ -270,8 +274,18 @@ static rt_err_t ili9341_lcd_control(rt_device_t dev, int cmd, void *args)
|
||||
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
||||
{
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
struct rt_device_rect_info *psRectInfo = args;
|
||||
rt_uint16_t *pixels = (rt_uint16_t *)g_Ili9341Info.framebuffer;
|
||||
RT_ASSERT(args != RT_NULL);
|
||||
ili9341_fillrect((uint16_t *)g_Ili9341Info.framebuffer, (struct rt_device_rect_info *) args);
|
||||
|
||||
if (psRectInfo->y >= g_Ili9341Info.height)
|
||||
{
|
||||
int buf_id = psRectInfo->y / g_Ili9341Info.height;
|
||||
pixels += g_Ili9341Info.width * g_Ili9341Info.height * buf_id;
|
||||
psRectInfo->y %= g_Ili9341Info.height;
|
||||
}
|
||||
|
||||
ili9341_fillrect(pixels, psRectInfo);
|
||||
#else
|
||||
/* nothong to be done */
|
||||
#endif
|
||||
@@ -310,7 +324,7 @@ int rt_hw_lcd_ili9341_init(void)
|
||||
lcd_device.user_data = &ili9341_ops;
|
||||
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
g_Ili9341Info.framebuffer = rt_malloc_align(g_Ili9341Info.bits_per_pixel / 2 * g_Ili9341Info.height * g_Ili9341Info.width, 32);
|
||||
g_Ili9341Info.framebuffer = rt_malloc_align((DEF_VRAM_BUFFER_NUMBER * g_Ili9341Info.width * g_Ili9341Info.height * (g_Ili9341Info.bits_per_pixel / 8)) + 32, 32);
|
||||
RT_ASSERT(g_Ili9341Info.framebuffer != RT_NULL);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,9 +3,19 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
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'))
|
||||
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
objs = objs + group
|
||||
|
||||
Return('objs')
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
import os
|
||||
|
||||
objs = []
|
||||
|
||||
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')
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('LVGL-port', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -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_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
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#include <lv_port_indev.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef LV_THREAD_STACK_SIZE
|
||||
#define LV_THREAD_STACK_SIZE 10240
|
||||
#endif
|
||||
|
||||
#ifndef LV_THREAD_PRIO
|
||||
#define LV_THREAD_PRIO 20
|
||||
#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);
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 <lvgl.h>
|
||||
|
||||
#define LOG_TAG "lvgl.disp"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL DBG_ERROR
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*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;
|
||||
|
||||
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;
|
||||
rt_kprintf("lv buf_1=%08x\n", buf_1);
|
||||
|
||||
/*Initialize `disp_buf` with the buffer(s).*/
|
||||
lv_disp_draw_buf_init(&disp_buf, buf_1, NULL, 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;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <rtdevice.h>
|
||||
#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 littlevgl2rtt_send_input_event(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lv_indev_t *button_indev;
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
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*/
|
||||
button_indev = lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
@@ -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 <lv_hal_indev.h>
|
||||
|
||||
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
|
||||
+138
-92
File diff suppressed because it is too large.
Load diff
@@ -3,9 +3,19 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
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'))
|
||||
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
objs = objs + group
|
||||
|
||||
Return('objs')
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
import os
|
||||
|
||||
objs = []
|
||||
|
||||
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')
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('LVGL-port', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#include <lv_port_indev.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef LV_THREAD_STACK_SIZE
|
||||
#define LV_THREAD_STACK_SIZE 10240
|
||||
#endif
|
||||
|
||||
#ifndef LV_THREAD_PRIO
|
||||
#define LV_THREAD_PRIO 20
|
||||
#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(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);
|
||||
//MSH_CMD_EXPORT(lvgl_demo, start lvgl music demo);
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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 <lvgl.h>
|
||||
|
||||
#define LOG_TAG "lvgl.disp"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL DBG_ERROR
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*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;
|
||||
rt_kprintf("lv buf_1=%08x\n", buf_1);
|
||||
|
||||
buf_2 = (void *)((uint32_t)info.framebuffer + info.height * info.width * info.bits_per_pixel / 8);
|
||||
rt_kprintf("lv buf_2=%08x\n", 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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 <lvgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <rtdevice.h>
|
||||
#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 littlevgl2rtt_send_input_event(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lv_indev_t *button_indev;
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
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*/
|
||||
button_indev = lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
@@ -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 <lv_hal_indev.h>
|
||||
|
||||
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
|
||||
@@ -259,12 +259,7 @@ int rt_hw_lcm_port(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_PIN)
|
||||
/* set LCM_BLEN pin mode to output */
|
||||
rt_pin_mode(LCM_BLEN, PIN_MODE_OUTPUT);
|
||||
rt_pin_write(LCM_BLEN, PIN_HIGH);
|
||||
#endif
|
||||
|
||||
/* Use PWM to control backlight. */
|
||||
LCMLightOn();
|
||||
|
||||
return 0;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -3,9 +3,19 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
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'))
|
||||
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
objs = objs + group
|
||||
|
||||
Return('objs')
|
||||
|
||||
@@ -153,7 +153,7 @@ INIT_COMPONENT_EXPORT(rt_hw_spiflash_init);
|
||||
#if defined(BOARD_USING_SRAM0_AS_MEMHEAP)
|
||||
/*
|
||||
In Advance board design, SRAM address bus A16/A17/A18 are GPIO-controlled by SW, not EBI.
|
||||
So we just remap 128KB only to RTT memory heap, due to it is out of controll.
|
||||
So we just remap 128KB only to RTT memory heap, due to it is out of control.
|
||||
AD0~AD15: 2^16*16bit = 128KB
|
||||
*/
|
||||
#include <drv_ebi.h>
|
||||
|
||||
Reference in new issue
Block a user