51 static time_t unix_time;
52 static struct tm *time_info;
53 unix_time = time(NULL);
54 time_info = localtime(&unix_time);
55 uint32_t year = time_info->tm_year + 1900;
56 uint32_t month = time_info->tm_mon + 1;
57 uint32_t day = time_info->tm_mday;
58 printf(
"year:%d,month:%d,day:%d\n", year, month, day);
59 lv_obj_t *calendar_obj=(lv_obj_t *)(timer->user_data);
60 lv_calendar_set_today_date(calendar_obj, year, month, day);
61 lv_calendar_set_showed_date(calendar_obj, year, month);
71 static time_t unix_time;
72 static struct tm *time_info;
73 unix_time = time(NULL);
74 time_info = localtime(&unix_time);
75 uint32_t year = time_info->tm_year + 1900;
76 uint32_t month = time_info->tm_mon + 1;
77 uint32_t day = time_info->tm_mday;
78 printf(
"year:%d,month:%d,day:%d\n", year, month, day);
85 lv_obj_t *calendar_obj = lv_calendar_create(
Calender_OBJ);
86 static lv_style_t style_rect_back;
87 lv_style_init(&style_rect_back);
88 lv_style_set_bg_color(&style_rect_back, lv_color_hex(0xf0e6e8));
93 lv_calendar_set_today_date(calendar_obj, year, month, day);
94 lv_calendar_set_showed_date(calendar_obj, year, month);
95 lv_calendar_header_dropdown_create(calendar_obj);
98 static lv_style_t style_rect;
100 lv_color_t c = lv_color_hex(0xb4848c);
101 lv_style_init(&style_rect);
102 lv_style_set_bg_color(&style_rect, c);
104 lv_style_set_height(&style_rect,
ver_res);
105 lv_style_set_radius(&style_rect, 0);
107 lv_style_set_shadow_width(&style_rect, 25);
108 lv_style_set_shadow_ofs_x(&style_rect, -3);
110 lv_style_set_border_width(&style_rect, 0);
112 lv_obj_align(rect, LV_ALIGN_TOP_RIGHT, 0, 0);
113 lv_obj_add_style(rect, &style_rect, 0);
115 lv_obj_t *home_img_btn = lv_imgbtn_create(
Calender_OBJ);
117 lv_imgbtn_set_src(home_img_btn, LV_IMGBTN_STATE_RELEASED, &
home, NULL, NULL);
119 lv_obj_align(home_img_btn, LV_ALIGN_TOP_RIGHT, -1 *
rect_width / 2.0 + 64 / 2,
ver_res / 2.0 - 64 / 2);
120 lv_obj_set_size(home_img_btn, 64, 64);
static lv_coord_t ver_res
static void clock_calender_task_callback(lv_timer_t *timer)
时钟定时触发回调
static lv_coord_t hor_res
static lv_coord_t rect_width
static void home_img_clicked_callback(lv_event_t *e)
主页按键触发回调