未验证 提交 093b40ad 编写于 作者: G guo 提交者: GitHub

Merge pull request #5217 from mysterywolf/l475

...@@ -12,5 +12,6 @@ ...@@ -12,5 +12,6 @@
#define LV_CONF_H #define LV_CONF_H
#define LV_COLOR_16_SWAP 1 #define LV_COLOR_16_SWAP 1
#define LV_USE_PERF_MONITOR 1
#endif #endif
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#define DBG_TAG "LVGL" #define DBG_TAG "LVGL"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
#include <drv_lcd.h>
#include <lv_port_indev.h> #include <lv_port_indev.h>
#ifndef LV_THREAD_STACK_SIZE #ifndef LV_THREAD_STACK_SIZE
...@@ -23,34 +23,59 @@ ...@@ -23,34 +23,59 @@
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3) #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
#endif #endif
static void btn_event_cb(lv_event_t * e) static void event_handler(lv_event_t * e)
{ {
lv_event_code_t code = lv_event_get_code(e); lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * btn = lv_event_get_target(e); lv_obj_t * obj = lv_event_get_target(e);
if(code == LV_EVENT_CLICKED) {
static uint8_t cnt = 0; if(code == LV_EVENT_VALUE_CHANGED) {
cnt++; lv_calendar_date_t date;
if(lv_calendar_get_pressed_date(obj, &date)) {
/*Get the first child of the button which is the label and change its text*/ LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
lv_obj_t * label = lv_obj_get_child(btn, 0); }
lv_label_set_text_fmt(label, "WK_UP: %d", cnt);
} }
} }
void lv_example_calendar_1(void)
{
lv_obj_t * calendar = lv_calendar_create(lv_scr_act());
lv_obj_set_size(calendar, LCD_W, LCD_H);
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 60);
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(lv_scr_act(), calendar);
#elif LV_USE_CALENDAR_HEADER_ARROW
lv_calendar_header_arrow_create(lv_scr_act(), calendar, 25);
#endif
}
static void lvgl_thread(void *parameter) static void lvgl_thread(void *parameter)
{ {
/*assign buttons to coordinates*/ /*assign buttons to coordinates*/
const lv_point_t points_array[] = {{0,0},{0,0},{0,0},{70,35}}; const lv_point_t points_array[] = {{200,35},{0,0},{70,35},{0,0}};
lv_indev_set_button_points(button_indev, points_array); lv_indev_set_button_points(button_indev, points_array);
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/ lv_example_calendar_1();
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "WK_UP: 0"); /*Set the labels text*/
lv_obj_center(label);
while(1) while(1)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册