This commit is contained in:
Wang_Weigen
2022-01-05 15:23:12 +08:00
parent 36f2ebbf95
commit 37c247f4d7
20 changed files with 360 additions and 126 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -0,0 +1,3 @@
SRC_FILES := lv_demo.c lv_demo_calendar.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -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 );

View File

@@ -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);
}

View File

@@ -0,0 +1,6 @@
#ifndef __LV_DEMO_CALENDAR_H__
#define __LV_DEMO_CALENDAR_H__
void lv_demo_calendar(void);
#endif

View File

@@ -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;
}