赞
踩
LVGL库实现的简单实时时钟表盘示例代码:
- #include "lvgl.h"
- #include <time.h>
-
- static lv_obj_t * screen;
- static lv_obj_t * label_time;
- static lv_obj_t * label_date;
-
- void create_time_label(void)
- {
- // 创建时间标签
- label_time = lv_label_create(screen, NULL);
- lv_obj_align(label_time, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
- lv_label_set_text(label_time, "00:00");
- lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
- lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_roboto_28);
-
- // 创建日期标签
- label_date = lv_label_create(screen, NULL);
- lv_obj_align(label_date, NULL, LV_ALIGN_IN_TOP_MID, 0, 60);
- lv_label_set_text(label_date, "1 January");
- lv_label_set_align(label_date, LV_LABEL_ALIGN_CENTER);
- lv_obj_set_style_local_text_font(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_roboto_16);
- }
-
- void update_time_label(time_t t)
- {
- // 更新时间标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。