minor fixes + lv_sqrt() optmization

This commit is contained in:
Gabor Kiss-Vamosi
2020-04-02 09:31:38 +02:00
parent ef7a8f3543
commit 163498e192
9 changed files with 98 additions and 183 deletions

View File

@@ -531,7 +531,7 @@ typedef void * lv_obj_user_data_t;
/*LED (dependencies: -)*/
#define LV_USE_LED 1
#if LV_USE_LED
# define LV_LED_BRIGHT_MIN 60 /*Minimal brightness*/
# define LV_LED_BRIGHT_MIN 80 /*Minimal brightness*/
# define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/
#endif

View File

@@ -780,7 +780,7 @@
#endif
#if LV_USE_LED
#ifndef LV_LED_BRIGHT_MIN
# define LV_LED_BRIGHT_MIN 60 /*Minimal brightness*/
# define LV_LED_BRIGHT_MIN 80 /*Minimal brightness*/
#endif
#ifndef LV_LED_BRIGHT_MAX
# define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/

View File

@@ -388,8 +388,6 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
}
/*Use the normal vector for the endings*/
lv_draw_mask_line_points_init(&mask_top_param, p1.x, p1.y, p1.x - ydiff, p1.y + xdiff, LV_DRAW_MASK_LINE_SIDE_BOTTOM);
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y, p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
int16_t mask_left_id = lv_draw_mask_add(&mask_left_param, NULL);
int16_t mask_right_id = lv_draw_mask_add(&mask_right_param, NULL);
@@ -397,6 +395,8 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
int16_t mask_bottom_id = LV_MASK_ID_INV;
if(!dsc->raw_end) {
lv_draw_mask_line_points_init(&mask_top_param, p1.x, p1.y, p1.x - ydiff, p1.y + xdiff, LV_DRAW_MASK_LINE_SIDE_BOTTOM);
lv_draw_mask_line_points_init(&mask_bottom_param, p2.x, p2.y, p2.x - ydiff, p2.y + xdiff, LV_DRAW_MASK_LINE_SIDE_TOP);
mask_top_id = lv_draw_mask_add(&mask_top_param, NULL);
mask_bottom_id = lv_draw_mask_add(&mask_bottom_param, NULL);
}

View File

@@ -99,15 +99,16 @@ lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_
bool changed = false;
lv_draw_mask_common_dsc_t * dsc;
uint8_t i;
for(i = 0; i < LV_MASK_MAX_NUM; i++) {
if(mask_list[i].param) {
dsc = mask_list[i].param;
lv_mask_saved_t * m = mask_list;
while(m->param) {
dsc = m->param;
lv_draw_mask_res_t res = LV_DRAW_MASK_RES_FULL_COVER;
res = dsc->cb(mask_buf, abs_x, abs_y, len, (void *)mask_list[i].param);
res = dsc->cb(mask_buf, abs_x, abs_y, len, (void *)m->param);
if(res == LV_DRAW_MASK_RES_FULL_TRANSP) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(res == LV_DRAW_MASK_RES_CHANGED) changed = true;
}
m++;
}
return changed ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
@@ -874,28 +875,33 @@ static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * mask_buf, lv_coord_t abs
static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
lv_draw_mask_radius_param_t * p)
{
if(p->cfg.outer == 0) {
if(abs_y < p->cfg.rect.y1 || abs_y > p->cfg.rect.y2) {
bool outer = p->cfg.outer;
int32_t radius = p->cfg.radius;
lv_area_t rect;
lv_area_copy(&rect, &p->cfg.rect);
if(outer == false) {
if(abs_y < rect.y1 || abs_y >rect.y2) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
}
}
else {
if(abs_y < p->cfg.rect.y1 || abs_y > p->cfg.rect.y2) {
if(abs_y < rect.y1 || abs_y > rect.y2) {
return LV_DRAW_MASK_RES_FULL_COVER;
}
}
if((abs_x >= p->cfg.rect.x1 + p->cfg.radius && abs_x + len <= p->cfg.rect.x2 - p->cfg.radius) ||
(abs_y >= p->cfg.rect.y1 + p->cfg.radius && abs_y <= p->cfg.rect.y2 - p->cfg.radius)) {
if(p->cfg.outer == 0) {
if((abs_x >= rect.x1 + radius && abs_x + len <= rect.x2 - radius) ||
(abs_y >= rect.y1 + radius && abs_y <= rect.y2 - radius)) {
if(outer == false) {
/*Remove the edges*/
int32_t last = p->cfg.rect.x1 - abs_x;
int32_t last = rect.x1 - abs_x;
if(last > len) return LV_DRAW_MASK_RES_FULL_TRANSP;
if(last >= 0) {
lv_memset_00(&mask_buf[0], last);
}
int32_t first = p->cfg.rect.x2 - abs_x + 1;
int32_t first = rect.x2 - abs_x + 1;
if(first <= 0) return LV_DRAW_MASK_RES_FULL_TRANSP;
else if(first < len) {
lv_memset_00(&mask_buf[first], len - first);
@@ -904,10 +910,10 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
else return LV_DRAW_MASK_RES_CHANGED;
}
else {
int32_t first = p->cfg.rect.x1 - abs_x;
int32_t first = rect.x1 - abs_x;
if(first < 0) first = 0;
if(first <= len) {
int32_t last = p->cfg.rect.x2 - abs_x - first + 1;
int32_t last = rect.x2 - abs_x - first + 1;
if(first + last > len) last = len - first;
if(last >= 0) {
lv_memset_00(&mask_buf[first], last);
@@ -917,28 +923,34 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
return LV_DRAW_MASK_RES_CHANGED;
}
int32_t k = p->cfg.rect.x1 - abs_x; /*First relevant coordinate on the of the mask*/
int32_t w = lv_area_get_width(&p->cfg.rect);
int32_t h = lv_area_get_height(&p->cfg.rect);
abs_x -= p->cfg.rect.x1;
abs_y -= p->cfg.rect.y1;
int32_t k = rect.x1 - abs_x; /*First relevant coordinate on the of the mask*/
int32_t w = lv_area_get_width(&rect);
int32_t h = lv_area_get_height(&rect);
abs_x -= rect.x1;
abs_y -= rect.y1;
uint32_t r2 = p->cfg.radius * p->cfg.radius;
/*Handle corner areas*/
if(abs_y < p->cfg.radius || abs_y > h - p->cfg.radius - 1) {
if(abs_y < radius || abs_y > h - radius - 1) {
uint32_t sqrt_mask;
if(radius <= 32) sqrt_mask = 0x200;
if(radius <= 256) sqrt_mask = 0x800;
else sqrt_mask = 0x8000;
/* y = 0 should mean the top of the circle */
int32_t y;
if(abs_y < p->cfg.radius) y = p->cfg.radius - abs_y;
else y = p->cfg.radius - (h - abs_y) + 1;
if(abs_y < radius) y = radius - abs_y;
else y = radius - (h - abs_y) + 1;
/* Get the x intersection points for `abs_y` and `abs_y+1`
* Use the circle's equation x = sqrt(r^2 - y^2) */
lv_sqrt_res_t x0;
lv_sqrt(r2 - (y * y), &x0);
lv_sqrt(r2 - (y * y), &x0, sqrt_mask);
lv_sqrt_res_t x1;
lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1);
lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask);
/* If x1 is on the next round coordinate (e.g. x0: 3.5, x1:4.0)
* then treat x1 as x1: 3.99 to handle them as they were on the same pixel*/
@@ -947,11 +959,11 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
x1.f = 0xFF;
}
/*If the two x intersections are on the same x then just get average of the fractionals*/
/*If the two x intersections are on the same x then just get average of the fractions*/
if(x0.i == x1.i) {
lv_opa_t m = (x0.f + x1.f) >> 1;
if(p->cfg.outer) m = 255 - m;
int32_t ofs = p->cfg.radius - x0.i - 1;
if(outer) m = 255 - m;
int32_t ofs = radius - x0.i - 1;
/*Left corner*/
int32_t kl = k + ofs;
@@ -967,7 +979,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
}
/*Clear the unused parts*/
if(p->cfg.outer == 0) {
if(outer == false) {
kr++;
if(kl > len) {
return LV_DRAW_MASK_RES_FULL_TRANSP;
@@ -996,11 +1008,11 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
}
/*Multiple pixels are affected. Get y intersection of the pixels*/
else {
int32_t ofs = p->cfg.radius - (x0.i + 1);
int32_t ofs = radius - (x0.i + 1);
int32_t kl = k + ofs;
int32_t kr = k + (w - ofs - 1);
if(p->cfg.outer) {
if(outer) {
int32_t first = kl + 1;
if(first < 0) first = 0;
@@ -1016,7 +1028,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
lv_sqrt_res_t y_prev;
lv_sqrt_res_t y_next;
lv_sqrt(r2 - (x0.i * x0.i), &y_prev);
lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask);
if(y_prev.f == 0) {
y_prev.i--;
@@ -1025,10 +1037,10 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
/*The first y intersection is special as it might be in the previous line*/
if(y_prev.i >= y) {
lv_sqrt(r2 - (i * i), &y_next);
lv_sqrt(r2 - (i * i), &y_next, sqrt_mask);
m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9);
if(p->cfg.outer) m = 255 - m;
if(outer) m = 255 - m;
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
kl--;
@@ -1039,10 +1051,10 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
/*Set all points which are crossed by the circle*/
for(; i <= x1.i; i++) {
lv_sqrt(r2 - (i * i), &y_next);
lv_sqrt(r2 - (i * i), &y_next, sqrt_mask);
m = (y_prev.f + y_next.f) >> 1;
if(p->cfg.outer) m = 255 - m;
if(outer) m = 255 - m;
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
kl--;
@@ -1054,14 +1066,14 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab
* the circle still has parts on the next one*/
if(y_prev.f) {
m = (y_prev.f * x1.f) >> 9;
if(p->cfg.outer) m = 255 - m;
if(outer) m = 255 - m;
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
kl--;
kr++;
}
if(p->cfg.outer == 0) {
if(outer == 0) {
kl++;
if(kl > len) {
return LV_DRAW_MASK_RES_FULL_TRANSP;

View File

@@ -35,6 +35,8 @@ static const int16_t sin0_90_table[] = {
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767
};
/**********************
* MACROS
**********************/
@@ -98,140 +100,28 @@ int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
return v1 + v2 + v3 + v4;
}
#define SQRT_BITSPERLONG 32
#define TOP2BITS(x) (x >> (SQRT_BITSPERLONG-2))
#define SQRT_CORE r = (r << 2) + TOP2BITS(x); x <<= 2; \
a <<= 1; \
e = (a << 1) + 1; \
if (r >= e) { r -= e; a++; } \
#define SQRT_CORE_8_TIMES SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE SQRT_CORE
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q)
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask)
{
x = x << 8; /*To get 4 bit precision. (sqrt(256) = 16 = 4 bit)*/
if(x == 0) {
q->f = 0;
q->i = 0;
return;
uint32_t root = 0;
uint32_t trial;
// http://ww1.microchip.com/...en/AppNotes/91040a.pdf
do {
trial = root + mask;
if ((uint32_t)trial * trial <= x) root = trial;
mask = mask >> 1;
trial = root + mask;
if ((uint32_t)trial * trial <= x) root = trial;
mask = mask >> 1;
} while(mask);
q->i = (uint32_t) root >> 4;
q->f = (uint32_t) (root & 0xf) << 4;
}
/*Look up table for x=1..1024*/
static const uint8_t ci[] = {
1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32,
};
static const uint8_t cf[] = {
0, 106, 187, 0, 60, 115, 165, 212, 0, 42, 81, 119, 155, 190, 223, 0, 32, 62, 92, 121, 149, 177, 204, 230,
0, 25, 50, 75, 99, 122, 145, 168, 191, 213, 235, 0, 21, 42, 63, 83, 103, 123, 143, 162, 181, 200, 219,
238, 0, 18, 36, 54, 72, 89, 107, 124, 141, 158, 174, 191, 207, 224, 240, 0, 16, 32, 47, 63, 78, 94, 109,
124, 139, 154, 169, 184, 198, 213, 227, 242, 0, 14, 28, 42, 56, 70, 84, 97, 111, 125, 138, 151, 165, 178,
191, 204, 217, 230, 243, 0, 13, 25, 38, 51, 63, 76, 88, 100, 113, 125, 137, 149, 161, 173, 185, 197, 209,
221, 233, 244, 0, 12, 23, 35, 46, 58, 69, 80, 92, 103, 114, 125, 136, 147, 158, 169, 180, 191, 202, 213,
224, 235, 245, 0, 11, 21, 32, 42, 53, 63, 74, 84, 95, 105, 115, 125, 136, 146, 156, 166, 176, 186, 196,
206, 216, 226, 236, 246, 0, 10, 20, 29, 39, 49, 59, 68, 78, 87, 97, 107, 116, 126, 135, 145, 154, 163,
173, 182, 191, 201, 210, 219, 228, 238, 247, 0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126,
135, 143, 152, 161, 170, 178, 187, 196, 204, 213, 222, 230, 239, 247, 0, 9, 17, 26, 34, 42, 51, 59, 68,
76, 84, 93, 101, 109, 118, 126, 134, 142, 151, 159, 167, 175, 183, 191, 200, 208, 216, 224, 232, 240, 248,
0, 8, 16, 24, 32, 40, 48, 56, 64, 71, 79, 87, 95, 103, 111, 118, 126, 134, 142, 149, 157, 165, 172, 180,
188, 195, 203, 211, 218, 226, 233, 241, 248, 0, 8, 15, 23, 30, 37, 45, 52, 60, 67, 75, 82, 89, 97, 104,
112, 119, 126, 133, 141, 148, 155, 163, 170, 177, 184, 192, 199, 206, 213, 220, 227, 235, 242, 249, 0, 7,
14, 21, 28, 35, 42, 50, 57, 64, 71, 78, 85, 92, 99, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 174,
181, 188, 195, 202, 209, 215, 222, 229, 236, 243, 249, 0, 7, 13, 20, 27, 34, 40, 47, 54, 60, 67, 74, 80,
87, 93, 100, 107, 113, 120, 126, 133, 139, 146, 153, 159, 166, 172, 179, 185, 192, 198, 205, 211, 217,
224, 230, 237, 243, 250, 0, 6, 13, 19, 26, 32, 38, 45, 51, 57, 64, 70, 76, 83, 89, 95, 101, 108, 114, 120,
126, 133, 139, 145, 151, 158, 164, 170, 176, 182, 189, 195, 201, 207, 213, 219, 225, 232, 238, 244, 250,
0, 6, 12, 18, 24, 30, 36, 42, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 132, 138, 144,
150, 156, 162, 168, 174, 180, 186, 192, 198, 203, 209, 215, 221, 227, 233, 239, 244, 250, 0, 6, 12, 17,
23, 29, 35, 41, 46, 52, 58, 64, 69, 75, 81, 87, 92, 98, 104, 109, 115, 121, 127, 132, 138, 144, 149, 155,
161, 166, 172, 178, 183, 189, 194, 200, 206, 211, 217, 223, 228, 234, 239, 245, 250, 0, 6, 11, 17, 22, 28,
33, 39, 44, 50, 55, 61, 66, 72, 77, 83, 88, 94, 99, 105, 110, 116, 121, 127, 132, 138, 143, 148, 154, 159,
165, 170, 175, 181, 186, 192, 197, 202, 208, 213, 219, 224, 229, 235, 240, 245, 251, 0, 5, 11, 16, 21, 27,
32, 37, 43, 48, 53, 58, 64, 69, 74, 79, 85, 90, 95, 101, 106, 111, 116, 121, 127, 132, 137, 142, 148, 153,
158, 163, 168, 174, 179, 184, 189, 194, 199, 205, 210, 215, 220, 225, 230, 235, 241, 246, 251, 0, 5, 10,
15, 20, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 92, 97, 102, 107, 112, 117, 122, 127, 132,
137, 142, 147, 152, 157, 162, 167, 172, 177, 182, 187, 192, 197, 202, 207, 212, 216, 221, 226, 231, 236,
241, 246, 251, 0, 5, 10, 15, 20, 25, 29, 34, 39, 44, 49, 54, 59, 64, 69, 73, 78, 83, 88, 93, 98, 103, 107,
112, 117, 122, 127, 132, 136, 141, 146, 151, 156, 161, 165, 170, 175, 180, 185, 189, 194, 199, 204, 208,
213, 218, 223, 227, 232, 237, 242, 247, 251, 0, 5, 9, 14, 19, 24, 28, 33, 38, 43, 47, 52, 57, 61, 66, 71,
75, 80, 85, 89, 94, 99, 104, 108, 113, 118, 122, 127, 131, 136, 141, 145, 150, 155, 159, 164, 169, 173,
178, 182, 187, 192, 196, 201, 206, 210, 215, 219, 224, 229, 233, 238, 242, 247, 251, 0, 5, 9, 14, 18, 23,
27, 32, 36, 41, 46, 50, 55, 59, 64, 68, 73, 77, 82, 86, 91, 95, 100, 104, 109, 113, 118, 122, 127, 131,
136, 140, 145, 149, 154, 158, 163, 167, 172, 176, 181, 185, 189, 194, 198, 203, 207, 212, 216, 221, 225,
229, 234, 238, 243, 247, 252, 0, 4, 9, 13, 18, 22, 26, 31, 35, 40, 44, 48, 53, 57, 62, 66, 70, 75, 79, 83,
88, 92, 96, 101, 105, 110, 114, 118, 123, 127, 131, 136, 140, 144, 149, 153, 157, 162, 166, 170, 175, 179,
183, 187, 192, 196, 200, 205, 209, 213, 218, 222, 226, 230, 235, 239, 243, 247, 252, 0, 4, 9, 13, 17, 21,
26, 30, 34, 38, 43, 47, 51, 55, 60, 64, 68, 72, 76, 81, 85, 89, 93, 98, 102, 106, 110, 114, 119, 123,
127, 131, 135, 140, 144, 148, 152, 156, 160, 165, 169, 173, 177, 181, 185, 190, 194, 198, 202, 206, 210,
215, 219, 223, 227, 231, 235, 239, 244, 248, 252, 0, 4, 8, 12, 16, 21, 25, 29, 33, 37, 41, 45, 49, 53, 58,
62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151,
155, 159, 163, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236,
240, 244, 248, 252, 0,
};
if(x <= 1024) {
x--;
q->i = ci[x];
q->f = cf[x];
return;
}
/*
* Source:
* http://web.archive.org/web/20080303101624/http://c.snippets.org/snip_lister.php?fname=isqrt.c
* https://stackoverflow.com/questions/1100090/looking-for-an-efficient-integer-square-root-algorithm-for-arm-thumb2
*/
uint32_t a = 0L; /* accumulator */
uint32_t r = 0L; /* remainder */
uint32_t e = 0L; /* trial product */
/*Unroll the loop*/
SQRT_CORE_8_TIMES
SQRT_CORE_8_TIMES
SQRT_CORE_8_TIMES
q->f = a & 0xFF;
q->i = a >> 8;
}
/**
* Calculate the atan2 of a vector.

View File

@@ -75,9 +75,7 @@ int16_t lv_trigo_sin(int16_t angle);
*/
int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3);
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q);
/**
/*
* Calculate the atan2 of a vector.
* @param x
* @param y
@@ -85,6 +83,18 @@ void lv_sqrt(uint32_t x, lv_sqrt_res_t * q);
*/
uint16_t lv_atan2(int x, int y);
/**
* Get the square root of a number
* @param x integer which square root should be calculatoed
* @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit
* @param mask: optional to skip some iterations if the magnitude of the root is known.
* Set to 0x8000 by default.
* If root < 16: mask = 0x80
* If root < 256: mask = 0x800
* Else: mask = 0x8000
*/
void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask);
/**********************
* MACROS
**********************/

View File

@@ -297,11 +297,11 @@ static void basic_init(void)
lv_style_set_pad_inner(&pad_inner, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_init(&pad_small);
lv_style_set_pad_left(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_right(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_top(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_bottom(&pad_small, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_inner(&pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
lv_style_set_pad_left(&pad_small, LV_STATE_DEFAULT, LV_DPI / 15);
lv_style_set_pad_right(&pad_small, LV_STATE_DEFAULT, LV_DPI / 15);
lv_style_set_pad_top(&pad_small, LV_STATE_DEFAULT, LV_DPI / 15);
lv_style_set_pad_bottom(&pad_small, LV_STATE_DEFAULT, LV_DPI / 15);
lv_style_set_pad_inner(&pad_small, LV_STATE_DEFAULT, LV_DPI / 25);
}
static void cont_init(void)

View File

@@ -113,6 +113,9 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
lv_gauge_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_gauge_set_needle_count(gauge, copy_ext->needle_count, copy_ext->needle_colors);
lv_style_list_copy(&ext->style_strong, &copy_ext->style_strong);
lv_style_list_copy(&ext->style_needle, &copy_ext->style_needle);
uint8_t i;
for(i = 0; i < ext->needle_count; i++) {
ext->values[i] = copy_ext->values[i];

View File

@@ -302,7 +302,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
mask_area.x2 = x_ofs + r_in - 1;
mask_area.y1 = y_ofs - r_in;
mask_area.y2 = y_ofs + r_in - 1;
lv_draw_mask_radius_param_t mask_in_param;
it lv_draw_mask_radius_param_t mask_in_param;
lv_draw_mask_radius_init(&mask_in_param, &mask_area, LV_RADIUS_CIRCLE, true);
int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, 0);