lv_gauge: add comments about how to calculate the line_cnt

This commit is contained in:
Gabor Kiss-Vamosi
2018-09-04 07:03:47 +02:00
parent 8db4e97d65
commit aa83d9109b
3 changed files with 10 additions and 8 deletions
+5 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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));