diff --git a/APP_Framework/Applications/Makefile b/APP_Framework/Applications/Makefile index af2f86d2c..97257c9dc 100644 --- a/APP_Framework/Applications/Makefile +++ b/APP_Framework/Applications/Makefile @@ -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 diff --git a/APP_Framework/Applications/framework_init.c b/APP_Framework/Applications/framework_init.c index 603af2fac..f618df6af 100644 --- a/APP_Framework/Applications/framework_init.c +++ b/APP_Framework/Applications/framework_init.c @@ -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; } \ No newline at end of file diff --git a/APP_Framework/Applications/lv_app/Makefile b/APP_Framework/Applications/lv_app/Makefile new file mode 100644 index 000000000..0efc4bd16 --- /dev/null +++ b/APP_Framework/Applications/lv_app/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := lv_demo.c lv_demo_calendar.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/lv_app/lv_demo.c b/APP_Framework/Applications/lv_app/lv_demo.c new file mode 100644 index 000000000..538a61ca4 --- /dev/null +++ b/APP_Framework/Applications/lv_app/lv_demo.c @@ -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 +#include +#include "lv_demo_calendar.h" +#include + +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 ); + diff --git a/APP_Framework/Applications/lv_app/lv_demo_calendar.c b/APP_Framework/Applications/lv_app/lv_demo_calendar.c new file mode 100644 index 000000000..de1a68e9f --- /dev/null +++ b/APP_Framework/Applications/lv_app/lv_demo_calendar.c @@ -0,0 +1,50 @@ +#include +#include "lv_demo_calendar.h" +// #include + +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); +} diff --git a/APP_Framework/Applications/lv_app/lv_demo_calendar.h b/APP_Framework/Applications/lv_app/lv_demo_calendar.h new file mode 100644 index 000000000..b8a7772f2 --- /dev/null +++ b/APP_Framework/Applications/lv_app/lv_demo_calendar.h @@ -0,0 +1,6 @@ +#ifndef __LV_DEMO_CALENDAR_H__ +#define __LV_DEMO_CALENDAR_H__ + +void lv_demo_calendar(void); + +#endif diff --git a/APP_Framework/Applications/lv_init.c b/APP_Framework/Applications/lv_init.c new file mode 100644 index 000000000..3ff01dddc --- /dev/null +++ b/APP_Framework/Applications/lv_init.c @@ -0,0 +1,38 @@ +#include +#define DBG_TAG "LVGL" +#define DBG_LVL DBG_INFO + +#ifndef PKG_USING_LVGL_DISP_DEVICE +#include +#endif + +#ifndef PKG_USING_LVGL_INDEV_DEVICE +#include +#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; +} + diff --git a/APP_Framework/Framework/transform_layer/xiuos/transform.c b/APP_Framework/Framework/transform_layer/xiuos/transform.c index e80102a65..36d7c3181 100644 --- a/APP_Framework/Framework/transform_layer/xiuos/transform.c +++ b/APP_Framework/Framework/transform_layer/xiuos/transform.c @@ -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; } diff --git a/APP_Framework/Framework/transform_layer/xiuos/transform.h b/APP_Framework/Framework/transform_layer/xiuos/transform.h index b2996fd44..1e50350d5 100644 --- a/APP_Framework/Framework/transform_layer/xiuos/transform.h +++ b/APP_Framework/Framework/transform_layer/xiuos/transform.h @@ -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); diff --git a/APP_Framework/lib/Kconfig b/APP_Framework/lib/Kconfig index f92cf7cfd..cc9317522 100755 --- a/APP_Framework/lib/Kconfig +++ b/APP_Framework/lib/Kconfig @@ -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 diff --git a/APP_Framework/lib/Makefile b/APP_Framework/lib/Makefile index ec6061b73..3e8e31a84 100644 --- a/APP_Framework/lib/Makefile +++ b/APP_Framework/lib/Makefile @@ -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 diff --git a/APP_Framework/lib/lvgl b/APP_Framework/lib/lvgl new file mode 160000 index 000000000..d38eb1e68 --- /dev/null +++ b/APP_Framework/lib/lvgl @@ -0,0 +1 @@ +Subproject commit d38eb1e689fa5a64c25e677275172d9c8a4ab2f0 diff --git a/Ubiquitous/Nuttx/apps/graphics/lvgl/lv_conf.h b/Ubiquitous/Nuttx/apps/graphics/lvgl/lv_conf.h index 3ea42c8aa..2f584c0cc 100644 --- a/Ubiquitous/Nuttx/apps/graphics/lvgl/lv_conf.h +++ b/Ubiquitous/Nuttx/apps/graphics/lvgl/lv_conf.h @@ -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) */ diff --git a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/include/graphic.h b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/include/graphic.h index cbc4e2bcd..aa02acac9 100644 --- a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/include/graphic.h +++ b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/include/graphic.h @@ -32,11 +32,11 @@ Modification: add aiit-riscv64-board lcd configure and operation function #include #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 { diff --git a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/Kconfig b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/Kconfig index f29f599eb..f058a8bb1 100644 --- a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/Kconfig +++ b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/Kconfig @@ -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 diff --git a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/connect_lcd.c b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/connect_lcd.c index f96b11cd5..25e109d11 100644 --- a/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/connect_lcd.c +++ b/Ubiquitous/XiUOS/board/aiit-riscv64-board/third_party_driver/lcd/connect_lcd.c @@ -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; diff --git a/Ubiquitous/XiUOS/board/kd233/third_party_driver/gpio/connect_gpio.c b/Ubiquitous/XiUOS/board/kd233/third_party_driver/gpio/connect_gpio.c index 23fd3222e..475e13a88 100644 --- a/Ubiquitous/XiUOS/board/kd233/third_party_driver/gpio/connect_gpio.c +++ b/Ubiquitous/XiUOS/board/kd233/third_party_driver/gpio/connect_gpio.c @@ -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; diff --git a/Ubiquitous/XiUOS/kernel/kernel_test/test_lcd.c b/Ubiquitous/XiUOS/kernel/kernel_test/test_lcd.c index cc4088c0d..4932c703a 100644 --- a/Ubiquitous/XiUOS/kernel/kernel_test/test_lcd.c +++ b/Ubiquitous/XiUOS/kernel/kernel_test/test_lcd.c @@ -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 ); diff --git a/Ubiquitous/XiUOS/path_kernel.mk b/Ubiquitous/XiUOS/path_kernel.mk index b8ab6d15c..1c6ddad5a 100755 --- a/Ubiquitous/XiUOS/path_kernel.mk +++ b/Ubiquitous/XiUOS/path_kernel.mk @@ -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 diff --git a/Ubiquitous/XiUOS/resources/include/dev_lcd.h b/Ubiquitous/XiUOS/resources/include/dev_lcd.h index fe967a633..7cf9380d2 100644 --- a/Ubiquitous/XiUOS/resources/include/dev_lcd.h +++ b/Ubiquitous/XiUOS/resources/include/dev_lcd.h @@ -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);