mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 00:51:49 +08:00
lv_gauge: add comments about how to calculate the line_cnt
This commit is contained in:
+5
-2
@@ -186,11 +186,14 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value)
|
||||
* Set the scale settings of a gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param line_cnt count of scale lines
|
||||
* @param label_cnt count of scale labels
|
||||
* @param line_cnt count of scale lines.
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1
|
||||
* @param label_cnt count of scale labels.
|
||||
*/
|
||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt)
|
||||
{
|
||||
/*TODO v6.0: change `line_cnt` to `subdiv_cnt`*/
|
||||
|
||||
lv_lmeter_set_scale(gauge, angle, line_cnt);
|
||||
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
+3
-2
@@ -107,8 +107,9 @@ static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)
|
||||
* Set the scale settings of a gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param line_cnt count of scale lines
|
||||
* @param label_cnt count of scale labels
|
||||
* @param line_cnt count of scale lines.
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1
|
||||
* @param label_cnt count of scale labels.
|
||||
*/
|
||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);
|
||||
|
||||
|
||||
+2
-4
@@ -276,7 +276,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
|
||||
style_tmp.line.color = style->body.main_color;
|
||||
|
||||
/*Calculate every coordinate in x32 size to make rounding later*/
|
||||
/*Calculate every coordinate in a bigger size to make rounding later*/
|
||||
r_out = r_out << LV_LMETER_LINE_UPSCALE;
|
||||
r_in = r_in << LV_LMETER_LINE_UPSCALE;
|
||||
|
||||
@@ -363,12 +363,10 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par
|
||||
static lv_coord_t lv_lmeter_coord_round(int32_t x)
|
||||
{
|
||||
#if LV_LMETER_LINE_UPSCALE > 0
|
||||
bool was_negative;
|
||||
bool was_negative = false;
|
||||
if(x < 0) {
|
||||
was_negative = true;
|
||||
x = -x;
|
||||
} else {
|
||||
was_negative = false;
|
||||
}
|
||||
|
||||
x = (x >> LV_LMETER_LINE_UPSCALE) + ((x & LV_LMETER_LINE_UPSCALE_MASK) >> (LV_LMETER_LINE_UPSCALE - 1));
|
||||
|
||||
Reference in New Issue
Block a user