仪表 (lv_meter)¶
概述¶
仪表小部件可以以非常灵活的方式可视化数据。它可以显示弧线、指针、刻度线和标签。
部件和样式¶
LV_PART_MAIN仪表的背景。使用典型的背景属性。LV_PART_TICK刻度线和标签,使用 line 和 text 样式属性。LV_PART_INDICATOR指针线或图像,使用 line 和 img 样式属性,以及背景属性在指针的枢轴上绘制一个方形(或圆形)。填充使方形更大。LV_PART_ITEMS弧线,使用 arc 属性。
用法¶
添加刻度¶
首先需要使用 lv_meter_scale_t * scale = lv_meter_add_scale(meter) 向仪表添加一个刻度。
刻度有次要和主要刻度线,以及主要刻度线上的标签。稍后可以向仪表添加指针(指针、弧线、刻度修改器)。
可以向仪表添加任意数量的刻度。
次要刻度线可以通过以下方式配置:lv_meter_set_scale_ticks(meter, scale, tick_count, line_width, tick_length, tick_color)。
要添加主要刻度线,请使用 lv_meter_set_scale_major_ticks(meter, scale, nth_major, tick_width, tick_length, tick_color, label_gap)。nth_major 指定跳过多少个次要刻度以绘制一个主要刻度。
标签会自动添加到主要刻度上,距离刻度 label_gap,文本与刻度线的值成比例。
lv_meter_set_scale_range(meter, scale, min, max, angle_range, rotation) 设置刻度的值和角度范围。
添加指针¶
指针需要添加到刻度上,其值在刻度范围内解释。
所有添加指针的函数返回 lv_meter_indicator_t *。
指针线¶
indic = lv_meter_add_needle_line(meter, scale, line_width, line_color, r_mod) 向刻度添加指针线。默认情况下,线的长度与刻度的半径相同,但 r_mod 会更改长度。
lv_meter_set_indicator_value(meter, indic, value) 设置指针的值。
指针图像¶
indic = lv_meter_add_needle_img(meter, scale, img_src, pivot_x, pivot_y) 设置一个图像作为指针。img_src 应该是一个指向右侧的指针,例如 -O--->。
pivot_x 和 pivot_y 设置相对于图像左上角的旋转枢轴点。
lv_meter_set_indicator_value(meter, indicator, value) 设置指针的值。
弧线¶
indic = lv_meter_add_arc(meter, scale, arc_width, arc_color, r_mod) 添加弧线指针。默认情况下,弧线的半径与刻度的半径相同,但 r_mod 会更改半径。
lv_meter_set_indicator_start_value(meter, indic, value) 和 lv_meter_set_indicator_end_value(meter, indicator, value) 设置指针的值。
刻度线(ticks)¶
indic = lv_meter_add_scale_lines(meter, scale, color_start, color_end, local, width_mod) 添加一个修改刻度线的指针。
如果 local 为 true,刻度线的颜色将在指针的起始值和结束值范围内从 color_start 渐变到 color_end。
如果 local 为 false,color_start 和 color_end 将映射到刻度的起始值和结束值,并且只有该颜色渐变的“切片”将在指针的起始值和结束值范围内可见。
width_mod 修改刻度线的宽度。
lv_meter_set_indicator_start_value(meter, indicator, value) 和 lv_meter_set_indicator_end_value(meter, indicator, value) 设置指针的值。
事件¶
LV_EVENT_DRAW_PART_BEGIN和LV_EVENT_DRAW_PART_END会针对以下类型发送:LV_METER_DRAW_PART_ARC弧线指针part:LV_PART_ITEMSsub_part_ptr: 指向指针的指针arc_dscradius: 弧线的半径p1弧线的中心
LV_METER_DRAW_PART_NEEDLE_LINE指针线part:LV_PART_ITEMSp1,p2线的点line_dscsub_part_ptr: 指向指针的指针
LV_METER_DRAW_PART_NEEDLE_IMG指针图像part:LV_PART_ITEMSp1,p2线的点img_dscsub_part_ptr: 指向指针的指针
LV_METER_DRAW_PART_TICK刻度线和标签part:LV_PART_TICKSvalue: 线的值text:value转换为十进制或次要线上的NULLlabel_dsc: 标签绘制描述符或次要线上的NULLline_dscid: 线的索引
也可以查看 基础对象 的事件。
了解更多关于事件的信息。
示例¶
Simple meter¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_METER && LV_BUILD_EXAMPLES
static lv_obj_t * meter;
static void set_value(void * indic, int32_t v)
{
lv_meter_set_indicator_value(meter, indic, v);
}
/**
* A simple meter
*/
void lv_example_meter_1(void)
{
meter = lv_meter_create(lv_scr_act());
lv_obj_center(meter);
lv_obj_set_size(meter, 200, 200);
/*Add a scale first*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 41, 2, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(meter, scale, 8, 4, 15, lv_color_black(), 10);
lv_meter_indicator_t * indic;
/*Add a blue arc to the start*/
indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_BLUE), 0);
lv_meter_set_indicator_start_value(meter, indic, 0);
lv_meter_set_indicator_end_value(meter, indic, 20);
/*Make the tick lines blue at the start of the scale*/
indic = lv_meter_add_scale_lines(meter, scale, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_BLUE),
false, 0);
lv_meter_set_indicator_start_value(meter, indic, 0);
lv_meter_set_indicator_end_value(meter, indic, 20);
/*Add a red arc to the end*/
indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_RED), 0);
lv_meter_set_indicator_start_value(meter, indic, 80);
lv_meter_set_indicator_end_value(meter, indic, 100);
/*Make the tick lines red at the end of the scale*/
indic = lv_meter_add_scale_lines(meter, scale, lv_palette_main(LV_PALETTE_RED), lv_palette_main(LV_PALETTE_RED), false,
0);
lv_meter_set_indicator_start_value(meter, indic, 80);
lv_meter_set_indicator_end_value(meter, indic, 100);
/*Add a needle line indicator*/
indic = lv_meter_add_needle_line(meter, scale, 4, lv_palette_main(LV_PALETTE_GREY), -10);
/*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_var(&a, indic);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_time(&a, 2000);
lv_anim_set_repeat_delay(&a, 100);
lv_anim_set_playback_time(&a, 500);
lv_anim_set_playback_delay(&a, 100);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}
#endif
#!//opt/bin/lv_micropython -i
import utime as time
import lvgl as lv
import display_driver
def set_value(indic, v):
meter.set_indicator_value(indic, v)
#
# A simple meter
#
meter = lv.meter(lv.scr_act())
meter.center()
meter.set_size(200, 200)
# Add a scale first
scale = meter.add_scale()
meter.set_scale_ticks(scale, 51, 2, 10, lv.palette_main(lv.PALETTE.GREY))
meter.set_scale_major_ticks(scale, 10, 4, 15, lv.color_black(), 10)
indic = lv.meter_indicator_t()
# Add a blue arc to the start
indic = meter.add_arc(scale, 3, lv.palette_main(lv.PALETTE.BLUE), 0)
meter.set_indicator_start_value(indic, 0)
meter.set_indicator_end_value(indic, 20)
# Make the tick lines blue at the start of the scale
indic = meter.add_scale_lines(scale, lv.palette_main(lv.PALETTE.BLUE), lv.palette_main(lv.PALETTE.BLUE), False, 0)
meter.set_indicator_start_value(indic, 0)
meter.set_indicator_end_value(indic, 20)
# Add a red arc to the end
indic = meter.add_arc(scale, 3, lv.palette_main(lv.PALETTE.RED), 0)
meter.set_indicator_start_value(indic, 80)
meter.set_indicator_end_value(indic, 100)
# Make the tick lines red at the end of the scale
indic = meter.add_scale_lines(scale, lv.palette_main(lv.PALETTE.RED), lv.palette_main(lv.PALETTE.RED), False, 0)
meter.set_indicator_start_value(indic, 80)
meter.set_indicator_end_value(indic, 100)
# Add a needle line indicator
indic = meter.add_needle_line(scale, 4, lv.palette_main(lv.PALETTE.GREY), -10)
# Create an animation to set the value
a = lv.anim_t()
a.init()
a.set_var(indic)
a.set_values(0, 100)
a.set_time(2000)
a.set_repeat_delay(100)
a.set_playback_time(500)
a.set_playback_delay(100)
a.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
a.set_custom_exec_cb(lambda a,val: set_value(indic,val))
lv.anim_t.start(a)
A meter with multiple arcs¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_METER && LV_BUILD_EXAMPLES
static lv_obj_t * meter;
static void set_value(void * indic, int32_t v)
{
lv_meter_set_indicator_end_value(meter, indic, v);
}
/**
* A meter with multiple arcs
*/
void lv_example_meter_2(void)
{
meter = lv_meter_create(lv_scr_act());
lv_obj_center(meter);
lv_obj_set_size(meter, 200, 200);
/*Remove the circle from the middle*/
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
/*Add a scale first*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 15);
lv_meter_set_scale_range(meter, scale, 0, 100, 270, 90);
/*Add a three arc indicator*/
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_RED), 0);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_GREEN), -10);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_BLUE), -20);
/*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, 100);
lv_anim_set_repeat_delay(&a, 100);
lv_anim_set_playback_delay(&a, 100);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_time(&a, 2000);
lv_anim_set_playback_time(&a, 500);
lv_anim_set_var(&a, indic1);
lv_anim_start(&a);
lv_anim_set_time(&a, 1000);
lv_anim_set_playback_time(&a, 1000);
lv_anim_set_var(&a, indic2);
lv_anim_start(&a);
lv_anim_set_time(&a, 1000);
lv_anim_set_playback_time(&a, 2000);
lv_anim_set_var(&a, indic3);
lv_anim_start(&a);
}
#endif
#!//opt/bin/lv_micropython -i
import utime as time
import lvgl as lv
import display_driver
def set_value(indic,v):
meter.set_indicator_end_value(indic, v)
#
# A meter with multiple arcs
#
meter = lv.meter(lv.scr_act())
meter.center()
meter.set_size(200, 200)
# Remove the circle from the middle
meter.remove_style(None, lv.PART.INDICATOR)
# Add a scale first
scale = meter.add_scale()
meter.set_scale_ticks(scale, 11, 2, 10, lv.palette_main(lv.PALETTE.GREY))
meter.set_scale_major_ticks(scale, 1, 2, 30, lv.color_hex3(0xeee), 10)
meter.set_scale_range(scale, 0, 100, 270, 90)
# Add a three arc indicator
indic1 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.RED), 0)
indic2 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.GREEN), -10)
indic3 = meter.add_arc(scale, 10, lv.palette_main(lv.PALETTE.BLUE), -20)
# Create an animation to set the value
a1 = lv.anim_t()
a1.init()
a1.set_values(0, 100)
a1.set_time(2000)
a1.set_repeat_delay(100)
a1.set_playback_delay(100)
a1.set_playback_time(500)
a1.set_var(indic1)
a1.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
a1.set_custom_exec_cb(lambda a,val: set_value(indic1,val))
lv.anim_t.start(a1)
a2 = lv.anim_t()
a2.init()
a2.set_values(0, 100)
a2.set_time(1000)
a2.set_repeat_delay(100)
a2.set_playback_delay(100)
a2.set_playback_time(1000)
a2.set_var(indic2)
a2.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
a2.set_custom_exec_cb(lambda a,val: set_value(indic2,val))
lv.anim_t.start(a2)
a3 = lv.anim_t()
a3.init()
a3.set_values(0, 100)
a3.set_time(1000)
a3.set_repeat_delay(100)
a3.set_playback_delay(100)
a3.set_playback_time(2000)
a3.set_var(indic3)
a3.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
a3.set_custom_exec_cb(lambda a,val: set_value(indic3,val))
lv.anim_t.start(a3)
A clock from a meter¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_METER && LV_BUILD_EXAMPLES
static lv_obj_t * meter;
static void set_value(void * indic, int32_t v)
{
lv_meter_set_indicator_end_value(meter, indic, v);
}
/**
* A clock from a meter
*/
void lv_example_meter_3(void)
{
meter = lv_meter_create(lv_scr_act());
lv_obj_set_size(meter, 220, 220);
lv_obj_center(meter);
/*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_min, &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_set_var(&a, indic_hour);
lv_anim_set_time(&a, 24000); /*24 sec for 1 turn of the hour hand*/
lv_anim_set_values(&a, 0, 60);
lv_anim_start(&a);
}
#endif
#!//opt/bin/lv_micropython -i
import utime as time
import lvgl as lv
import display_driver
from imagetools import get_png_info, open_png
# Register PNG image decoder
decoder = lv.img.decoder_create()
decoder.info_cb = get_png_info
decoder.open_cb = open_png
# Create an image from the png file
try:
with open('../../assets/img_hand_min.png','rb') as f:
img_hand_min_data = f.read()
except:
print("Could not find img_hand_min.png")
sys.exit()
img_hand_min_dsc = lv.img_dsc_t({
'data_size': len(img_hand_min_data),
'data': img_hand_min_data
})
# Create an image from the png file
try:
with open('../../assets/img_hand_hour.png','rb') as f:
img_hand_hour_data = f.read()
except:
print("Could not find img_hand_hour.png")
sys.exit()
img_hand_hour_dsc = lv.img_dsc_t({
'data_size': len(img_hand_hour_data),
'data': img_hand_hour_data
})
def set_value(indic, v):
meter.set_indicator_value(indic, v)
#
# A clock from a meter
#
meter = lv.meter(lv.scr_act())
meter.set_size(220, 220)
meter.center()
# Create a scale for the minutes
# 61 ticks in a 360 degrees range (the last and the first line overlaps)
scale_min = meter.add_scale()
meter.set_scale_ticks(scale_min, 61, 1, 10, lv.palette_main(lv.PALETTE.GREY))
meter.set_scale_range(scale_min, 0, 60, 360, 270)
# Create another scale for the hours. It's only visual and contains only major ticks
scale_hour = meter.add_scale()
meter.set_scale_ticks(scale_hour, 12, 0, 0, lv.palette_main(lv.PALETTE.GREY)) # 12 ticks
meter.set_scale_major_ticks(scale_hour, 1, 2, 20, lv.color_black(), 10) # Every tick is major
meter.set_scale_range(scale_hour, 1, 12, 330, 300) # [1..12] values in an almost full circle
# LV_IMG_DECLARE(img_hand)
# Add the hands from images
indic_min = meter.add_needle_img(scale_min, img_hand_min_dsc, 5, 5)
indic_hour = meter.add_needle_img(scale_min, img_hand_hour_dsc, 5, 5)
# Create an animation to set the value
a1 = lv.anim_t()
a1.init()
a1.set_values(0, 60)
a1.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
a1.set_time(2000) # 2 sec for 1 turn of the minute hand (1 hour)
a1.set_var(indic_min)
a1.set_custom_exec_cb(lambda a1,val: set_value(indic_min,val))
lv.anim_t.start(a1)
a2 = lv.anim_t()
a2.init()
a2.set_var(indic_hour)
a2.set_time(24000) # 24 sec for 1 turn of the hour hand
a2.set_values(0, 60)
a2.set_custom_exec_cb(lambda a2,val: set_value(indic_hour,val))
lv.anim_t.start(a2)
Pie chart¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_METER && LV_BUILD_EXAMPLES
/**
* Create a pie chart
*/
void lv_example_meter_4(void)
{
lv_obj_t * meter = lv_meter_create(lv_scr_act());
/*Remove the background and the circle from the middle*/
lv_obj_remove_style(meter, NULL, LV_PART_MAIN);
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
lv_obj_set_size(meter, 200, 200);
lv_obj_center(meter);
/*Add a scale first with no ticks.*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, lv_color_black());
lv_meter_set_scale_range(meter, scale, 0, 100, 360, 0);
/*Add a three arc indicator*/
lv_coord_t indic_w = 100;
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_ORANGE), 0);
lv_meter_set_indicator_start_value(meter, indic1, 0);
lv_meter_set_indicator_end_value(meter, indic1, 40);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_YELLOW), 0);
lv_meter_set_indicator_start_value(meter, indic2, 40); /*Start from the previous*/
lv_meter_set_indicator_end_value(meter, indic2, 80);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_DEEP_ORANGE), 0);
lv_meter_set_indicator_start_value(meter, indic3, 80); /*Start from the previous*/
lv_meter_set_indicator_end_value(meter, indic3, 100);
}
#endif
#
# Create a pie chart
#
meter = lv.meter(lv.scr_act())
# Remove the background and the circle from the middle
meter.remove_style(None, lv.PART.MAIN)
meter.remove_style(None, lv.PART.INDICATOR)
meter.set_size(200, 200)
meter.center()
# Add a scale first with no ticks.
scale = meter.add_scale()
meter.set_scale_ticks(scale, 0, 0, 0, lv.color_black())
meter.set_scale_range(scale, 0, 100, 360, 0)
# Add a three arc indicator*
indic_w = 100
indic1 = meter.add_arc(scale, indic_w,lv.palette_main(lv.PALETTE.ORANGE), 0)
meter.set_indicator_start_value(indic1, 0)
meter.set_indicator_end_value(indic1, 40)
indic2 = meter.add_arc(scale, indic_w, lv.palette_main(lv.PALETTE.YELLOW), 0)
meter.set_indicator_start_value(indic2, 40) # Start from the previous
meter.set_indicator_end_value(indic2, 80)
indic3 = meter.add_arc(scale, indic_w, lv.palette_main(lv.PALETTE.DEEP_ORANGE), 0)
meter.set_indicator_start_value(indic3, 80) # Start from the previous
meter.set_indicator_end_value(indic3, 100)
API¶
Typedefs
-
typedef uint8_t
lv_meter_indicator_type_t¶
Enums
-
Values:
-
enumerator
LV_METER_INDICATOR_TYPE_NEEDLE_IMG¶
-
enumerator
LV_METER_INDICATOR_TYPE_NEEDLE_LINE¶
-
enumerator
LV_METER_INDICATOR_TYPE_SCALE_LINES¶
-
enumerator
LV_METER_INDICATOR_TYPE_ARC¶
-
enumerator
-
enum
lv_meter_draw_part_type_t¶ typefield inlv_obj_draw_part_dsc_tifclass_p = lv_meter_classUsed inLV_EVENT_DRAW_PART_BEGINandLV_EVENT_DRAW_PART_ENDValues:
-
enumerator
LV_METER_DRAW_PART_ARC¶ The arc indicator
-
enumerator
LV_METER_DRAW_PART_NEEDLE_LINE¶ The needle lines
-
enumerator
LV_METER_DRAW_PART_NEEDLE_IMG¶ The needle images
-
enumerator
LV_METER_DRAW_PART_TICK¶ The tick lines and labels
-
enumerator
Functions
-
lv_obj_t *
lv_meter_create(lv_obj_t *parent)¶ Create a Meter object
- Parameters
parent -- pointer to an object, it will be the parent of the new bar.
- Returns
pointer to the created meter
-
lv_meter_scale_t *
lv_meter_add_scale(lv_obj_t *obj)¶ Add a new scale to the meter.
Note
Indicators can be attached to scales.
- Parameters
obj -- pointer to a meter object
- Returns
the new scale
-
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)¶ Set the properties of the ticks of a scale
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)cnt -- number of tick lines
width -- width of tick lines
len -- length of tick lines
color -- color of tick lines
-
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)¶ Make some "normal" ticks major ticks and set their attributes. Texts with the current value are also added to the major ticks.
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)nth -- make every Nth normal tick major tick. (start from the first on the left)
width -- width of the major ticks
len -- length of the major ticks
color -- color of the major ticks
label_gap -- gap between the major ticks and the labels
-
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)¶ Set the value and angular range of a scale.
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)min -- the minimum value
max -- the maximal value
angle_range -- the angular range of the scale
rotation -- the angular offset from the 3 o'clock position (clock-wise)
-
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)¶ Add a needle line indicator the scale
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)width -- width of the line
color -- color of the line
r_mod -- the radius modifier (added to the scale's radius) to get the lines length
- Returns
the new indicator
-
lv_meter_indicator_t *
lv_meter_add_needle_img(lv_obj_t *obj, lv_meter_scale_t *scale, const void *src, lv_coord_t pivot_x, lv_coord_t pivot_y)¶ Add a needle image indicator the scale
Note
the needle image should point to the right, like -O----->
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)src -- the image source of the indicator. path or pointer to lv_img_dsc_t
pivot_x -- the X pivot point of the needle
pivot_y -- the Y pivot point of the needle
- Returns
the new indicator
-
lv_meter_indicator_t *
lv_meter_add_arc(lv_obj_t *obj, lv_meter_scale_t *scale, uint16_t width, lv_color_t color, int16_t r_mod)¶ Add an arc indicator the scale
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)width -- width of the arc
color -- color of the arc
r_mod -- the radius modifier (added to the scale's radius) to get the outer radius of the arc
- Returns
the new indicator
-
lv_meter_indicator_t *
lv_meter_add_scale_lines(lv_obj_t *obj, lv_meter_scale_t *scale, lv_color_t color_start, lv_color_t color_end, bool local, int16_t width_mod)¶ Add a scale line indicator the scale. It will modify the ticks.
- Parameters
obj -- pointer to a meter object
scale -- pointer to scale (added to
meter)color_start -- the start color
color_end -- the end color
local -- tell how to map start and end color. true: the indicator's start and end_value; false: the scale's min max value
width_mod -- add this the affected tick's width
- Returns
the new indicator
-
void
lv_meter_set_indicator_value(lv_obj_t *obj, lv_meter_indicator_t *indic, int32_t value)¶ Set the value of the indicator. It will set start and and value to the same value
- Parameters
obj -- pointer to a meter object
indic -- pointer to an indicator
value -- the new value
-
void
lv_meter_set_indicator_start_value(lv_obj_t *obj, lv_meter_indicator_t *indic, int32_t value)¶ Set the start value of the indicator.
- Parameters
obj -- pointer to a meter object
indic -- pointer to an indicator
value -- the new value
-
void
lv_meter_set_indicator_end_value(lv_obj_t *obj, lv_meter_indicator_t *indic, int32_t value)¶ Set the start value of the indicator.
- Parameters
obj -- pointer to a meter object
indic -- pointer to an indicator
value -- the new value
Variables
-
const lv_obj_class_t
lv_meter_class¶
-
struct
lv_meter_scale_t¶ Public Members
-
lv_color_t
tick_color¶
-
uint16_t
tick_cnt¶
-
uint16_t
tick_length¶
-
uint16_t
tick_width¶
-
lv_color_t
tick_major_color¶
-
uint16_t
tick_major_nth¶
-
uint16_t
tick_major_length¶
-
uint16_t
tick_major_width¶
-
int16_t
label_gap¶
-
int16_t
label_color¶
-
int32_t
min¶
-
int32_t
max¶
-
int16_t
r_mod¶
-
uint16_t
angle_range¶
-
int16_t
rotation¶
-
lv_color_t
-
struct
lv_meter_indicator_t¶ Public Members
-
lv_meter_scale_t *
scale¶
-
lv_opa_t
opa¶
-
int32_t
start_value¶
-
int32_t
end_value¶
-
const void *
src¶
-
lv_point_t
pivot¶
-
struct lv_meter_indicator_t
needle_img¶
-
uint16_t
width¶
-
int16_t
r_mod¶
-
lv_color_t
color¶
-
struct lv_meter_indicator_t
needle_line¶
-
struct lv_meter_indicator_t
arc¶
-
int16_t
width_mod¶
-
lv_color_t
color_start¶
-
lv_color_t
color_end¶
-
uint8_t
local_grad¶
-
struct lv_meter_indicator_t
scale_lines¶
-
union lv_meter_indicator_t
type_data¶
-
lv_meter_scale_t *
-
struct
lv_meter_t¶