LVGL 8.2 meter控件实现模拟时钟
模拟 实现 控件 时钟 LVGL 8.2
2023-09-14 09:06:41 时间
动画回调函数
static lv_obj_t* meter;
static void set_value(void* indic, int32_t v)
{
lv_meter_set_indicator_end_value(meter, indic, v); // 设置分针值
}
static void set_hour_value(void* indic, int32_t v)
{
if (v == 0)
v = 12;
lv_meter_set_indicator_end_value(meter, indic, v); // 设置时针值
}
clock from a meter
static void lv_example_meter_3(void)
{
meter = lv_meter_create(lv_scr_act());
lv_obj_set_size(meter, 220, 220);
lv_obj_center(meter);
lv_obj_remove_style(meter, NULL, LV_PART_TICKS);
lv_obj_remove_style(meter, NULL, LV_PART_ITEMS);
/*Create a scale for the minutes*/
/*61 ticks in a 360 degrees range (the last and the first line overlaps)*/
lv_meter_scale_t* scale_min = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale_min, 61, 1, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_range(meter, scale_min, 0, 60, 360, 270);
/*Create another scale for the hours. It's only visual and contains only major ticks*/
lv_meter_scale_t* scale_hour = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale_hour, 12, 0, 0, lv_palette_main(LV_PALETTE_GREY)); /*12 ticks*/
lv_meter_set_scale_major_ticks(meter, scale_hour, 1, 2, 20, lv_color_black(), 10); /*Every tick is major*/
lv_meter_set_scale_range(meter, scale_hour, 1, 12, 330, 300); /*[1..12] values in an almost full circle*/
LV_IMG_DECLARE(img_hand) // 表针图片资源声明
/*Add a the hands from images*/
lv_meter_indicator_t* indic_min = lv_meter_add_needle_img(meter, scale_min, &img_hand, 5, 5); //
lv_meter_indicator_t* indic_hour = lv_meter_add_needle_img(meter, scale_hour, &img_hand, 5, 5);
/*Create an animation to set the value*/
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, set_value);
lv_anim_set_values(&a, 0, 60);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_time(&a, 2000); /*2 sec for 1 turn of the minute hand (1 hour)*/
lv_anim_set_var(&a, indic_min);
lv_anim_start(&a);
lv_anim_t a1;
lv_anim_init(&a1);
lv_anim_set_exec_cb(&a1, set_hour_value);
lv_anim_set_repeat_count(&a1, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_var(&a1, indic_hour);
lv_anim_set_time(&a1, 24000); /*24 sec for 1 turn of the hour hand*/
lv_anim_set_values(&a1, 0, 12);
lv_anim_start(&a1);
}
运行效果
相关文章
- 操作系统实验一进程调度算法模拟_常用的进程调度算法有
- 隔空点你的手机!新攻击装置可向屏幕发送电磁脉冲,模拟手指点击
- Java 多线程模拟卖票
- ext4 io hung模拟脚本
- Golang模拟实现连接池
- 蓝桥杯省模拟赛第十题(淹没城堡)
- PYTHON 用几何布朗运动模型和蒙特卡罗MONTE CARLO随机过程模拟股票价格可视化分析耐克NKE股价时间序列数据|附代码数据
- 字符串常见函数介绍及模拟实现
- 华为实验 | ENSP模拟VXLAN EVPN分布式网关
- qsort 函数的使用及其模拟实现
- C++STL——list类与模拟实现
- 模拟实现C++中的string类(详细解析)
- 字符函数和字符串函数的使用及模拟实现(上)
- 【C++】string的模拟实现
- Jedis操作Redis实现模拟验证码发送功能
- NSCondition模拟买票的过程的简单实现详解手机开发
- Spark项目之电商用户行为分析大数据平台之(十二)Spark上下文构建及模拟数据生成详解大数据
- HtmlUnit模拟页面提交一个form详解编程语言
- Java 模拟鼠标事件详解编程语言
- C# 实现QQ群成员列表导出及邮件群发之模拟QQ登陆
- PostHttpPage用asp是实现模拟登录效果的代码
- JS模拟面向对象全解(二、类型与赋值)
- js模拟权限选择实现代码(select操作)
- jQuery数据缓存功能的实现思路及简单模拟
- LinkedList学习示例模拟堆栈与队列数据结构
- nodejs实现模拟form表单上传文件