initial commit
This commit is contained in:
28
libraries/lvgl/examples/widgets/meter/index.rst
Normal file
28
libraries/lvgl/examples/widgets/meter/index.rst
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
Simple meter
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/meter/lv_example_meter_1
|
||||
:language: c
|
||||
|
||||
|
||||
A meter with multiple arcs
|
||||
"""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/meter/lv_example_meter_2
|
||||
:language: c
|
||||
|
||||
|
||||
A clock from a meter
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/meter/lv_example_meter_3
|
||||
:language: c
|
||||
|
||||
|
||||
Pie chart
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/meter/lv_example_meter_4
|
||||
:language: c
|
||||
|
||||
66
libraries/lvgl/examples/widgets/meter/lv_example_meter_1.c
Normal file
66
libraries/lvgl/examples/widgets/meter/lv_example_meter_1.c
Normal file
@@ -0,0 +1,66 @@
|
||||
#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
|
||||
58
libraries/lvgl/examples/widgets/meter/lv_example_meter_1.py
Normal file
58
libraries/lvgl/examples/widgets/meter/lv_example_meter_1.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!//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)
|
||||
|
||||
60
libraries/lvgl/examples/widgets/meter/lv_example_meter_2.c
Normal file
60
libraries/lvgl/examples/widgets/meter/lv_example_meter_2.c
Normal file
@@ -0,0 +1,60 @@
|
||||
#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
|
||||
69
libraries/lvgl/examples/widgets/meter/lv_example_meter_2.py
Normal file
69
libraries/lvgl/examples/widgets/meter/lv_example_meter_2.py
Normal file
@@ -0,0 +1,69 @@
|
||||
#!//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)
|
||||
|
||||
|
||||
|
||||
54
libraries/lvgl/examples/widgets/meter/lv_example_meter_3.c
Normal file
54
libraries/lvgl/examples/widgets/meter/lv_example_meter_3.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#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
|
||||
83
libraries/lvgl/examples/widgets/meter/lv_example_meter_3.py
Normal file
83
libraries/lvgl/examples/widgets/meter/lv_example_meter_3.py
Normal file
@@ -0,0 +1,83 @@
|
||||
#!//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)
|
||||
|
||||
38
libraries/lvgl/examples/widgets/meter/lv_example_meter_4.c
Normal file
38
libraries/lvgl/examples/widgets/meter/lv_example_meter_4.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#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
|
||||
32
libraries/lvgl/examples/widgets/meter/lv_example_meter_4.py
Normal file
32
libraries/lvgl/examples/widgets/meter/lv_example_meter_4.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user