diff --git a/demos/widgets/lv_demo_widgets.c b/demos/widgets/lv_demo_widgets.c index 6a7956e2c..1698e7e54 100644 --- a/demos/widgets/lv_demo_widgets.c +++ b/demos/widgets/lv_demo_widgets.c @@ -544,7 +544,7 @@ static lv_obj_t * create_chart_with_scales(lv_obj_t * parent, const char * title lv_obj_t * scale_ver = lv_scale_create(parent); lv_scale_set_mode(scale_ver, LV_SCALE_MODE_VERTICAL_LEFT); lv_obj_set_grid_cell(scale_ver, LV_GRID_ALIGN_END, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1); - lv_scale_set_total_tick_count(scale_ver, 10); + lv_scale_set_total_tick_count(scale_ver, 11); lv_scale_set_major_tick_every(scale_ver, 2); lv_scale_set_range(scale_ver, 0, 100); @@ -568,7 +568,7 @@ static lv_obj_t * create_chart_with_scales(lv_obj_t * parent, const char * title lv_obj_t * scale_hor = lv_scale_create(wrapper); lv_scale_set_mode(scale_hor, LV_SCALE_MODE_HORIZONTAL_BOTTOM); lv_obj_set_grid_cell(scale_hor, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_START, 1, 1); - lv_scale_set_total_tick_count(scale_hor, 11); + lv_scale_set_total_tick_count(scale_hor, 12); lv_scale_set_major_tick_every(scale_hor, 1); lv_scale_set_text_src(scale_hor, hor_text); lv_obj_set_width(scale_hor, lv_pct(200)); @@ -699,7 +699,6 @@ static void analytics_create(lv_obj_t * parent) /*Scale 2*/ lv_scale_set_round_props(scale2, 330, 0); - lv_scale_set_total_tick_count(scale2, 10); lv_scale_set_major_tick_length(scale2, 30); lv_scale_set_major_tick_every(scale2, 1); arc = lv_arc_create(scale2); @@ -739,7 +738,7 @@ static void analytics_create(lv_obj_t * parent) /*Scale 3*/ lv_scale_set_range(scale3, 10, 60); - lv_scale_set_total_tick_count(scale3, 20); + lv_scale_set_total_tick_count(scale3, 21); lv_scale_set_major_tick_every(scale3, 4); lv_scale_set_minor_tick_length(scale3, 10); lv_scale_set_major_tick_length(scale3, 20); diff --git a/examples/widgets/scale/lv_example_scale_1.c b/examples/widgets/scale/lv_example_scale_1.c index 0a72d671c..c5b2a535f 100644 --- a/examples/widgets/scale/lv_example_scale_1.c +++ b/examples/widgets/scale/lv_example_scale_1.c @@ -13,7 +13,7 @@ void lv_example_scale_1(void) lv_scale_set_label_show(scale, true); - lv_scale_set_total_tick_count(scale, 30); + 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/examples/widgets/scale/lv_example_scale_2.c b/examples/widgets/scale/lv_example_scale_2.c index 004f97825..ec3e76302 100644 --- a/examples/widgets/scale/lv_example_scale_2.c +++ b/examples/widgets/scale/lv_example_scale_2.c @@ -12,7 +12,7 @@ void lv_example_scale_2(void) lv_scale_set_mode(scale, LV_SCALE_MODE_VERTICAL_RIGHT); lv_obj_center(scale); - lv_scale_set_total_tick_count(scale, 20); + lv_scale_set_total_tick_count(scale, 21); lv_scale_set_major_tick_every(scale, 5); lv_scale_set_major_tick_length(scale, 10); @@ -74,13 +74,15 @@ void lv_example_scale_2(void) /* Configure section styles */ lv_scale_section_t * section = lv_scale_add_section(scale); - lv_scale_section_set_range(section, 80, 100); + lv_scale_section_set_range(section, 75, 100); lv_scale_section_set_style(section, LV_PART_INDICATOR, §ion_label_style); lv_scale_section_set_style(section, LV_PART_ITEMS, §ion_minor_tick_style); lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style); - - lv_obj_set_style_bg_opa(scale, 40, 0); + lv_obj_set_style_bg_color(scale, lv_palette_main(LV_PALETTE_BLUE_GREY), 0); + lv_obj_set_style_bg_opa(scale, LV_OPA_50, 0); + lv_obj_set_style_pad_left(scale, 8, 0); + lv_obj_set_style_radius(scale, 8, 0); lv_obj_set_style_pad_ver(scale, 20, 0); } diff --git a/examples/widgets/scale/lv_example_scale_3.c b/examples/widgets/scale/lv_example_scale_3.c index 191443243..89aa5a09c 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, 30); + lv_scale_set_total_tick_count(scale, 11); lv_scale_set_major_tick_every(scale, 5); lv_scale_set_major_tick_length(scale, 10); diff --git a/examples/widgets/scale/lv_example_scale_4.c b/examples/widgets/scale/lv_example_scale_4.c index 3aed5431e..f640b9f83 100644 --- a/examples/widgets/scale/lv_example_scale_4.c +++ b/examples/widgets/scale/lv_example_scale_4.c @@ -12,7 +12,7 @@ void lv_example_scale_4(void) lv_scale_set_mode(scale, LV_SCALE_MODE_ROUND_OUTER); lv_obj_center(scale); - lv_scale_set_total_tick_count(scale, 20); + lv_scale_set_total_tick_count(scale, 21); lv_scale_set_major_tick_every(scale, 5); lv_scale_set_major_tick_length(scale, 10); @@ -74,7 +74,7 @@ void lv_example_scale_4(void) /* Configure section styles */ lv_scale_section_t * section = lv_scale_add_section(scale); - lv_scale_section_set_range(section, 80, 100); + lv_scale_section_set_range(section, 75, 100); lv_scale_section_set_style(section, LV_PART_INDICATOR, §ion_label_style); lv_scale_section_set_style(section, LV_PART_ITEMS, §ion_minor_tick_style); lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style); diff --git a/src/themes/default/lv_theme_default.c b/src/themes/default/lv_theme_default.c index 835871a74..338c09200 100644 --- a/src/themes/default/lv_theme_default.c +++ b/src/themes/default/lv_theme_default.c @@ -647,9 +647,9 @@ static void style_init(struct _my_theme_t * theme) #if LV_USE_SCALE style_init_reset(&theme->styles.scale); - lv_style_set_line_color(&theme->styles.scale, theme->color_grey); + lv_style_set_line_color(&theme->styles.scale, theme->color_text); lv_style_set_line_width(&theme->styles.scale, LV_DPX(2)); - lv_style_set_arc_color(&theme->styles.scale, theme->color_grey); + lv_style_set_arc_color(&theme->styles.scale, theme->color_text); lv_style_set_arc_width(&theme->styles.scale, LV_DPX(2)); #endif } diff --git a/src/widgets/scale/lv_scale.c b/src/widgets/scale/lv_scale.c index e872f2c1d..8bccedf17 100644 --- a/src/widgets/scale/lv_scale.c +++ b/src/widgets/scale/lv_scale.c @@ -394,7 +394,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event) if(tick_idx % scale->major_tick_every == 0) is_major_tick = true; if(is_major_tick) major_tick_idx++; - const int32_t tick_value = lv_map(tick_idx, 0U, total_tick_count, scale->range_min, scale->range_max); + const int32_t tick_value = lv_map(tick_idx, 0U, total_tick_count - 1, scale->range_min, scale->range_max); /* Overwrite label and tick properties if tick value is within section range */ lv_scale_section_t * section; @@ -483,7 +483,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event) if(tick_idx % scale->major_tick_every == 0) is_major_tick = true; if(is_major_tick) major_tick_idx++; - const int32_t tick_value = lv_map(tick_idx, 0U, scale->total_tick_count, scale->range_min, scale->range_max); + const int32_t tick_value = lv_map(tick_idx, 0U, scale->total_tick_count - 1, scale->range_min, scale->range_max); /* Overwrite label and tick properties if tick value is within section range */ lv_scale_section_t * section; @@ -887,7 +887,7 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool center_point.x = scale_area.x1 + radius_edge; center_point.y = scale_area.y1 + radius_edge; - 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; /* Draw a little bit longer lines to be sure the mask will clip them correctly @@ -1145,7 +1145,7 @@ static void scale_find_section_tick_idx(lv_obj_t * obj) bool is_major_tick = false; if(tick_idx % scale->major_tick_every == 0) is_major_tick = true; - const int32_t tick_value = lv_map(tick_idx, 0U, total_tick_count, min_out, max_out); + const int32_t tick_value = lv_map(tick_idx, 0U, total_tick_count - 1, min_out, max_out); lv_scale_section_t * section; _LV_LL_READ_BACK(&scale->section_ll, section) { diff --git a/src/widgets/scale/lv_scale.h b/src/widgets/scale/lv_scale.h index 64358e46d..9e54d2315 100644 --- a/src/widgets/scale/lv_scale.h +++ b/src/widgets/scale/lv_scale.h @@ -24,7 +24,7 @@ extern "C" { *********************/ /**Default value of total minor ticks. */ -#define LV_SCALE_TOTAL_TICK_COUNT_DEFAULT (10U) +#define LV_SCALE_TOTAL_TICK_COUNT_DEFAULT (11U) LV_EXPORT_CONST_INT(LV_SCALE_TOTAL_TICK_COUNT_DEFAULT); /**Default value of major tick every nth ticks. */