赞
踩
目录
① LV_PART_MAIN: 主体背景;
② LV_PART_TICK:仪表的刻度;
③ LV_PART_INDICATOR:仪表指针;
④ LV_PART_ITEMS:圆弧。
lv_meter_scale_t *lv_meter_add_scale(lv_obj_t *obj)
- void lv_meter_set_scale_ticks(lv_obj_t *obj, lv_meter_scale_t *scale,
- uint16_t cnt, uint16_t width,
- uint16_t len, lv_color_t color);
- void lv_meter_set_scale_major_ticks(lv_obj_t *obj, lv_meter_scale_t *scale,
- uint16_t nth, uint16_t width, uint16_t len,
- lv_color_t color, int16_t label_gap);
- lv_meter_indicator_t *lv_meter_add_needle_line(lv_obj_t *obj,
- lv_meter_scale_t *scale,
- uint16_t width,
- lv_color_t color,
- int16_t r_mod);
- void lv_meter_set_indicator_value( lv_obj_t * obj,
- lv_meter_indicator_t * indic,
- int32_t value);
- void lv_meter_set_scale_range(lv_obj_t * obj,
- lv_meter_scale_t * scale,
- int32_t min, int32_t max,
- uint32_t angle_range, uint32_t rotation);
- //时钟
- meter = lv_meter_create(ui_HomePage); //定义并创建仪表
- lv_obj_set_size(meter, 180, 180); //设置仪表宽度高度
- lv_obj_set_x(meter, 30);
- lv_obj_set_y(meter, 95);
- lv_meter_scale_t* scale_min = lv_meter_add_scale(meter);
- lv_meter_set_scale_ticks(meter, scale_min, 61, 1, 5, lv_palette_main(LV_PALETTE_GREY));
- lv_meter_set_scale_range(meter, scale_min, 0, 60, 360, 270);
- lv_meter_scale_t* scale_hour = lv_meter_add_scale(meter); //定义并添加刻度
- lv_meter_set_scale_ticks(meter, scale_hour, 12, 1, 1, lv_palette_main(LV_PALETTE_GREY)); //设置小刻度
- lv_meter_set_scale_major_ticks(meter, scale_hour, 1, 2, 10, lv_color_black(), 10); //设置主刻度
- lv_meter_set_scale_range(meter, scale_hour, 1, 12, 330, 300);
- lv_meter_indicator_t* indic_hour;
- indic_hour = lv_meter_add_needle_line(meter, scale_hour, 6,lv_palette_main(LV_PALETTE_BLUE), -30); //添加仪表指针,该指针宽度为 4,颜色为灰色,长度-10
- lv_meter_set_indicator_value(meter, indic_hour,11); //设置指针指向的数值
- lv_meter_indicator_t* indic_min;
- indic_min = lv_meter_add_needle_line(meter, scale_min, 3,lv_palette_main(LV_PALETTE_RED), -10);
- lv_meter_set_indicator_value(meter, indic_min,59);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。