Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3

This commit is contained in:
Gabor Kiss-Vamosi 2019-01-04 08:33:30 +01:00
commit 31d18a21b2
4 changed files with 32 additions and 10 deletions

View File

@ -31,8 +31,7 @@ extern "C" {
#define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/ #define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/
#ifndef LV_VDB_PX_BPP #ifndef LV_VDB_PX_BPP
#warning "LV_VDB_PX_BPP is not specified in lv_conf.h. Use the default value (LV_COLOR_SIZE)" #define LV_VDB_PX_BPP LV_COLOR_SIZE /* Default is LV_COLOR_SIZE */
#define LV_VDB_PX_BPP LV_COLOR_SIZE
#endif #endif

View File

@ -32,7 +32,7 @@ extern "C" {
#define LV_LOG_LEVEL_ERROR 3 /*Only critical issue, when the system may fail*/ #define LV_LOG_LEVEL_ERROR 3 /*Only critical issue, when the system may fail*/
#define _LV_LOG_LEVEL_NUM 4 #define _LV_LOG_LEVEL_NUM 4
typedef uint8_t lv_log_level_t; typedef int8_t lv_log_level_t;
#if USE_LV_LOG #if USE_LV_LOG
/********************** /**********************

View File

@ -33,7 +33,8 @@ static int16_t sin0_90_table[] = {
25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087,
28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591, 28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591,
30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165,
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762,
32767
}; };
@ -117,13 +118,13 @@ int16_t lv_trigo_sin(int16_t angle)
if(angle < 90) { if(angle < 90) {
ret = sin0_90_table[angle]; ret = sin0_90_table[angle];
} else if(angle >= 90 && angle < 180) { } else if(angle >= 90 && angle < 180) {
angle = 179 - angle; angle = 180 - angle;
ret = sin0_90_table[angle]; ret = sin0_90_table[angle];
} else if(angle >= 180 && angle < 270) { } else if(angle >= 180 && angle < 270) {
angle = angle - 180; angle = angle - 180;
ret = - sin0_90_table[angle]; ret = - sin0_90_table[angle];
} else { /*angle >=270*/ } else { /*angle >=270*/
angle = 359 - angle; angle = 360 - angle;
ret = - sin0_90_table[angle]; ret = - sin0_90_table[angle];
} }

View File

@ -24,7 +24,8 @@
#define LV_GAUGE_DEF_LABEL_COUNT 6 #define LV_GAUGE_DEF_LABEL_COUNT 6
#define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/ #define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/
#define LV_GAUGE_DEF_ANGLE 220 #define LV_GAUGE_DEF_ANGLE 220
#define LV_GAUGE_INTERPOLATE_SHIFT 5 /*Interpolate the needle drawing between to degrees*/
#define LV_GAUGE_INTERPOLATE_MASK 0x1F
/********************** /**********************
* TYPEDEFS * TYPEDEFS
@ -406,6 +407,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
int16_t max = lv_gauge_get_max_value(gauge); int16_t max = lv_gauge_get_max_value(gauge);
lv_point_t p_mid; lv_point_t p_mid;
lv_point_t p_end; lv_point_t p_end;
lv_point_t p_end_low;
lv_point_t p_end_high;
uint8_t i; uint8_t i;
lv_style_copy(&style_needle, style); lv_style_copy(&style_needle, style);
@ -414,9 +417,28 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
p_mid.y = y_ofs; p_mid.y = y_ofs;
for(i = 0; i < ext->needle_count; i++) { for(i = 0; i < ext->needle_count; i++) {
/*Calculate the end point of a needle*/ /*Calculate the end point of a needle*/
int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs; int16_t needle_angle = (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) / (max - min); //+ angle_ofs;
p_end.y = (lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end.x = (lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
int16_t needle_angle_low = (needle_angle >> LV_GAUGE_INTERPOLATE_SHIFT) + angle_ofs;
int16_t needle_angle_high = needle_angle_low + 1;
p_end_low.y = (lv_trigo_sin(needle_angle_low) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end_low.x = (lv_trigo_sin(needle_angle_low + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
p_end_high.y = (lv_trigo_sin(needle_angle_high) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end_high.x = (lv_trigo_sin(needle_angle_high + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
uint16_t rem = needle_angle & ((1 << LV_GAUGE_INTERPOLATE_SHIFT) - 1);
int16_t x_mod = ((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
int16_t y_mod = ((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
if(p_end_high.x < p_end_low.x) x_mod = -x_mod;
if(p_end_high.y < p_end_low.y) y_mod = -y_mod;
p_end.x = p_end_low.x + x_mod;
p_end.y = p_end_low.y + y_mod;
/*Draw the needle with the corresponding color*/ /*Draw the needle with the corresponding color*/
if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR; if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;