Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources

This commit is contained in:
2026-07-06 11:30:13 +08:00
commit e76462eeb7
3451 changed files with 1415300 additions and 0 deletions

View 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

View File

@@ -0,0 +1,65 @@
#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_set_scale_ticks(meter, 41, 2, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(meter, 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, 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, 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, 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, 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, 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

View File

@@ -0,0 +1,53 @@
#!//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)
indic = lv.meter_indicator_t()
# Add a blue arc to the start
indic = meter.add_arc(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(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(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(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(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)

View File

@@ -0,0 +1,59 @@
#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, 220, 220);
/*Remove the circle from the middle*/
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
/*Add a scale first*/
lv_meter_set_scale_ticks(meter, 11, 2, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(meter, 1, 2, 30, lv_color_hex3(0xeee), 15);
lv_meter_set_scale_range(meter, 0, 100, 270, 90);
/*Add a three arc indicator*/
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, 10, lv_palette_main(LV_PALETTE_RED), 0);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, 10, lv_palette_main(LV_PALETTE_GREEN), -10);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, 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

View File

@@ -0,0 +1,68 @@
#!//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)
# Scale settings
meter.set_scale_ticks(11, 2, 10, lv.palette_main(lv.PALETTE.GREY))
meter.set_scale_major_ticks(1, 2, 30, lv.color_hex3(0xeee), 10)
meter.set_scale_range(0, 100, 270, 90)
# Add a three arc indicator
indic1 = meter.add_arc(10, lv.palette_main(lv.PALETTE.RED), 0)
indic2 = meter.add_arc(10, lv.palette_main(lv.PALETTE.GREEN), -10)
indic3 = meter.add_arc(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)

View File

@@ -0,0 +1,73 @@
#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);
}
static void tick_label_event(lv_event_t * e)
{
lv_obj_draw_part_dsc_t * draw_part_dsc = lv_event_get_draw_part_dsc(e);
/*Be sure it's drawing meter related parts*/
if(draw_part_dsc->class_p != &lv_meter_class) return;
/*Be sure it's drawing the ticks*/
if(draw_part_dsc->type != LV_METER_DRAW_PART_TICK) return;
/*Be sure it's a major ticks*/
if(draw_part_dsc->id % 5) return;
/*The order of numbers on the clock is tricky: 12, 1, 2, 3...*/
if(draw_part_dsc->id == 0) {
lv_strncpy(draw_part_dsc->text, "12", 4);
}
else {
lv_snprintf(draw_part_dsc->text, 4, "%d", draw_part_dsc->id / 5);
}
}
/**
* 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_set_scale_ticks(meter, 60, 1, 10, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_major_ticks(meter, 5, 2, 20, lv_color_black(), 10);
lv_meter_set_scale_range(meter, 0, 59, 354, 270);
LV_IMG_DECLARE(img_hand)
/*Add a the hands from images*/
lv_meter_indicator_t * indic_min = lv_meter_add_needle_img(meter, &img_hand, 5, 5);
lv_meter_indicator_t * indic_hour = lv_meter_add_needle_img(meter, &img_hand, 5, 5);
lv_obj_add_event_cb(meter, tick_label_event, LV_EVENT_DRAW_PART_BEGIN, NULL);
/*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, 59);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_time(&a, 5000); /*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, 240000); /*24 sec for 1 turn of the hour hand*/
lv_anim_set_values(&a, 0, 59);
lv_anim_start(&a);
}
#endif

View File

@@ -0,0 +1,88 @@
#!//opt/bin/lv_micropython -i
import utime as time
import lvgl as lv
import display_driver
# 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
#
def tick_label_event(e):
draw_part_dsc = e.get_draw_part_dsc();
# Be sure it's drawing the ticks
if draw_part_dsc.type != lv.meter.DRAW_PART.TICK: return
# Be sure it's a major ticks
if draw_part_dsc.id % 5: return
# The order of numbers on the clock is tricky: 12, 1, 2, 3...*/
txt = ["12", "1", "2as", "3", "4", "5", "6", "7", "8", "9", "10", "11"]
# dsc.text is defined char text[16], I must therefore convert the Python string to a byte_array
idx = int(draw_part_dsc.id / 5)
draw_part_dsc.text = bytes(txt[idx],"ascii")
meter = lv.meter(lv.scr_act())
meter.set_size(220, 220)
meter.center()
# Create a scale for the minutes
# 60 ticks in a 354 degrees range
meter.set_scale_ticks(60, 1, 10, lv.palette_main(lv.PALETTE.GREY))
meter.set_scale_major_ticks(5, 2, 20, lv.color_black(), 10) # Every tick is major
meter.set_scale_range(0, 59, 354, 270)
# Add the hands from images
indic_min = meter.add_needle_img(img_hand_min_dsc, 5, 5)
indic_hour = meter.add_needle_img(img_hand_hour_dsc, 5, 5)
#Add an event to set the numbers of hours
meter.add_event_cb(tick_label_event, lv.EVENT.DRAW_PART_BEGIN, None)
# 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)

View File

@@ -0,0 +1,37 @@
#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_set_scale_ticks(meter, 0, 0, 0, lv_color_black());
lv_meter_set_scale_range(meter, 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, 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, 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, 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

View File

@@ -0,0 +1,31 @@
#
# 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.
meter.set_scale_ticks( 0, 0, 0, lv.color_black())
meter.set_scale_range(0, 100, 360, 0)
# Add a three arc indicator*
indic_w = 100
indic1 = meter.add_arc(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(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(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)