forked from xuos/xiuos
add lvgl
This commit is contained in:
parent
36f2ebbf95
commit
37c247f4d7
|
@ -2,6 +2,12 @@ SRC_DIR := general_functions app_test
|
|||
|
||||
SRC_FILES := main.c framework_init.c
|
||||
|
||||
ifeq ($(CONFIG_LIB_LV),y)
|
||||
SRC_FILES += lv_init.c
|
||||
|
||||
SRC_DIR += lv_app
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_OTA),y)
|
||||
SRC_DIR += ota
|
||||
endif
|
||||
|
|
|
@ -34,6 +34,8 @@ extern int Tb600bIaq10IaqInit(void);
|
|||
extern int Tb600bTvoc10TvocInit(void);
|
||||
extern int Tb600bWqHcho1osInit(void);
|
||||
|
||||
extern int lv_port_init(void);
|
||||
|
||||
typedef int (*InitFunc)(void);
|
||||
struct InitDesc
|
||||
{
|
||||
|
@ -200,5 +202,9 @@ int FrameworkInit()
|
|||
ConnectionDeviceFrameworkInit(framework);
|
||||
#endif
|
||||
|
||||
#ifdef LIB_LV
|
||||
lv_port_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := lv_demo.c lv_demo_calendar.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 <lvgl.h>
|
||||
#include <lv_port_indev_template.h>
|
||||
#include "lv_demo_calendar.h"
|
||||
#include <transform.h>
|
||||
|
||||
void* lvgl_thread(void *parameter)
|
||||
{
|
||||
/* display demo; you may replace with your LVGL application at here */
|
||||
lv_demo_calendar();
|
||||
|
||||
/* handle the tasks of LVGL */
|
||||
while(1)
|
||||
{
|
||||
lv_task_handler();
|
||||
PrivTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_t lvgl_task;
|
||||
static int lvgl_demo_init(void)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = 20;
|
||||
attr.stacksize = 4096;
|
||||
|
||||
PrivTaskCreate(&lvgl_task, &attr, lvgl_thread, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_demo_init, lvgl_demo_init, lvgl_demo_init );
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include <lvgl.h>
|
||||
#include "lv_demo_calendar.h"
|
||||
// #include <drv_lcd.h>
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_calendar_date_t date;
|
||||
if(lv_calendar_get_pressed_date(obj, &date)) {
|
||||
LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_demo_calendar(void)
|
||||
{
|
||||
lv_obj_t * calendar = lv_calendar_create(lv_scr_act());
|
||||
lv_obj_set_size(calendar, 240, 240);
|
||||
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
lv_calendar_set_today_date(calendar, 2021, 02, 23);
|
||||
lv_calendar_set_showed_date(calendar, 2021, 02);
|
||||
|
||||
/*Highlight a few days*/
|
||||
static lv_calendar_date_t highlighted_days[3]; /*Only its pointer will be saved so should be static*/
|
||||
highlighted_days[0].year = 2021;
|
||||
highlighted_days[0].month = 02;
|
||||
highlighted_days[0].day = 6;
|
||||
|
||||
highlighted_days[1].year = 2021;
|
||||
highlighted_days[1].month = 02;
|
||||
highlighted_days[1].day = 11;
|
||||
|
||||
highlighted_days[2].year = 2022;
|
||||
highlighted_days[2].month = 02;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
lv_calendar_header_dropdown_create(calendar);
|
||||
#elif LV_USE_CALENDAR_HEADER_ARROW
|
||||
lv_calendar_header_arrow_create(calendar);
|
||||
#endif
|
||||
lv_calendar_set_showed_date(calendar, 2021, 10);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef __LV_DEMO_CALENDAR_H__
|
||||
#define __LV_DEMO_CALENDAR_H__
|
||||
|
||||
void lv_demo_calendar(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#include <lvgl.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
|
||||
#ifndef PKG_USING_LVGL_DISP_DEVICE
|
||||
#include <lv_port_disp_template.h>
|
||||
#endif
|
||||
|
||||
#ifndef PKG_USING_LVGL_INDEV_DEVICE
|
||||
#include <lv_port_indev_template.h>
|
||||
#endif
|
||||
extern void lv_port_disp_init(void);
|
||||
extern void lv_port_indev_init(void);
|
||||
#if LV_USE_LOG && LV_LOG_PRINTF
|
||||
static void lv_rt_log(const char *buf)
|
||||
{
|
||||
LOG_I(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
int lv_port_init(void)
|
||||
{
|
||||
#if LV_USE_LOG && LV_LOG_PRINTF
|
||||
lv_log_register_print_cb(lv_rt_log);
|
||||
#endif
|
||||
|
||||
lv_init();
|
||||
|
||||
#ifndef PKG_USING_LVGL_DISP_DEVICE
|
||||
lv_port_disp_init();
|
||||
#endif
|
||||
#ifndef PKG_USING_LVGL_INDEV_DEVICE
|
||||
lv_port_indev_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -138,6 +138,13 @@ static int PrivPinIoctl(int fd, int cmd, void *args)
|
|||
return ioctl(fd, cmd, pin_cfg);
|
||||
}
|
||||
|
||||
static int PrivLcdIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct DeviceLcdInfo *lcd_cfg = (struct DeviceLcdInfo *)args;
|
||||
|
||||
return ioctl(fd, cmd, lcd_cfg);
|
||||
}
|
||||
|
||||
int PrivIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
int ret;
|
||||
|
@ -154,6 +161,9 @@ int PrivIoctl(int fd, int cmd, void *args)
|
|||
case I2C_TYPE:
|
||||
ret = ioctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case LCD_TYPE:
|
||||
ret = PrivLcdIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ enum IoctlDriverType
|
|||
SPI_TYPE,
|
||||
I2C_TYPE,
|
||||
PIN_TYPE,
|
||||
LCD_TYPE,
|
||||
DEFAULT_TYPE,
|
||||
};
|
||||
|
||||
|
@ -147,6 +148,32 @@ struct PrivIoctlCfg
|
|||
void *args;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 x_pos;
|
||||
uint16 y_pos;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint8 font_size;
|
||||
uint8 *addr;
|
||||
uint16 font_color;
|
||||
uint16 back_color;
|
||||
}LcdStringParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 x_pos;
|
||||
uint16 y_pos;
|
||||
uint16 pixel_color;
|
||||
}LcdPixelParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char type; // 0:write string;1:write dot
|
||||
LcdStringParam string_info;
|
||||
LcdPixelParam pixel_info;
|
||||
}LcdWriteParam;
|
||||
|
||||
/**********************mutex**************************/
|
||||
|
||||
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
menu "lib"
|
||||
|
||||
choice
|
||||
prompt "chose a kind of lib for app"
|
||||
default APP_SELECT_NEWLIB
|
||||
|
@ -12,4 +11,5 @@ menu "lib"
|
|||
endchoice
|
||||
source "$APP_DIR/lib/cJSON/Kconfig"
|
||||
source "$APP_DIR/lib/queue/Kconfig"
|
||||
source "$APP_DIR/lib/lvgl/Kconfig"
|
||||
endmenu
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
SRC_DIR :=
|
||||
# SRC_DIR := lvgl
|
||||
|
||||
ifeq ($(CONFIG_APP_SELECT_NEWLIB),y)
|
||||
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
|
||||
SRC_DIR += app_newlib
|
||||
endif
|
||||
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
|
||||
SRC_DIR += app_newlib
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_LV),y)
|
||||
SRC_DIR += lvgl
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit d38eb1e689fa5a64c25e677275172d9c8a4ab2f0
|
|
@ -851,7 +851,7 @@ typedef void * lv_obj_user_data_t;
|
|||
#ifdef CONFIG_USE_LV_CALENDAR
|
||||
#define LV_USE_CALENDAR CONFIG_USE_LV_CALENDAR
|
||||
#else
|
||||
#define LV_USE_CALENDAR 0
|
||||
#define LV_USE_CALENDAR 1
|
||||
#endif
|
||||
|
||||
/* Canvas (dependencies: lv_img) */
|
||||
|
|
|
@ -32,11 +32,11 @@ Modification: add aiit-riscv64-board lcd configure and operation function
|
|||
#include <xiuos.h>
|
||||
|
||||
#define GRAPHIC_CTRL_RECT_UPDATE 0
|
||||
#define GRAPHIC_CTRL_POWERON 1
|
||||
#define GRAPHIC_CTRL_POWEROFF 2
|
||||
#define GRAPHIC_CTRL_GET_INFO 3
|
||||
#define GRAPHIC_CTRL_SET_MODE 4
|
||||
#define GRAPHIC_CTRL_GET_EXT 5
|
||||
#define GRAPHIC_CTRL_POWERON 1
|
||||
#define GRAPHIC_CTRL_POWEROFF 2
|
||||
#define GRAPHIC_CTRL_GET_INFO 3
|
||||
#define GRAPHIC_CTRL_SET_MODE 4
|
||||
#define GRAPHIC_CTRL_GET_EXT 5
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
if BSP_USING_LCD
|
||||
config LCD_BUS_NAME_1
|
||||
string "lcd bus 1 name"
|
||||
default "lcd1"
|
||||
config LCD_DRV_NAME_1
|
||||
string "lcd bus 1 driver name"
|
||||
default "lcd1drv"
|
||||
config LCD_1_DEVICE_NAME_0
|
||||
string "lcd bus 1 device 0 name"
|
||||
default "lcd10"
|
||||
config LCD_BUS_NAME
|
||||
string "lcd bus name"
|
||||
default "lcd"
|
||||
config LCD_DRV_NAME
|
||||
string "lcd bus driver name"
|
||||
default "lcd_drv"
|
||||
config LCD_DEVICE_NAME
|
||||
string "lcd bus device name"
|
||||
default "lcd_dev"
|
||||
config BSP_LCD_CS_PIN
|
||||
int "CS pin number of 8080 interface"
|
||||
default 40
|
||||
|
|
|
@ -137,7 +137,7 @@ typedef enum _lcd_dir
|
|||
|
||||
typedef struct Lcd8080Device
|
||||
{
|
||||
struct LcdBus lcd_bus;
|
||||
struct LcdBus lcd_bus;
|
||||
struct DeviceLcdInfo lcd_info;
|
||||
int spi_channel;
|
||||
int cs;
|
||||
|
@ -145,46 +145,46 @@ typedef struct Lcd8080Device
|
|||
int dma_channel;
|
||||
} * Lcd8080DeviceType;
|
||||
|
||||
Lcd8080DeviceType lcd ;
|
||||
Lcd8080DeviceType aiit_lcd ;
|
||||
|
||||
static void DrvLcdCmd(uint8 cmd)
|
||||
{
|
||||
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_LOW);
|
||||
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(lcd->spi_channel/*spi num*/, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
gpiohs_set_pin(aiit_lcd->dc_pin, GPIO_PV_LOW);
|
||||
spi_init(aiit_lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(aiit_lcd->spi_channel/*spi num*/, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, &cmd, 1, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(aiit_lcd->dma_channel, aiit_lcd->spi_channel, aiit_lcd->cs, &cmd, 1, SPI_TRANS_CHAR);
|
||||
}
|
||||
|
||||
static void DrvLcdDataByte(uint8 *data_buf, uint32 length)
|
||||
{
|
||||
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(lcd->spi_channel, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
gpiohs_set_pin(aiit_lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(aiit_lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(aiit_lcd->spi_channel, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(aiit_lcd->dma_channel, aiit_lcd->spi_channel, aiit_lcd->cs, data_buf, length, SPI_TRANS_CHAR);
|
||||
}
|
||||
|
||||
static void DrvLcdDataHalfWord(uint16 *data_buf, uint32 length)
|
||||
{
|
||||
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0);
|
||||
spi_init_non_standard(lcd->spi_channel, 16 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
gpiohs_set_pin(aiit_lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(aiit_lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0);
|
||||
spi_init_non_standard(aiit_lcd->spi_channel, 16 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_SHORT);
|
||||
spi_send_data_normal_dma(aiit_lcd->dma_channel, aiit_lcd->spi_channel, aiit_lcd->cs, data_buf, length, SPI_TRANS_SHORT);
|
||||
}
|
||||
|
||||
static void DrvLcdDataWord(uint32 *data_buf, uint32 length)
|
||||
{
|
||||
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
|
||||
gpiohs_set_pin(aiit_lcd->dc_pin, GPIO_PV_HIGH);
|
||||
/*spi num Polarity and phase mode Multi-line mode Data bit width little endian */
|
||||
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
|
||||
spi_init(aiit_lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
|
||||
|
||||
/* spi num instrction length address length wait cycles spi address trans mode*/
|
||||
spi_init_non_standard(lcd->spi_channel, 0 , 32, 0 ,SPI_AITM_AS_FRAME_FORMAT );
|
||||
spi_init_non_standard(aiit_lcd->spi_channel, 0 , 32, 0 ,SPI_AITM_AS_FRAME_FORMAT );
|
||||
|
||||
/*dma channel spi num chip_selete tx_buff tx_len spi_trans_data_width */
|
||||
spi_send_data_normal_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, data_buf, length, SPI_TRANS_INT);
|
||||
spi_send_data_normal_dma(aiit_lcd->dma_channel, aiit_lcd->spi_channel, aiit_lcd->cs, data_buf, length, SPI_TRANS_INT);
|
||||
}
|
||||
|
||||
static void DrvLcdHwInit(Lcd8080DeviceType lcd)
|
||||
|
@ -201,11 +201,11 @@ static void DrvLcdSetDirection(lcd_dir_t dir)
|
|||
dir |= 0x08;
|
||||
#endif
|
||||
if (dir & DIR_XY_MASK) {
|
||||
lcd->lcd_info.width = 320;
|
||||
lcd->lcd_info.height = 240;
|
||||
aiit_lcd->lcd_info.width = 320;
|
||||
aiit_lcd->lcd_info.height = 240;
|
||||
} else {
|
||||
lcd->lcd_info.width = 240;
|
||||
lcd->lcd_info.height = 320;
|
||||
aiit_lcd->lcd_info.width = 240;
|
||||
aiit_lcd->lcd_info.height = 320;
|
||||
}
|
||||
|
||||
DrvLcdCmd(MEMORY_ACCESS_CTL);
|
||||
|
@ -265,12 +265,12 @@ void LcdShowChar(uint16 x,uint16 y,uint8 num,uint8 size,uint16 color,uint16 back
|
|||
|
||||
temp<<=1;
|
||||
y++;
|
||||
if(y>=lcd->lcd_info.height)
|
||||
if(y>=aiit_lcd->lcd_info.height)
|
||||
return;
|
||||
if ((y-y0) == size) {
|
||||
y=y0;
|
||||
x++;
|
||||
if(x>=lcd->lcd_info.width)
|
||||
if(x>=aiit_lcd->lcd_info.width)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
@ -305,29 +305,29 @@ void DrvLcdClear(uint16 color)
|
|||
{
|
||||
uint32 data = ((uint32)color << 16) | (uint32)color;
|
||||
|
||||
DrvLcdSetArea(0, 0, lcd->lcd_info.width - 1, lcd->lcd_info.height - 1);
|
||||
gpiohs_set_pin(lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
|
||||
spi_init_non_standard(lcd->spi_channel,
|
||||
DrvLcdSetArea(0, 0, aiit_lcd->lcd_info.width - 1, aiit_lcd->lcd_info.height - 1);
|
||||
gpiohs_set_pin(aiit_lcd->dc_pin, GPIO_PV_HIGH);
|
||||
spi_init(aiit_lcd->spi_channel, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
|
||||
spi_init_non_standard(aiit_lcd->spi_channel,
|
||||
0 /*instrction length*/,
|
||||
32 /*address length */,
|
||||
0 /*wait cycles */,
|
||||
SPI_AITM_AS_FRAME_FORMAT );
|
||||
spi_fill_data_dma(lcd->dma_channel, lcd->spi_channel, lcd->cs, (const uint32_t *)&data, lcd->lcd_info.width * lcd->lcd_info.height / 2);
|
||||
spi_fill_data_dma(aiit_lcd->dma_channel, aiit_lcd->spi_channel, aiit_lcd->cs, (const uint32_t *)&data, aiit_lcd->lcd_info.width * aiit_lcd->lcd_info.height / 2);
|
||||
}
|
||||
|
||||
static void DrvLcdRectUpdate(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height)
|
||||
{
|
||||
static uint16 * rect_buffer = NONE;
|
||||
if (!rect_buffer) {
|
||||
rect_buffer = x_malloc(lcd->lcd_info.height * lcd->lcd_info.width * (lcd->lcd_info.bits_per_pixel / 8));
|
||||
rect_buffer = x_malloc(aiit_lcd->lcd_info.height * aiit_lcd->lcd_info.width * (aiit_lcd->lcd_info.bits_per_pixel / 8));
|
||||
if (!rect_buffer) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (x1 == 0 && y1 == 0 && width == lcd->lcd_info.width && height == lcd->lcd_info.height) {
|
||||
if (x1 == 0 && y1 == 0 && width == aiit_lcd->lcd_info.width && height == aiit_lcd->lcd_info.height) {
|
||||
DrvLcdSetArea(x1, y1, x1 + width - 1, y1 + height - 1);
|
||||
DrvLcdDataWord((uint32 *)lcd->lcd_info.framebuffer, width * height / (lcd->lcd_info.bits_per_pixel / 8));
|
||||
DrvLcdDataWord((uint32 *)aiit_lcd->lcd_info.framebuffer, width * height / (aiit_lcd->lcd_info.bits_per_pixel / 8));
|
||||
} else {
|
||||
DrvLcdSetArea(x1, y1, x1 + width - 1, y1 + height - 1);
|
||||
DrvLcdDataWord((uint32 *)rect_buffer, width * height / 2);
|
||||
|
@ -337,13 +337,14 @@ static void DrvLcdRectUpdate(uint16_t x1, uint16_t y1, uint16_t width, uint16_t
|
|||
x_err_t DrvLcdInit(Lcd8080DeviceType dev)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
lcd = (Lcd8080DeviceType)dev;
|
||||
aiit_lcd = (Lcd8080DeviceType)dev;
|
||||
uint8 data = 0;
|
||||
|
||||
if (!lcd) {
|
||||
return ERROR;
|
||||
if (!aiit_lcd)
|
||||
{
|
||||
return -ERROR;
|
||||
}
|
||||
DrvLcdHwInit(lcd);
|
||||
DrvLcdHwInit(aiit_lcd);
|
||||
/* reset LCD */
|
||||
DrvLcdCmd(SOFTWARE_RESET);
|
||||
MdelayKTask(100);
|
||||
|
@ -360,8 +361,8 @@ x_err_t DrvLcdInit(Lcd8080DeviceType dev)
|
|||
/* set direction */
|
||||
DrvLcdSetDirection(DIR_YX_RLUD);
|
||||
|
||||
lcd->lcd_info.framebuffer = x_malloc(lcd->lcd_info.height * lcd->lcd_info.width * (lcd->lcd_info.bits_per_pixel / 8));
|
||||
CHECK(lcd->lcd_info.framebuffer);
|
||||
aiit_lcd->lcd_info.framebuffer = x_malloc(aiit_lcd->lcd_info.height * aiit_lcd->lcd_info.width * (aiit_lcd->lcd_info.bits_per_pixel / 8));
|
||||
CHECK(aiit_lcd->lcd_info.framebuffer);
|
||||
|
||||
/*display on*/
|
||||
DrvLcdCmd(DISPALY_ON);
|
||||
|
@ -369,18 +370,18 @@ x_err_t DrvLcdInit(Lcd8080DeviceType dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static x_err_t drv_lcd_control(Lcd8080DeviceType dev, int cmd, void *args)
|
||||
static uint32 drv_lcd_control(void* drv, struct BusConfigureInfo *configure_info)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
Lcd8080DeviceType lcd = (Lcd8080DeviceType)dev;
|
||||
x_base level;
|
||||
struct DeviceRectInfo* rect_info = (struct DeviceRectInfo*)args;
|
||||
struct LcdDriver *lcddrv = (struct LcdDriver *)drv;
|
||||
|
||||
NULL_PARAM_CHECK(dev);
|
||||
struct DeviceRectInfo* rect_info;
|
||||
NULL_PARAM_CHECK(drv);
|
||||
|
||||
switch (cmd)
|
||||
switch (configure_info->configure_cmd)
|
||||
{
|
||||
case GRAPHIC_CTRL_RECT_UPDATE:
|
||||
rect_info = (struct DeviceRectInfo*)configure_info->private_data;
|
||||
if(!rect_info)
|
||||
{
|
||||
SYS_ERR("GRAPHIC_CTRL_RECT_UPDATE error args");
|
||||
|
@ -400,7 +401,7 @@ static x_err_t drv_lcd_control(Lcd8080DeviceType dev, int cmd, void *args)
|
|||
break;
|
||||
|
||||
case GRAPHIC_CTRL_GET_INFO:
|
||||
*(struct DeviceLcdInfo *)args = lcd->lcd_info;
|
||||
*(struct DeviceLcdInfo *)configure_info->private_data = aiit_lcd->lcd_info;
|
||||
break;
|
||||
|
||||
case GRAPHIC_CTRL_SET_MODE:
|
||||
|
@ -410,7 +411,7 @@ static x_err_t drv_lcd_control(Lcd8080DeviceType dev, int cmd, void *args)
|
|||
ret = -ENONESYS;
|
||||
break;
|
||||
default:
|
||||
SYS_ERR("drv_lcd_control cmd: %d", cmd);
|
||||
SYS_ERR("drv_lcd_control cmd: %d", configure_info->configure_cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -456,20 +457,33 @@ void HandTest(unsigned short *x_pos, unsigned short *y_pos)
|
|||
static uint32 LcdWrite(void *dev, struct BusBlockWriteParam *write_param)
|
||||
{
|
||||
if (write_param == NONE) {
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
LcdStringParam * show = (LcdStringParam *)write_param->buffer;
|
||||
|
||||
if (0==write_param->pos) { //output string
|
||||
LcdShowString(show->x_pos,show->y_pos,show->width,show->height,show->font_size,show->addr,show->font_color,show->back_color);
|
||||
return EOK;
|
||||
} else if (1==write_param->pos) { //output dot
|
||||
DrvLcdSetPixel(show->x_pos, show->y_pos, show->font_color);
|
||||
return EOK;
|
||||
} else {
|
||||
return ERROR;
|
||||
LcdWriteParam * show = (LcdWriteParam *)write_param->buffer;
|
||||
KPrintf("DEBUG TYPE %d X:%d Y:%d color %d\n",show->pixel_info.x_pos, show->pixel_info.y_pos, show->pixel_info.pixel_color);
|
||||
if(0 == show->type) //output string
|
||||
{
|
||||
LcdShowString(show->string_info.x_pos,show->string_info.y_pos,show->string_info.width,show->string_info.height,show->string_info.font_size,show->string_info.addr,show->string_info.font_color,show->string_info.back_color);
|
||||
return EOK;
|
||||
}
|
||||
else if(1 == show->type) //output dot
|
||||
{
|
||||
DrvLcdSetPixel(show->pixel_info.x_pos, show->pixel_info.y_pos, show->pixel_info.pixel_color);
|
||||
return EOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ERROR;
|
||||
}
|
||||
// if (0==write_param->pos) { //output string
|
||||
// LcdShowString(show->x_pos,show->y_pos,show->width,show->height,show->font_size,show->addr,show->font_color,show->back_color);
|
||||
// return EOK;
|
||||
// } else if (1==write_param->pos) { //output dot
|
||||
// DrvLcdSetPixel(show->x_pos, show->y_pos, show->font_color);
|
||||
// return EOK;
|
||||
// } else {
|
||||
// return -ERROR;
|
||||
// }
|
||||
}
|
||||
|
||||
uint32 DrvLcdClearDone(void * dev, struct BusConfigureInfo *configure_info)
|
||||
|
@ -488,55 +502,49 @@ const struct LcdDevDone lcd_dev_done =
|
|||
.read = NONE
|
||||
};
|
||||
|
||||
static int BoardLcdBusInit(struct LcdBus * lcd_bus, struct LcdDriver * lcd_driver)
|
||||
static int BoardLcdBusInit(struct LcdBus * lcd_bus, struct LcdDriver * lcd_driver,const char *bus_name, const char *drv_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
/*Init the lcd bus */
|
||||
ret = LcdBusInit( lcd_bus, LCD_BUS_NAME_1);
|
||||
ret = LcdBusInit( lcd_bus, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Board_lcd_init LcdBusInit error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
lcd_driver->configure = DrvLcdClearDone;
|
||||
/*Init the lcd driver*/
|
||||
ret = LcdDriverInit( lcd_driver, LCD_DRV_NAME_1);
|
||||
ret = LcdDriverInit( lcd_driver, drv_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Board_LCD_init LcdDriverInit error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
/*Attach the lcd driver to the lcd bus*/
|
||||
ret = LcdDriverAttachToBus(LCD_DRV_NAME_1, LCD_BUS_NAME_1);
|
||||
ret = LcdDriverAttachToBus(drv_name, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Board_LCD_init LcdDriverAttachToBus error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Attach the lcd device to the lcd bus*/
|
||||
static int BoardLcdDevBend(void)
|
||||
static int BoardLcdDevBend(struct LcdHardwareDevice *lcd_device, void *param, const char *bus_name, const char *dev_name)
|
||||
{
|
||||
x_err_t ret = EOK;
|
||||
|
||||
static struct LcdHardwareDevice lcd_device;
|
||||
memset(&lcd_device, 0, sizeof(struct LcdHardwareDevice));
|
||||
|
||||
lcd_device.dev_done = &(lcd_dev_done);
|
||||
|
||||
ret = LcdDeviceRegister(&lcd_device, NONE, LCD_1_DEVICE_NAME_0);
|
||||
ret = LcdDeviceRegister(lcd_device, NONE, dev_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Board_LCD_init LcdDeviceInit device %s error %d\n", LCD_1_DEVICE_NAME_0, ret);
|
||||
return ERROR;
|
||||
KPrintf("Board_LCD_init LcdDeviceInit device %s error %d\n", dev_name, ret);
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
ret = LcdDeviceAttachToBus(LCD_1_DEVICE_NAME_0, LCD_BUS_NAME_1);
|
||||
ret = LcdDeviceAttachToBus(dev_name, bus_name);
|
||||
if (EOK != ret) {
|
||||
KPrintf("Board_LCD_init LcdDeviceAttachToBus device %s error %d\n", LCD_1_DEVICE_NAME_0, ret);
|
||||
return ERROR;
|
||||
KPrintf("Board_LCD_init LcdDeviceAttachToBus device %s error %d\n", dev_name, ret);
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -549,44 +557,59 @@ int HwLcdInit(void)
|
|||
static struct LcdDriver lcd_driver;
|
||||
memset(&lcd_driver, 0, sizeof(struct LcdDriver));
|
||||
|
||||
Lcd8080DeviceType lcd_dev = (Lcd8080DeviceType )malloc(sizeof( struct Lcd8080Device));
|
||||
memset(lcd_dev, 0, sizeof(struct Lcd8080Device));
|
||||
|
||||
if (!lcd_dev) {
|
||||
return -1;
|
||||
Lcd8080DeviceType lcd_dev = (Lcd8080DeviceType )x_malloc(sizeof( struct Lcd8080Device));
|
||||
if (!lcd_dev)
|
||||
{
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
FpioaSetFunction(41,FUNC_GPIOHS9); //DC order / data
|
||||
FpioaSetFunction(47,FUNC_GPIOHS10); //BL
|
||||
FpioaSetFunction(40,FUNC_SPI0_SS0); //chip select
|
||||
FpioaSetFunction(38,FUNC_SPI0_SCLK); //clk
|
||||
memset(lcd_dev, 0, sizeof(struct Lcd8080Device));
|
||||
|
||||
lcd_dev->cs = SPI_CHIP_SELECT_0;
|
||||
lcd_dev->dc_pin = 9;
|
||||
lcd_dev->dma_channel = DMAC_CHANNEL0;
|
||||
lcd_dev->spi_channel = SPI_DEVICE_0;
|
||||
lcd_dev->lcd_info.bits_per_pixel = 16;
|
||||
lcd_dev->lcd_info.pixel_format = PIXEL_FORMAT_BGR565;
|
||||
FpioaSetFunction(BSP_LCD_DC_PIN, FUNC_GPIOHS9); //DC order/data
|
||||
FpioaSetFunction(BSP_LCD_BL_PIN, FUNC_GPIOHS10); //BL
|
||||
FpioaSetFunction(BSP_LCD_CS_PIN, FUNC_SPI0_SS0); //chip select
|
||||
FpioaSetFunction(BSP_LCD_WR_PIN, FUNC_SPI0_SCLK); //clk
|
||||
|
||||
lcd_dev->cs = SPI_CHIP_SELECT_0;
|
||||
lcd_dev->dc_pin = 9;
|
||||
lcd_dev->dma_channel = DMAC_CHANNEL0;
|
||||
lcd_dev->spi_channel = SPI_DEVICE_0;
|
||||
lcd_dev->lcd_info.bits_per_pixel = 16;
|
||||
lcd_dev->lcd_info.pixel_format = PIXEL_FORMAT_BGR565;
|
||||
|
||||
sysctl_set_power_mode(SYSCTL_POWER_BANK6, SYSCTL_POWER_V18);
|
||||
sysctl_set_power_mode(SYSCTL_POWER_BANK7, SYSCTL_POWER_V18);
|
||||
|
||||
sysctl_set_spi0_dvp_data(1); //open the lcd interface with spi0
|
||||
ret = BoardLcdBusInit(&lcd_dev->lcd_bus, &lcd_driver); //init lcd bus
|
||||
if (EOK != ret) {
|
||||
sysctl_set_spi0_dvp_data(1); //open the lcd interface with spi0
|
||||
|
||||
lcd_driver.configure = &drv_lcd_control;
|
||||
|
||||
ret = BoardLcdBusInit(&lcd_dev->lcd_bus, &lcd_driver, LCD_BUS_NAME, LCD_DRV_NAME); //init lcd bus
|
||||
if (EOK != ret)
|
||||
{
|
||||
KPrintf("Board_lcd_Init error ret %u\n", ret);
|
||||
return ERROR;
|
||||
x_free(lcd_dev);
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
ret = BoardLcdDevBend(); //init lcd device
|
||||
if (EOK != ret) {
|
||||
static struct LcdHardwareDevice lcd_device;
|
||||
memset(&lcd_device, 0, sizeof(struct LcdHardwareDevice));
|
||||
|
||||
lcd_device.dev_done = &(lcd_dev_done);
|
||||
|
||||
ret = BoardLcdDevBend(&lcd_device, NONE, LCD_BUS_NAME, LCD_DEVICE_NAME); //init lcd device
|
||||
if (EOK != ret)
|
||||
{
|
||||
KPrintf("BoardLcdDevBend error ret %u\n", ret);
|
||||
return ERROR;
|
||||
x_free(lcd_dev);
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
gpiohs_set_drive_mode(10, GPIO_DM_OUTPUT);
|
||||
gpiohs_set_pin(10, GPIO_PV_HIGH);
|
||||
gpiohs_set_pin(10, GPIO_PV_HIGH);
|
||||
|
||||
KPrintf("LCD driver inited ...\r\n");
|
||||
|
||||
DrvLcdInit(lcd_dev);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -303,13 +303,13 @@ int HwGpioInit(void)
|
|||
ret = PinDriverInit(&drv, PIN_DRIVER_NAME, NONE);
|
||||
if (ret != EOK) {
|
||||
KPrintf("pin driver init error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
ret = PinDriverAttachToBus(PIN_DRIVER_NAME, PIN_BUS_NAME);
|
||||
if (ret != EOK) {
|
||||
KPrintf("pin driver attach error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
static struct PinHardwareDevice dev;
|
||||
|
@ -318,13 +318,13 @@ int HwGpioInit(void)
|
|||
ret = PinDeviceRegister(&dev, NONE, PIN_DEVICE_NAME);
|
||||
if (ret != EOK) {
|
||||
KPrintf("pin device register error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
ret = PinDeviceAttachToBus(PIN_DEVICE_NAME, PIN_BUS_NAME);
|
||||
if (ret != EOK) {
|
||||
KPrintf("pin device register error %d\n", ret);
|
||||
return ERROR;
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -93,7 +93,7 @@ int EnableLcd(const char *bus_name, const char *driver_name, const char *device_
|
|||
*/
|
||||
void TestLcd(void)
|
||||
{
|
||||
EnableLcd(LCD_BUS_NAME_1,LCD_DRV_NAME_1,LCD_1_DEVICE_NAME_0);
|
||||
EnableLcd(LCD_BUS_NAME,LCD_DRV_NAME,LCD_DEVICE_NAME);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),TestLcd, TestLcd, Test LCD );
|
||||
|
|
|
@ -239,6 +239,12 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/knowing/tensorflow
|
|||
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/third_party/ruy #
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_LV),y)
|
||||
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lvgl_new #
|
||||
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/lib/lvgl_new/examples/porting #
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CRYPTO), y)
|
||||
KERNELPATHS += -I$(KERNEL_ROOT)/framework/security/crypto/include #
|
||||
endif
|
||||
|
|
|
@ -63,6 +63,20 @@ typedef struct
|
|||
uint16 back_color;
|
||||
}LcdStringParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 x_pos;
|
||||
uint16 y_pos;
|
||||
uint16 pixel_color;
|
||||
}LcdPixelParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char type;
|
||||
LcdStringParam string_info;
|
||||
LcdPixelParam pixel_info;
|
||||
}LcdWriteParam;
|
||||
|
||||
struct LcdDevDone
|
||||
{
|
||||
uint32 (*open) (void *dev);
|
||||
|
|
Loading…
Reference in New Issue