mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-23 15:56:59 +08:00
refactor(scale): remove lv_meter use lv_scale instead
This commit is contained in:
@@ -233,9 +233,9 @@ static void obj_test_task_cb(lv_timer_t * tmr)
|
||||
lv_anim_set_exec_cb(&a, arc_set_end_angle_anim);
|
||||
lv_anim_start(&a);
|
||||
|
||||
obj = lv_meter_create(main_page);
|
||||
obj = lv_scale_create(main_page);
|
||||
lv_scale_set_mode(obj, LV_SCALE_MODE_ROUND_INNER);
|
||||
lv_obj_scroll_to_view(obj, LV_ANIM_ON);
|
||||
lv_meter_add_needle_line(obj, 3, lv_palette_main(LV_PALETTE_RED), -10);
|
||||
|
||||
auto_del(obj, LV_DEMO_STRESS_TIME_STEP * 6 + 30);
|
||||
break;
|
||||
|
||||
File diff suppressed because one or more lines are too long
+249
-279
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,6 @@ Widgets
|
||||
line
|
||||
list
|
||||
menu
|
||||
meter
|
||||
msgbox
|
||||
roller
|
||||
scale
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
Meter (lv_meter)
|
||||
================
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
The Meter widget can visualize data in very flexible ways. In can show
|
||||
arcs, needles, ticks lines and labels.
|
||||
|
||||
Parts and Styles
|
||||
****************
|
||||
|
||||
- :cpp:enumerator:`LV_PART_MAIN` The background of the Meter. Uses the typical
|
||||
background properties.
|
||||
- :cpp:enumerator:`LV_PART_TICK` The tick lines a labels using the *line* and *text*
|
||||
style properties.
|
||||
- :cpp:enumerator:`LV_PART_INDICATOR` The needle line or image using the *line* and
|
||||
*img* style properties, as well as the background properties to draw
|
||||
a square (or circle) on the pivot of the needles. Padding makes the
|
||||
square larger.
|
||||
- :cpp:enumerator:`LV_PART_ITEMS` The arcs using the *arc* properties.
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
Scale
|
||||
-----
|
||||
|
||||
The Scale has minor and major ticks, and labels on the major ticks.
|
||||
|
||||
The minor tick lines can be configured with:
|
||||
:cpp:expr:`lv_meter_set_scale_ticks(meter, tick_count, line_width, tick_length, tick_color)`.
|
||||
|
||||
To show major tick lines use
|
||||
:cpp:expr:`lv_meter_set_scale_major_ticks(meter, nth_major, tick_width, tick_length, tick_color, label_gap)`.
|
||||
``nth_major`` to specify how many minor ticks to skip to draw a major
|
||||
tick.
|
||||
|
||||
Labels are added automatically on major ticks with ``label_gap``
|
||||
distance from the ticks with text proportionally to the values of the
|
||||
tick line.
|
||||
|
||||
:cpp:expr:`lv_meter_set_scale_range(meter, min, max, angle_range, rotation)`
|
||||
sets the value and angle range of the scale.
|
||||
|
||||
Add indicators
|
||||
--------------
|
||||
|
||||
Indicators can be added to meter and their value is interpreted in the
|
||||
range of the scale.
|
||||
|
||||
All the indicator add functions return an ``lv_meter_indicator_t *``.
|
||||
|
||||
Needle line
|
||||
^^^^^^^^^^^
|
||||
|
||||
``indic = lv_meter_add_needle_line(meter, line_width, line_color, r_mod)``
|
||||
adds a needle line to a Scale. By default, the length of the line is the
|
||||
same as the scale's radius but ``r_mod`` changes the length.
|
||||
|
||||
:cpp:expr:`lv_meter_set_indicator_value(meter, indic, value)` sets the value of
|
||||
the indicator.
|
||||
|
||||
Needle image
|
||||
^^^^^^^^^^^^
|
||||
|
||||
``indic = lv_meter_add_needle_img(meter, img_src, pivot_x, pivot_y)``
|
||||
sets an image that will be used as a needle. ``img_src`` should be a
|
||||
needle pointing to the right like this ``-O--->``. ``pivot_x`` and
|
||||
``pivot_y`` sets the pivot point of the rotation relative to the top
|
||||
left corner of the image.
|
||||
|
||||
:cpp:expr:`lv_meter_set_indicator_value(meter, indicator, value)` sets the
|
||||
value of the indicator.
|
||||
|
||||
Arc
|
||||
^^^
|
||||
|
||||
``indic = lv_meter_add_arc(meter, arc_width, arc_color, r_mod)`` adds
|
||||
and arc indicator. . By default, the radius of the arc is the same as
|
||||
the scale's radius but ``r_mod`` changes the radius.
|
||||
|
||||
:cpp:expr:`lv_meter_set_indicator_start_value(meter, indic, value)` and
|
||||
:cpp:expr:`lv_meter_set_indicator_end_value(meter, indicator, value)` sets the
|
||||
value of the indicator.
|
||||
|
||||
Scale lines (ticks)
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
``indic = lv_meter_add_scale_lines(meter, color_start, color_end, local, width_mod)``
|
||||
adds an indicator that modifies the ticks lines. If ``local`` is
|
||||
``true`` the ticks' color will be faded from ``color_start`` to
|
||||
``color_end`` in the indicator's start and end value range. If ``local``
|
||||
is ``false`` ``color_start`` and ``color_end`` will be mapped to the
|
||||
start and end value of the scale and only a "slice" of that color
|
||||
gradient will be visible in the indicator's start and end value range.
|
||||
``width_mod`` modifies the width of the tick lines.
|
||||
|
||||
:cpp:expr:`lv_meter_set_indicator_start_value(meter, indicator, value)` and
|
||||
:cpp:expr:`lv_meter_set_indicator_end_value(meter, indicator, value)` sets the
|
||||
value of the indicator.
|
||||
|
||||
Events
|
||||
******
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_PART_BEGIN` and :cpp:enumerator:`LV_EVENT_DRAW_PART_END` is sent
|
||||
for the following types:
|
||||
|
||||
- :cpp:enumerator:`LV_METER_DRAW_PART_ARC` The arc indicator
|
||||
|
||||
- ``part``: :cpp:enumerator:`LV_PART_ITEMS`
|
||||
- ``sub_part_ptr``: pointer to the indicator
|
||||
- ``arc_dsc``
|
||||
- ``radius``: radius of the arc
|
||||
- ``p1`` center of the arc
|
||||
|
||||
- :cpp:enumerator:`LV_METER_DRAW_PART_NEEDLE_LINE` The needle lines
|
||||
|
||||
- ``part``: :cpp:enumerator:`LV_PART_ITEMS`
|
||||
- ``p1``, ``p2`` points of the line
|
||||
- ``line_dsc``
|
||||
- ``sub_part_ptr``: pointer to the indicator
|
||||
|
||||
- :cpp:enumerator:`LV_METER_DRAW_PART_NEEDLE_IMG` The needle images
|
||||
|
||||
- ``part``: :cpp:enumerator:`LV_PART_ITEMS`
|
||||
- ``p1``, ``p2`` points of the line
|
||||
- ``img_dsc``
|
||||
- ``sub_part_ptr``: pointer to the indicator
|
||||
|
||||
- :cpp:enumerator:`LV_METER_DRAW_PART_TICK` The tick lines and labels
|
||||
|
||||
- ``part``: :cpp:enumerator:`LV_PART_TICKS`
|
||||
- ``value``: the value of the line
|
||||
- ``text``: ``value`` converted to decimal or ``NULL`` on minor
|
||||
lines
|
||||
- ``label_dsc``: label draw descriptor or ``NULL`` on minor lines
|
||||
- ``line_dsc``:
|
||||
- ``id``: the index of the line
|
||||
|
||||
See the events of the `Base object </widgets/obj>`__ too.
|
||||
|
||||
Learn more about :ref:`events`.
|
||||
|
||||
Keys
|
||||
****
|
||||
|
||||
No keys are handled by the Meter widget.
|
||||
|
||||
Learn more about :ref:`indev_keys`.
|
||||
|
||||
Example
|
||||
*******
|
||||
|
||||
.. include:: ../examples/widgets/meter/index.rst
|
||||
|
||||
API
|
||||
***
|
||||
@@ -12,7 +12,7 @@ Parts and Styles
|
||||
The scale widget is divided in the following three parts:
|
||||
|
||||
- :cpp:enumerator: `LV_PART_MAIN` Main line. See blue line in the example image.
|
||||
- :cpp:enumerator: `LV_PART_ITEMS` Minor ticks. See red minor ticks in the example image.
|
||||
- :cpp:enumerator: `LV_PART_TICKS` Minor ticks. See red minor ticks in the example image.
|
||||
- :cpp:enumerator: `LV_PART_INDICATOR` Major ticks and its labels (if enabled). See pink labels and green major ticks in the example image.
|
||||
|
||||

|
||||
@@ -37,7 +37,7 @@ Sections
|
||||
|
||||
A section is the space between a minor and a major range. They can be created with :cpp:expr: `lv_scale_add_section(scale)` and it handles back an :cpp:expr: `lv_scale_section_t` pointer.
|
||||
|
||||
The range of the section is configured with :cpp:expr: `lv_scale_section_set_range(section, minor_range, major_range)`. The style of each of the three parts of the scale section can be set with :cpp:expr: `lv_scale_section_set_style(section, PART, style_pointer)`, where `PART` can be :cpp:enumarator: `LV_PART_MAIN`, :cpp:enumarator: `LV_PART_ITEMS` or :cpp:enumarator: `LV_PART_INDICATOR`, :cpp:expr: `style_pointer` should point to a global or static :cpp:expr: `lv_style_t` variable.
|
||||
The range of the section is configured with :cpp:expr: `lv_scale_section_set_range(section, minor_range, major_range)`. The style of each of the three parts of the scale section can be set with :cpp:expr: `lv_scale_section_set_style(section, PART, style_pointer)`, where `PART` can be :cpp:enumarator: `LV_PART_MAIN`, :cpp:enumarator: `LV_PART_TICKS` or :cpp:enumarator: `LV_PART_INDICATOR`, :cpp:expr: `style_pointer` should point to a global or static :cpp:expr: `lv_style_t` variable.
|
||||
|
||||
For labels the following properties can be configured:
|
||||
:cpp:expr: `lv_style_set_text_font`, :cpp:expr: `lv_style_set_text_color`, :cpp:expr: `lv_style_set_text_letter_space`, :cpp:expr: `lv_style_set_text_opa`.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,41 +1,49 @@
|
||||
#include "../../lv_examples.h"
|
||||
//TODO when lv_scale is ready
|
||||
#if LV_USE_CHART && LV_BUILD_EXAMPLES && 0
|
||||
|
||||
static void draw_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||
if(!lv_obj_draw_part_check_type(dsc, &lv_chart_class, LV_CHART_DRAW_PART_TICK_LABEL)) return;
|
||||
|
||||
if(dsc->id == LV_CHART_AXIS_PRIMARY_X && dsc->text) {
|
||||
const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||
lv_snprintf(dsc->text, dsc->text_length, "%s", month[dsc->value]);
|
||||
}
|
||||
}
|
||||
//static void draw_event_cb(lv_event_t * e)
|
||||
//{
|
||||
// lv_obj_draw_part_dsc_t * dsc = lv_event_get_draw_part_dsc(e);
|
||||
// if(!lv_obj_draw_part_check_type(dsc, &lv_chart_class, LV_CHART_DRAW_PART_TICK_LABEL)) return;
|
||||
//
|
||||
// if(dsc->id == LV_CHART_AXIS_PRIMARY_X && dsc->text) {
|
||||
// const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||
// lv_snprintf(dsc->text, dsc->text_length, "%s", month[dsc->value]);
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* Add ticks and labels to the axis and demonstrate scrolling
|
||||
*/
|
||||
void lv_example_chart_3(void)
|
||||
{
|
||||
lv_obj_t * main_cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(main_cont, 200, 150);
|
||||
|
||||
lv_obj_t * wrapper = lv_obj_create(main_cont);
|
||||
lv_obj_remove_style_all(wrapper);
|
||||
lv_obj_set_size(wrapper, 800, lv_pct(100));
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
/*Create a chart*/
|
||||
lv_obj_t * chart;
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_center(chart);
|
||||
lv_obj_t * chart = lv_chart_create(wrapper);
|
||||
lv_obj_set_width(chart, lv_pct(100));
|
||||
lv_obj_set_flex_grow(chart, 1);
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, 0, 100);
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_SECONDARY_Y, 0, 400);
|
||||
lv_chart_set_point_count(chart, 12);
|
||||
lv_obj_add_event(chart, draw_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||
lv_obj_set_style_radius(chart, 0, 0);
|
||||
|
||||
/*Add ticks and label to every axis*/
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 10, 5, 12, 3, true, 40);
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 2, true, 50);
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_SECONDARY_Y, 10, 5, 3, 4, true, 50);
|
||||
lv_obj_t * scale_bottom = lv_scale_create(wrapper);
|
||||
lv_scale_set_mode(scale_bottom, LV_SCALE_MODE_HORIZONTAL_BOTTOM);
|
||||
lv_obj_set_size(scale_bottom, lv_pct(100), 25);
|
||||
lv_scale_set_total_tick_count(scale_bottom, 12);
|
||||
lv_scale_set_major_tick_every(scale_bottom, 1);
|
||||
lv_obj_set_style_pad_hor(scale_bottom, 50, 0);
|
||||
|
||||
/*Zoom in a little in X*/
|
||||
lv_chart_set_zoom_x(chart, 800);
|
||||
static const char * month[] = {"Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec", NULL};
|
||||
lv_scale_set_text_src(scale_bottom, month);
|
||||
|
||||
/*Add two data series*/
|
||||
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_lighten(LV_PALETTE_GREEN, 2), LV_CHART_AXIS_PRIMARY_Y);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CHART && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_CHART && LV_BUILD_EXAMPLES && 0
|
||||
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
@@ -71,7 +71,7 @@ void lv_example_chart_4(void)
|
||||
lv_obj_refresh_ext_draw_size(chart);
|
||||
|
||||
/*Zoom in a little in X*/
|
||||
lv_chart_set_zoom_x(chart, 800);
|
||||
// lv_chart_set_zoom_x(chart, 800);
|
||||
|
||||
/*Add two data series*/
|
||||
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CHART && LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_CHART && LV_USE_SLIDER && LV_BUILD_EXAMPLES && 0
|
||||
|
||||
static lv_obj_t * chart;
|
||||
/* Source: https://github.com/ankur219/ECG-Arrhythmia-classification/blob/642230149583adfae1e4bd26c6f0e1fd8af2be0e/sample.csv*/
|
||||
@@ -50,14 +50,14 @@ static void slider_x_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
int32_t v = lv_slider_get_value(obj);
|
||||
lv_chart_set_zoom_x(chart, v);
|
||||
// lv_chart_set_zoom_x(chart, v);
|
||||
}
|
||||
|
||||
static void slider_y_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
int32_t v = lv_slider_get_value(obj);
|
||||
lv_chart_set_zoom_y(chart, v);
|
||||
// lv_chart_set_zoom_y(chart, v);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,8 +25,8 @@ void lv_example_chart_6(void)
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, LV_ALIGN_CENTER, 0, -10);
|
||||
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 40);
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 10, 5, 10, 1, true, 30);
|
||||
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 40);
|
||||
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 10, 5, 10, 1, true, 30);
|
||||
|
||||
lv_obj_add_event(chart, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_refresh_ext_draw_size(chart);
|
||||
@@ -39,7 +39,7 @@ void lv_example_chart_6(void)
|
||||
lv_chart_set_next_value(chart, ser, lv_rand(10, 90));
|
||||
}
|
||||
|
||||
lv_chart_set_zoom_x(chart, 500);
|
||||
// lv_chart_set_zoom_x(chart, 500);
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Click on a point");
|
||||
|
||||
@@ -50,8 +50,8 @@ void lv_example_chart_7(void)
|
||||
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_SCATTER);
|
||||
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 5, 5, 5, 1, true, 30);
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 50);
|
||||
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_X, 5, 5, 5, 1, true, 30);
|
||||
// lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 50);
|
||||
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_X, 0, 200);
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, 0, 1000);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
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
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
#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
|
||||
@@ -1,53 +0,0 @@
|
||||
import utime as time
|
||||
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
|
||||
meter.set_scale_ticks(41, 2, 10, lv.palette_main(lv.PALETTE.GREY))
|
||||
meter.set_scale_major_ticks(8, 4, 15, lv.color_black(), 10)
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#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
|
||||
@@ -1,65 +0,0 @@
|
||||
import utime as time
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#include "../../lv_examples.h"
|
||||
//TODO
|
||||
#if LV_USE_METER && LV_BUILD_EXAMPLES && 0
|
||||
|
||||
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_IMAGE_DECLARE(img_hand)
|
||||
|
||||
/*Add a the hands from images*/
|
||||
lv_meter_indicator_t * indic_min = lv_meter_add_needle_image(meter, &img_hand, 5, 5);
|
||||
lv_meter_indicator_t * indic_hour = lv_meter_add_needle_image(meter, &img_hand, 5, 5);
|
||||
|
||||
lv_obj_add_event(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
|
||||
@@ -1 +0,0 @@
|
||||
pass
|
||||
@@ -1,37 +0,0 @@
|
||||
#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
|
||||
@@ -1,33 +0,0 @@
|
||||
import utime as time
|
||||
|
||||
#
|
||||
# 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)
|
||||
|
||||
@@ -19,7 +19,7 @@ void lv_example_scale_2(void)
|
||||
lv_scale_set_minor_tick_length(scale, 5);
|
||||
lv_scale_set_range(scale, 0, 100);
|
||||
|
||||
static char * custom_labels[] = {"0 °C", "25 °C", "50 °C", "75 °C", "100 °C", NULL};
|
||||
static const char * custom_labels[] = {"0 °C", "25 °C", "50 °C", "75 °C", "100 °C", NULL};
|
||||
lv_scale_set_text_src(scale, custom_labels);
|
||||
|
||||
static lv_style_t indicator_style;
|
||||
@@ -40,7 +40,7 @@ void lv_example_scale_2(void)
|
||||
lv_style_set_line_color(&minor_ticks_style, lv_palette_lighten(LV_PALETTE_BLUE, 2));
|
||||
lv_style_set_width(&minor_ticks_style, 5U); /*Tick length*/
|
||||
lv_style_set_line_width(&minor_ticks_style, 2U); /*Tick width*/
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_ITEMS);
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_TICKS);
|
||||
|
||||
static lv_style_t main_line_style;
|
||||
lv_style_init(&main_line_style);
|
||||
@@ -78,6 +78,10 @@ void lv_example_scale_2(void)
|
||||
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_pad_ver(scale, 20, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@ void lv_example_scale_4(void)
|
||||
lv_obj_t * scale = lv_scale_create(lv_scr_act());
|
||||
lv_obj_set_size(scale, 150, 150);
|
||||
lv_scale_set_label_show(scale, true);
|
||||
lv_scale_set_mode(scale, LV_SCALE_MODE_ROUND_OUTTER);
|
||||
lv_scale_set_mode(scale, LV_SCALE_MODE_ROUND_OUTER);
|
||||
lv_obj_center(scale);
|
||||
|
||||
lv_scale_set_total_tick_count(scale, 20);
|
||||
@@ -19,7 +19,7 @@ void lv_example_scale_4(void)
|
||||
lv_scale_set_minor_tick_length(scale, 5);
|
||||
lv_scale_set_range(scale, 0, 100);
|
||||
|
||||
static char * custom_labels[] = {"0 °C", "25 °C", "50 °C", "75 °C", "100 °C", NULL};
|
||||
static const char * custom_labels[] = {"0 °C", "25 °C", "50 °C", "75 °C", "100 °C", NULL};
|
||||
lv_scale_set_text_src(scale, custom_labels);
|
||||
|
||||
static lv_style_t indicator_style;
|
||||
@@ -40,7 +40,7 @@ void lv_example_scale_4(void)
|
||||
lv_style_set_line_color(&minor_ticks_style, lv_palette_lighten(LV_PALETTE_BLUE, 2));
|
||||
lv_style_set_width(&minor_ticks_style, 5U); /*Tick length*/
|
||||
lv_style_set_line_width(&minor_ticks_style, 2U); /*Tick width*/
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_ITEMS);
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_TICKS);
|
||||
|
||||
static lv_style_t main_line_style;
|
||||
lv_style_init(&main_line_style);
|
||||
|
||||
@@ -17,7 +17,7 @@ void lv_example_scale_5(void)
|
||||
lv_scale_set_minor_tick_length(scale, 5);
|
||||
lv_scale_set_range(scale, 25, 35);
|
||||
|
||||
static char * custom_labels[3] = {"One", "Two", NULL};
|
||||
static const char * custom_labels[3] = {"One", "Two", NULL};
|
||||
lv_scale_set_text_src(scale, custom_labels);
|
||||
|
||||
static lv_style_t indicator_style;
|
||||
@@ -36,7 +36,7 @@ void lv_example_scale_5(void)
|
||||
lv_style_set_line_color(&minor_ticks_style, lv_color_hex(0xff0000));
|
||||
lv_style_set_width(&minor_ticks_style, 5U); // Tick length
|
||||
lv_style_set_line_width(&minor_ticks_style, 2U); // Tick width
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_ITEMS);
|
||||
lv_obj_add_style(scale, &minor_ticks_style, LV_PART_TICKS);
|
||||
|
||||
static lv_style_t main_line_style;
|
||||
lv_style_init(&main_line_style);
|
||||
|
||||
@@ -64,7 +64,6 @@ extern "C" {
|
||||
#include "src/widgets/line/lv_line.h"
|
||||
#include "src/widgets/list/lv_list.h"
|
||||
#include "src/widgets/menu/lv_menu.h"
|
||||
#include "src/widgets/meter/lv_meter.h"
|
||||
#include "src/widgets/msgbox/lv_msgbox.h"
|
||||
#include "src/widgets/roller/lv_roller.h"
|
||||
#include "src/widgets/scale/lv_scale.h"
|
||||
|
||||
@@ -335,6 +335,13 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, int32_t id)
|
||||
else return obj->spec_attr->children[id];
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_sibling(const lv_obj_t * obj, int32_t id)
|
||||
{
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
return lv_obj_get_child(parent, (int32_t)lv_obj_get_index(obj) + id);
|
||||
}
|
||||
|
||||
|
||||
uint32_t lv_obj_get_child_cnt(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
@@ -140,6 +140,19 @@ struct _lv_obj_t * lv_obj_get_parent(const struct _lv_obj_t * obj);
|
||||
*/
|
||||
struct _lv_obj_t * lv_obj_get_child(const struct _lv_obj_t * obj, int32_t id);
|
||||
|
||||
/**
|
||||
* Return a sibling of an object
|
||||
* @param obj pointer to an object whose sibling should be get
|
||||
* @param id 0: `obj` itself
|
||||
* -1: the first older sibling
|
||||
* -2: the next older sibling
|
||||
* 1: the first younger sibling
|
||||
* 2: the next younger sibling
|
||||
* etc
|
||||
* @return pointer to the requested sibling or NULL if there is no such sibling
|
||||
*/
|
||||
struct _lv_obj_t * lv_obj_get_sibling(const struct _lv_obj_t * obj, int32_t id);
|
||||
|
||||
/**
|
||||
* Get the number of children
|
||||
* @param obj pointer to an object
|
||||
|
||||
@@ -653,10 +653,10 @@ 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, lv_color_black());
|
||||
lv_style_set_line_width(&theme->styles.scale, 2U);
|
||||
lv_style_set_arc_color(&theme->styles.scale, lv_color_black());
|
||||
lv_style_set_arc_width(&theme->styles.scale, 2U);
|
||||
lv_style_set_line_color(&theme->styles.scale, theme->color_grey);
|
||||
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_width(&theme->styles.scale, LV_DPX(2));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1209,7 +1209,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
else if(lv_obj_check_type(obj, &lv_scale_class)) {
|
||||
lv_obj_add_style(obj, &theme->styles.scale, LV_PART_MAIN);
|
||||
lv_obj_add_style(obj, &theme->styles.scale, LV_PART_INDICATOR);
|
||||
lv_obj_add_style(obj, &theme->styles.scale, LV_PART_ITEMS);
|
||||
lv_obj_add_style(obj, &theme->styles.scale, LV_PART_TICKS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+38
-354
File diff suppressed because it is too large
Load Diff
@@ -107,21 +107,11 @@ typedef struct {
|
||||
uint32_t pos_set: 1; /*1: pos is set; 0: point_id is set*/
|
||||
} lv_chart_cursor_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t major_len;
|
||||
lv_coord_t minor_len;
|
||||
lv_coord_t draw_size;
|
||||
uint32_t minor_cnt : 15;
|
||||
uint32_t major_cnt : 15;
|
||||
uint32_t label_en : 1;
|
||||
} lv_chart_tick_dsc_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_ll_t series_ll; /**< Linked list for the series (stores lv_chart_series_t)*/
|
||||
lv_ll_t cursor_ll; /**< Linked list for the cursors (stores lv_chart_cursor_t)*/
|
||||
lv_chart_tick_dsc_t tick[4];
|
||||
lv_coord_t ymin[2];
|
||||
lv_coord_t ymax[2];
|
||||
lv_coord_t xmin[2];
|
||||
@@ -130,8 +120,6 @@ typedef struct {
|
||||
uint32_t hdiv_cnt; /**< Number of horizontal division lines*/
|
||||
uint32_t vdiv_cnt; /**< Number of vertical division lines*/
|
||||
uint32_t point_cnt; /**< Point number in a data line*/
|
||||
uint32_t zoom_x;
|
||||
uint32_t zoom_y;
|
||||
lv_chart_type_t type : 3; /**< Line or column chart*/
|
||||
lv_chart_update_mode_t update_mode : 1;
|
||||
} lv_chart_t;
|
||||
@@ -451,6 +439,14 @@ lv_coord_t * lv_chart_get_x_array(const lv_obj_t * obj, lv_chart_series_t * ser)
|
||||
*/
|
||||
uint32_t lv_chart_get_pressed_point(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the overall offset from the chart's side to the center of the first point.
|
||||
* In case of a bar chart it will be the center of the first column group
|
||||
* @param obj pointer to a chart object
|
||||
* @return the offset of the center
|
||||
*/
|
||||
int32_t lv_chart_get_first_point_center_offset(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,235 +0,0 @@
|
||||
/**
|
||||
* @file lv_meter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_METER_H
|
||||
#define LV_METER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_METER != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
enum _lv_meter_indicator_type_t {
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_IMG,
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_LINE,
|
||||
LV_METER_INDICATOR_TYPE_SCALE_LINES,
|
||||
LV_METER_INDICATOR_TYPE_ARC,
|
||||
};
|
||||
|
||||
#ifdef DOXYGEN
|
||||
typedef _lv_meter_indicator_type_t lv_meter_indicator_type_t;
|
||||
#else
|
||||
typedef uint8_t lv_meter_indicator_type_t;
|
||||
#endif /*DOXYGEN*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
lv_meter_indicator_type_t type;
|
||||
lv_opa_t opa;
|
||||
int32_t start_value;
|
||||
int32_t end_value;
|
||||
union {
|
||||
struct {
|
||||
const void * src;
|
||||
lv_point_t pivot;
|
||||
} needle_img;
|
||||
struct {
|
||||
uint16_t width;
|
||||
int16_t r_mod;
|
||||
lv_color_t color;
|
||||
} needle_line;
|
||||
struct {
|
||||
uint16_t width;
|
||||
const void * src;
|
||||
lv_color_t color;
|
||||
int16_t r_mod;
|
||||
} arc;
|
||||
struct {
|
||||
int16_t width_mod;
|
||||
lv_color_t color_start;
|
||||
lv_color_t color_end;
|
||||
uint8_t local_grad : 1;
|
||||
} scale_lines;
|
||||
} type_data;
|
||||
} lv_meter_indicator_t;
|
||||
|
||||
/*Data of line meter*/
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
struct {
|
||||
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;
|
||||
} scale;
|
||||
lv_ll_t indicator_ll;
|
||||
} lv_meter_t;
|
||||
|
||||
extern const lv_obj_class_t lv_meter_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a Meter object
|
||||
* @param parent pointer to an object, it will be the parent of the new bar.
|
||||
* @return pointer to the created meter
|
||||
*/
|
||||
lv_obj_t * lv_meter_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set the properties of the ticks of a scale
|
||||
* @param obj pointer to a meter object
|
||||
* @param cnt number of tick lines
|
||||
* @param width width of tick lines
|
||||
* @param len length of tick lines
|
||||
* @param color color of tick lines
|
||||
*/
|
||||
void lv_meter_set_scale_ticks(lv_obj_t * obj, uint16_t cnt, uint16_t width, uint16_t len,
|
||||
lv_color_t color);
|
||||
|
||||
/**
|
||||
* Make some "normal" ticks major ticks and set their attributes.
|
||||
* Texts with the current value are also added to the major ticks.
|
||||
* @param obj pointer to a meter object
|
||||
* @param nth make every Nth normal tick major tick. (start from the first on the left)
|
||||
* @param width width of the major ticks
|
||||
* @param len length of the major ticks
|
||||
* @param color color of the major ticks
|
||||
* @param label_gap gap between the major ticks and the labels
|
||||
*/
|
||||
void lv_meter_set_scale_major_ticks(lv_obj_t * obj, uint16_t nth, uint16_t width,
|
||||
uint16_t len, lv_color_t color, int16_t label_gap);
|
||||
|
||||
/**
|
||||
* Set the value and angular range of a scale.
|
||||
* @param obj pointer to a meter object
|
||||
* @param min the minimum value
|
||||
* @param max the maximal value
|
||||
* @param angle_range the angular range of the scale
|
||||
* @param rotation the angular offset from the 3 o'clock position (clock-wise)
|
||||
*/
|
||||
void lv_meter_set_scale_range(lv_obj_t * obj, int32_t min, int32_t max, uint32_t angle_range,
|
||||
uint32_t rotation);
|
||||
|
||||
/*=====================
|
||||
* Add indicator
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Add a needle line indicator the scale
|
||||
* @param obj pointer to a meter object
|
||||
* @param width width of the line
|
||||
* @param color color of the line
|
||||
* @param r_mod the radius modifier (added to the scale's radius) to get the lines length
|
||||
* @return the new indicator or NULL on allocation failure.
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, uint16_t width,
|
||||
lv_color_t color, int16_t r_mod);
|
||||
|
||||
/**
|
||||
* Add a needle image indicator the scale
|
||||
* @param obj pointer to a meter object
|
||||
* @param src the image source of the indicator. path or pointer to ::lv_image_dsc_t
|
||||
* @param pivot_x the X pivot point of the needle
|
||||
* @param pivot_y the Y pivot point of the needle
|
||||
* @return the new indicator or NULL on allocation failure.
|
||||
* @note the needle image should point to the right, like -O----->
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_needle_image(lv_obj_t * obj, const void * src,
|
||||
lv_coord_t pivot_x, lv_coord_t pivot_y);
|
||||
|
||||
/**
|
||||
* Add an arc indicator the scale
|
||||
* @param obj pointer to a meter object
|
||||
* @param width width of the arc
|
||||
* @param color color of the arc
|
||||
* @param r_mod the radius modifier (added to the scale's radius) to get the outer radius of the arc
|
||||
* @return the new indicator or NULL on allocation failure.
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, uint16_t width, lv_color_t color,
|
||||
int16_t r_mod);
|
||||
|
||||
|
||||
/**
|
||||
* Add a scale line indicator the scale. It will modify the ticks.
|
||||
* @param obj pointer to a meter object
|
||||
* @param color_start the start color
|
||||
* @param color_end the end color
|
||||
* @param local tell how to map start and end color. true: the indicator's start and end_value; false: the scale's min max value
|
||||
* @param width_mod add this the affected tick's width
|
||||
* @return the new indicator or NULL on allocation failure.
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_color_t color_start,
|
||||
lv_color_t color_end, bool local, int16_t width_mod);
|
||||
|
||||
/*=====================
|
||||
* Set indicator value
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the value of the indicator. It will set start and and value to the same value
|
||||
* @param obj pointer to a meter object
|
||||
* @param indic pointer to an indicator
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_meter_set_indicator_value(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value);
|
||||
|
||||
/**
|
||||
* Set the start value of the indicator.
|
||||
* @param obj pointer to a meter object
|
||||
* @param indic pointer to an indicator
|
||||
* @param 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.
|
||||
* @param obj pointer to a meter object
|
||||
* @param indic pointer to an indicator
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_METER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_METER_H*/
|
||||
@@ -182,17 +182,18 @@ void lv_scale_set_round_props(lv_obj_t * obj, uint32_t angle_range, int32_t rota
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_scale_set_text_src(lv_obj_t * obj, char * txt_src[])
|
||||
void lv_scale_set_text_src(lv_obj_t * obj, const char * txt_src[])
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_scale_t * scale = (lv_scale_t *)obj;
|
||||
|
||||
scale->txt_src = txt_src;
|
||||
|
||||
scale->custom_label_cnt = 0;
|
||||
lv_coord_t idx;
|
||||
for(idx = 0; txt_src[idx]; ++idx) {
|
||||
scale->custom_label_cnt++;
|
||||
if(scale->txt_src) {
|
||||
lv_coord_t idx;
|
||||
for(idx = 0; txt_src[idx]; ++idx) {
|
||||
scale->custom_label_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
@@ -252,7 +253,7 @@ void lv_scale_section_set_style(lv_scale_section_t * section, uint32_t part, lv_
|
||||
case LV_PART_INDICATOR:
|
||||
section->indicator_style = section_part_style;
|
||||
break;
|
||||
case LV_PART_ITEMS:
|
||||
case LV_PART_TICKS:
|
||||
section->items_style = section_part_style;
|
||||
break;
|
||||
default:
|
||||
@@ -261,7 +262,6 @@ void lv_scale_section_set_style(lv_scale_section_t * section, uint32_t part, lv_
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -375,7 +375,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
|
||||
/* Configure line draw descriptor for the minor tick drawing */
|
||||
lv_draw_line_dsc_t minor_tick_dsc;
|
||||
lv_draw_line_dsc_init(&minor_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &minor_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_TICKS, &minor_tick_dsc);
|
||||
|
||||
/* Main line style */
|
||||
lv_draw_line_dsc_t main_line_dsc;
|
||||
@@ -405,14 +405,14 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
|
||||
scale_set_line_properties(obj, &major_tick_dsc, section->indicator_style, LV_PART_INDICATOR);
|
||||
}
|
||||
else {
|
||||
scale_set_line_properties(obj, &minor_tick_dsc, section->items_style, LV_PART_ITEMS);
|
||||
scale_set_line_properties(obj, &minor_tick_dsc, section->items_style, LV_PART_TICKS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Tick is not in section, get the proper styles */
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_INDICATOR, &label_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &major_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &minor_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_TICKS, &minor_tick_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
lv_area_t scale_area;
|
||||
lv_obj_get_content_coords(obj, &scale_area);
|
||||
|
||||
@@ -493,14 +493,14 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
|
||||
scale_set_line_properties(obj, &major_tick_dsc, section->indicator_style, LV_PART_INDICATOR);
|
||||
}
|
||||
else {
|
||||
scale_set_line_properties(obj, &minor_tick_dsc, section->items_style, LV_PART_ITEMS);
|
||||
scale_set_line_properties(obj, &minor_tick_dsc, section->items_style, LV_PART_TICKS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Tick is not in section, get the proper styles */
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_INDICATOR, &label_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &major_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &minor_tick_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_TICKS, &minor_tick_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ static void scale_draw_indicator(lv_obj_t * obj, lv_event_t * event)
|
||||
if(LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
radius_text = (radius_edge - scale->major_len) - (label_gap + label_dsc.letter_space);
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode) {
|
||||
radius_text = (radius_edge + scale->major_len) + (label_gap + label_dsc.letter_space);
|
||||
}
|
||||
else { /* Nothing to do */ }
|
||||
@@ -616,7 +616,7 @@ static void scale_draw_main(lv_obj_t * obj, lv_event_t * event)
|
||||
main_line_point_a.x = x_ofs - 1U;
|
||||
main_line_point_a.y = y_ofs;
|
||||
main_line_point_b.x = x_ofs - 1U;
|
||||
main_line_point_b.y = obj->coords.y2 - pad_left;
|
||||
main_line_point_b.y = obj->coords.y2 - pad_bottom;
|
||||
|
||||
/* Adjust main line with initial and last tick width */
|
||||
main_line_point_a.y -= scale->last_tick_width / 2U;
|
||||
@@ -679,7 +679,7 @@ static void scale_draw_main(lv_obj_t * obj, lv_event_t * event)
|
||||
lv_draw_line(layer, &main_line_section_dsc);
|
||||
}
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
/* Configure arc draw descriptors for the main part */
|
||||
lv_draw_arc_dsc_t arc_dsc;
|
||||
lv_draw_arc_dsc_init(&arc_dsc);
|
||||
@@ -873,7 +873,7 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool
|
||||
tick_point_b->y = tick_point_a->y + tick_length;
|
||||
}
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
lv_area_t scale_area;
|
||||
lv_obj_get_content_coords(obj, &scale_area);
|
||||
|
||||
@@ -895,7 +895,7 @@ static void scale_get_tick_points(lv_obj_t * obj, const uint32_t tick_idx, bool
|
||||
point_closer_to_arc = radius_edge - main_line_dsc.width;
|
||||
adjusted_radio_with_tick_len = point_closer_to_arc - (is_major_tick ? major_len : minor_len);
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode) {
|
||||
point_closer_to_arc = radius_edge - main_line_dsc.width;
|
||||
adjusted_radio_with_tick_len = point_closer_to_arc + (is_major_tick ? major_len : minor_len);
|
||||
}
|
||||
@@ -957,7 +957,7 @@ static void scale_get_label_coords(lv_obj_t * obj, lv_draw_label_dsc_t * label_d
|
||||
label_coords->x2 = tick_point->x + label_size.x + lv_obj_get_style_pad_right(obj, LV_PART_INDICATOR);
|
||||
}
|
||||
}
|
||||
else if(LV_SCALE_MODE_ROUND_OUTTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
else if(LV_SCALE_MODE_ROUND_OUTER == scale->mode || LV_SCALE_MODE_ROUND_INNER == scale->mode) {
|
||||
label_coords->x1 = tick_point->x - (label_size.x / 2U);
|
||||
label_coords->y1 = tick_point->y - (label_size.y / 2U);
|
||||
label_coords->x2 = label_coords->x1 + label_size.x;
|
||||
@@ -974,7 +974,7 @@ static void scale_get_label_coords(lv_obj_t * obj, lv_draw_label_dsc_t * label_d
|
||||
* @param obj pointer to a scale object
|
||||
* @param line_dsc pointer to line descriptor
|
||||
* @param items_section_style pointer to indicator section style
|
||||
* @param part line part, example: LV_PART_INDICATOR, LV_PART_ITEMS, LV_PART_MAIN
|
||||
* @param part line part, example: LV_PART_INDICATOR, LV_PART_TICKS, LV_PART_MAIN
|
||||
*/
|
||||
static void scale_set_line_properties(lv_obj_t * obj, lv_draw_line_dsc_t * line_dsc, lv_style_t * section_style,
|
||||
uint32_t part)
|
||||
@@ -1183,7 +1183,7 @@ static void scale_store_main_line_tick_width_compensation(lv_obj_t * obj, const
|
||||
else if((LV_SCALE_MODE_HORIZONTAL_BOTTOM == scale->mode) || (LV_SCALE_MODE_HORIZONTAL_TOP == scale->mode)) {
|
||||
scale->first_tick_width = is_major_tick ? major_tick_width : minor_tick_width;
|
||||
}
|
||||
else if((LV_SCALE_MODE_ROUND_INNER == scale->mode) || (LV_SCALE_MODE_ROUND_OUTTER == scale->mode)) {
|
||||
else if((LV_SCALE_MODE_ROUND_INNER == scale->mode) || (LV_SCALE_MODE_ROUND_OUTER == scale->mode)) {
|
||||
/* TODO */
|
||||
}
|
||||
else { /* Nothing to do */ }
|
||||
@@ -1195,7 +1195,7 @@ static void scale_store_main_line_tick_width_compensation(lv_obj_t * obj, const
|
||||
else if((LV_SCALE_MODE_HORIZONTAL_BOTTOM == scale->mode) || (LV_SCALE_MODE_HORIZONTAL_TOP == scale->mode)) {
|
||||
scale->last_tick_width = is_major_tick ? major_tick_width : minor_tick_width;
|
||||
}
|
||||
else if((LV_SCALE_MODE_ROUND_INNER == scale->mode) || (LV_SCALE_MODE_ROUND_OUTTER == scale->mode)) {
|
||||
else if((LV_SCALE_MODE_ROUND_INNER == scale->mode) || (LV_SCALE_MODE_ROUND_OUTER == scale->mode)) {
|
||||
/* TODO */
|
||||
}
|
||||
else { /* Nothing to do */ }
|
||||
@@ -1259,7 +1259,7 @@ static void scale_store_section_line_tick_width_compensation(lv_obj_t * obj, con
|
||||
scale_set_line_properties(obj, major_tick_dsc, section->indicator_style, LV_PART_INDICATOR);
|
||||
}
|
||||
else {
|
||||
scale_set_line_properties(obj, minor_tick_dsc, section->items_style, LV_PART_ITEMS);
|
||||
scale_set_line_properties(obj, minor_tick_dsc, section->items_style, LV_PART_TICKS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ enum {
|
||||
LV_SCALE_MODE_VERTICAL_LEFT = 0x02U,
|
||||
LV_SCALE_MODE_VERTICAL_RIGHT = 0x04U,
|
||||
LV_SCALE_MODE_ROUND_INNER = 0x08U,
|
||||
LV_SCALE_MODE_ROUND_OUTTER = 0x10U,
|
||||
LV_SCALE_MODE_ROUND_OUTER = 0x10U,
|
||||
_LV_SCALE_MODE_LAST
|
||||
};
|
||||
typedef uint32_t lv_scale_mode_t;
|
||||
@@ -72,7 +72,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_ll_t section_ll; /**< Linked list for the sections (stores lv_scale_section_t)*/
|
||||
char ** txt_src;
|
||||
const char ** txt_src;
|
||||
lv_coord_t custom_label_cnt;
|
||||
lv_coord_t major_len;
|
||||
lv_coord_t minor_len;
|
||||
@@ -174,7 +174,7 @@ void lv_scale_set_round_props(lv_obj_t * obj, uint32_t angle_range, int32_t rota
|
||||
* @param obj pointer to a scale object
|
||||
* @param txt_src pointer to an array of strings which will be display at major ticks
|
||||
*/
|
||||
void lv_scale_set_text_src(lv_obj_t * obj, char * txt_src[]);
|
||||
void lv_scale_set_text_src(lv_obj_t * obj, const char * txt_src[]);
|
||||
|
||||
/**
|
||||
* Draw the scale after all the children are drawn
|
||||
|
||||
@@ -104,16 +104,4 @@ void test_chart_one_point_when_setting_point_count_to_zero(void)
|
||||
TEST_ASSERT_EQUAL(1u, lv_chart_get_point_count(chart));
|
||||
}
|
||||
|
||||
void test_chart_set_zoom_y_to_none_when_factor_is_less_than_256(void)
|
||||
{
|
||||
lv_chart_set_zoom_y(chart, 128);
|
||||
TEST_ASSERT_EQUAL(LV_SCALE_NONE, lv_chart_get_zoom_y(chart));
|
||||
}
|
||||
|
||||
void test_chart_set_zoom_x_to_none_when_factor_is_less_than_256(void)
|
||||
{
|
||||
lv_chart_set_zoom_x(chart, 128);
|
||||
TEST_ASSERT_EQUAL(LV_SCALE_NONE, lv_chart_get_zoom_x(chart));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user