diff --git a/demos/widgets/lv_demo_widgets.c b/demos/widgets/lv_demo_widgets.c index 1698e7e54..7a8e0e5ea 100644 --- a/demos/widgets/lv_demo_widgets.c +++ b/demos/widgets/lv_demo_widgets.c @@ -653,6 +653,7 @@ static void analytics_create(lv_obj_t * parent) lv_obj_t * arc; arc = lv_arc_create(scale1); lv_obj_remove_style(arc, NULL, LV_PART_KNOB); + lv_obj_remove_style(arc, NULL, LV_PART_MAIN); lv_obj_set_size(arc, lv_pct(100), lv_pct(100)); lv_obj_set_style_arc_opa(arc, 0, 0); lv_obj_set_style_arc_width(arc, 15, LV_PART_INDICATOR); @@ -698,14 +699,17 @@ static void analytics_create(lv_obj_t * parent) lv_anim_start(&a); /*Scale 2*/ - lv_scale_set_round_props(scale2, 330, 0); + static const char * scale2_text[] = {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", NULL}; + lv_scale_set_round_props(scale2, 360, 0); + lv_scale_set_text_src(scale2, scale2_text); + lv_scale_set_total_tick_count(scale2, 11); lv_scale_set_major_tick_length(scale2, 30); lv_scale_set_major_tick_every(scale2, 1); arc = lv_arc_create(scale2); lv_obj_set_size(arc, lv_pct(100), lv_pct(100)); lv_obj_set_style_margin_all(arc, 10, 0); lv_obj_set_style_bg_opa(arc, 0, LV_PART_KNOB); - lv_obj_set_style_bg_opa(arc, 0, LV_PART_KNOB); + lv_obj_set_style_arc_opa(arc, 0, LV_PART_MAIN); lv_obj_set_style_arc_width(arc, 10, LV_PART_INDICATOR); lv_obj_set_style_arc_rounded(arc, false, LV_PART_INDICATOR); lv_obj_set_style_arc_color(arc, lv_palette_main(LV_PALETTE_BLUE), LV_PART_INDICATOR); @@ -717,6 +721,7 @@ static void analytics_create(lv_obj_t * parent) lv_obj_set_style_margin_all(arc, 5, 0); lv_obj_set_style_arc_opa(arc, 0, 0); lv_obj_set_style_bg_opa(arc, 0, LV_PART_KNOB); + lv_obj_set_style_arc_opa(arc, 0, LV_PART_MAIN); lv_obj_set_style_arc_width(arc, 20, LV_PART_INDICATOR); lv_obj_set_style_arc_rounded(arc, false, LV_PART_INDICATOR); lv_obj_set_style_arc_color(arc, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR); @@ -727,6 +732,7 @@ static void analytics_create(lv_obj_t * parent) lv_obj_set_size(arc, lv_pct(100), lv_pct(100)); lv_obj_set_style_arc_opa(arc, 0, 0); lv_obj_set_style_bg_opa(arc, 0, LV_PART_KNOB); + lv_obj_set_style_arc_opa(arc, 0, LV_PART_MAIN); lv_obj_set_style_arc_width(arc, 30, LV_PART_INDICATOR); lv_obj_set_style_arc_rounded(arc, false, LV_PART_INDICATOR); lv_obj_set_style_arc_color(arc, lv_palette_main(LV_PALETTE_GREEN), LV_PART_INDICATOR); diff --git a/examples/widgets/scale/lv_example_scale_3.c b/examples/widgets/scale/lv_example_scale_3.c index 89aa5a09c..4b92f8177 100644 --- a/examples/widgets/scale/lv_example_scale_3.c +++ b/examples/widgets/scale/lv_example_scale_3.c @@ -16,7 +16,7 @@ void lv_example_scale_3(void) lv_scale_set_label_show(scale, true); - lv_scale_set_total_tick_count(scale, 11); + lv_scale_set_total_tick_count(scale, 31); lv_scale_set_major_tick_every(scale, 5); lv_scale_set_major_tick_length(scale, 10); diff --git a/src/widgets/scale/lv_scale.c b/src/widgets/scale/lv_scale.c index 8bccedf17..5e861853f 100644 --- a/src/widgets/scale/lv_scale.c +++ b/src/widgets/scale/lv_scale.c @@ -528,7 +528,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event) } /* Also take into consideration the letter space of the style */ - int32_t angle_upscale = ((tick_idx * scale->angle_range) * 10U) / (scale->total_tick_count); + int32_t angle_upscale = ((tick_idx * scale->angle_range) * 10U) / (scale->total_tick_count - 1); angle_upscale += scale->rotation * 10U; uint32_t radius_text = 0; @@ -838,7 +838,7 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool /* Vertical position starts at y2 of the scale main line, we start at y2 because the ticks are drawn from bottom to top */ lv_coord_t vertical_position = obj->coords.y2 - (pad_bottom + tick_pad_bottom); - if(scale->total_tick_count == tick_idx) { + if((scale->total_tick_count - 1U) == tick_idx) { vertical_position = y_ofs; } /* Increment the tick offset depending of its index */ @@ -859,7 +859,7 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool /* Horizontal position starts at x1 of the scale main line */ lv_coord_t horizontal_position = x_ofs; /* Position the last tick at the x2 scale coordinate */ - if(scale->total_tick_count == tick_idx) { + if((scale->total_tick_count - 1U) == tick_idx) { horizontal_position = obj->coords.x2 - (pad_left + tick_pad_left); } /* Increment the tick offset depending of its index */