BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
a50650ea
Commit
a50650ea
authored
Jun 15, 2016
by
Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Line upscale added
parent
305db368
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
32 deletions
+73
-32
lv_label.c
lv_objx/lv_label.c
+2
-3
lv_line.c
lv_objx/lv_line.c
+66
-27
lv_line.h
lv_objx/lv_line.h
+5
-2
No files found.
lv_objx/lv_label.c
View file @
a50650ea
...
...
@@ -91,13 +91,12 @@ lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * ori_dp)
lv_obj_set_opa
(
new_obj
,
OPA_COVER
);
lv_obj_set_click
(
new_obj
,
false
);
lv_obj_set_style
(
new_obj
,
&
lv_labels_def
);
lv_label_set_fixw
(
new_obj
,
false
);
lv_label_set_text
(
new_obj
,
"Text"
);
}
/*Copy 'ori_dp' if not NULL*/
else
{
lv_obj_set_opa
(
new_obj
,
lv_obj_get_opa
(
ori_dp
));
lv_obj_set_click
(
new_obj
,
lv_obj_get_click
(
ori_dp
));
lv_obj_set_style
(
new_obj
,
lv_obj_get_style
(
ori_dp
));
lv_label_set_fixw
(
new_obj
,
lv_label_get_fixw
(
ori_dp
));
lv_label_set_text
(
new_obj
,
lv_label_get_text
(
ori_dp
));
}
return
new_obj
;
...
...
lv_objx/lv_line.c
View file @
a50650ea
...
...
@@ -67,16 +67,17 @@ lv_obj_t* lv_line_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
dm_assert
(
new_obj_dp
);
/*Extend the basic object to rectangle object*/
lv_line_
t
*
line_ext_p
=
lv_obj_alloc_ext
(
new_obj_dp
,
sizeof
(
lv_line
_t
));
lv_line_
ext_t
*
ext_p
=
lv_obj_alloc_ext
(
new_obj_dp
,
sizeof
(
lv_line_ext
_t
));
lv_obj_set_design_f
(
new_obj_dp
,
lv_line_design
);
lv_obj_set_signal_f
(
new_obj_dp
,
lv_line_signal
);
/*Init the new rectangle*/
if
(
copy_dp
==
NULL
)
{
line_ext_p
->
point_num
=
0
;
line_ext_p
->
point_p
=
NULL
;
line_ext_p
->
auto_size
=
1
;
line_ext_p
->
y_inv
=
0
;
ext_p
->
point_num
=
0
;
ext_p
->
point_p
=
NULL
;
ext_p
->
auto_size
=
1
;
ext_p
->
y_inv
=
0
;
ext_p
->
upscale
=
1
;
lv_obj_set_style
(
new_obj_dp
,
&
lv_lines_def
);
}
/*Copy 'copy_p' is not NULL*/
...
...
@@ -84,8 +85,9 @@ lv_obj_t* lv_line_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
lv_line_set_auto_size
(
new_obj_dp
,
lv_line_get_auto_size
(
copy_dp
));
lv_line_set_y_inv
(
new_obj_dp
,
lv_line_get_y_inv
(
copy_dp
));
lv_line_set_auto_size
(
new_obj_dp
,
lv_line_get_auto_size
(
copy_dp
));
lv_line_set_points
(
new_obj_dp
,
LV_EA
(
copy_dp
,
lv_line_t
)
->
point_p
,
LV_EA
(
copy_dp
,
lv_line_t
)
->
point_num
);
lv_line_set_upscale
(
new_obj_dp
,
lv_line_get_upscale
(
copy_dp
));
lv_line_set_points
(
new_obj_dp
,
LV_EA
(
copy_dp
,
lv_line_ext_t
)
->
point_p
,
LV_EA
(
copy_dp
,
lv_line_ext_t
)
->
point_num
);
}
...
...
@@ -130,17 +132,22 @@ bool lv_line_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
*/
void
lv_line_set_points
(
lv_obj_t
*
obj_dp
,
const
point_t
*
point_a
,
uint16_t
point_num
)
{
lv_line_
t
*
line
_p
=
lv_obj_get_ext
(
obj_dp
);
line
_p
->
point_p
=
point_a
;
line
_p
->
point_num
=
point_num
;
lv_line_
ext_t
*
ext
_p
=
lv_obj_get_ext
(
obj_dp
);
ext
_p
->
point_p
=
point_a
;
ext
_p
->
point_num
=
point_num
;
if
(
point_num
>
0
&&
line_p
->
auto_size
!=
0
)
{
uint8_t
us
=
1
;
if
(
ext_p
->
upscale
!=
0
)
{
us
=
LV_DOWNSCALE
;
}
if
(
point_num
>
0
&&
ext_p
->
auto_size
!=
0
)
{
uint16_t
i
;
cord_t
xmax
=
LV_CORD_MIN
;
cord_t
ymax
=
LV_CORD_MIN
;
for
(
i
=
0
;
i
<
point_num
;
i
++
)
{
xmax
=
max
(
point_a
[
i
].
x
,
xmax
);
ymax
=
max
(
point_a
[
i
].
y
,
ymax
);
xmax
=
max
(
point_a
[
i
].
x
*
us
,
xmax
);
ymax
=
max
(
point_a
[
i
].
y
*
us
,
ymax
);
}
lv_lines_t
*
lines_p
=
lv_obj_get_style
(
obj_dp
);
...
...
@@ -156,7 +163,7 @@ void lv_line_set_points(lv_obj_t* obj_dp, const point_t * point_a, uint16_t poin
*/
void
lv_line_set_auto_size
(
lv_obj_t
*
obj_dp
,
bool
en
)
{
lv_line_t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
lv_line_
ext_
t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
line_p
->
auto_size
=
en
==
false
?
0
:
1
;
...
...
@@ -175,13 +182,28 @@ void lv_line_set_auto_size(lv_obj_t * obj_dp, bool en)
*/
void
lv_line_set_y_inv
(
lv_obj_t
*
obj_dp
,
bool
en
)
{
lv_line_t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
lv_line_
ext_
t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
line_p
->
y_inv
=
en
==
false
?
0
:
1
;
lv_obj_inv
(
obj_dp
);
}
/**
* Enable (or disable) the point coordinate upscaling (compensate LV_DOWNSCALE).
* @param obj_dp pointer to a line object
* @param en true: enable the point coordinate upscaling
*/
void
lv_line_set_upscale
(
lv_obj_t
*
obj_dp
,
bool
en
)
{
lv_line_ext_t
*
ext_p
=
lv_obj_get_ext
(
obj_dp
);
ext_p
->
upscale
=
en
==
false
?
0
:
1
;
/*Refresh to point to handle auto size*/
lv_line_set_points
(
obj_dp
,
ext_p
->
point_p
,
ext_p
->
point_num
);
}
/*=====================
* Getter functions
*====================*/
...
...
@@ -193,7 +215,7 @@ void lv_line_set_y_inv(lv_obj_t * obj_dp, bool en)
*/
bool
lv_line_get_auto_size
(
lv_obj_t
*
obj_dp
)
{
lv_line_t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
lv_line_
ext_
t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
return
line_p
->
auto_size
==
0
?
false
:
true
;
}
...
...
@@ -205,12 +227,24 @@ bool lv_line_get_auto_size(lv_obj_t * obj_dp)
*/
bool
lv_line_get_y_inv
(
lv_obj_t
*
obj_dp
)
{
lv_line_t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
lv_line_
ext_
t
*
line_p
=
lv_obj_get_ext
(
obj_dp
);
return
line_p
->
y_inv
==
0
?
false
:
true
;
}
/**
* Get the point upscale enable attribute
* @param obj_dp pointer to a line object
* @return true: point coordinate upscale is enabled, false: disabled
*/
bool
lv_line_get_upscale
(
lv_obj_t
*
obj_dp
)
{
lv_line_ext_t
*
ext_p
=
lv_obj_get_ext
(
obj_dp
);
return
ext_p
->
upscale
==
0
?
false
:
true
;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_lines_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
...
...
@@ -259,9 +293,9 @@ static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
/*A line never covers an area*/
if
(
mode
==
LV_DESIGN_COVER_CHK
)
return
false
;
lv_line_
t
*
line
_p
=
lv_obj_get_ext
(
obj_dp
);
lv_line_
ext_t
*
ext
_p
=
lv_obj_get_ext
(
obj_dp
);
if
(
line_p
->
point_num
==
0
||
line
_p
->
point_p
==
NULL
)
return
false
;
if
(
ext_p
->
point_num
==
0
||
ext
_p
->
point_p
==
NULL
)
return
false
;
lv_lines_t
*
lines_p
=
lv_obj_get_style
(
obj_dp
);
if
(
lines_p
->
bg_opa
!=
0
)
{
...
...
@@ -280,18 +314,23 @@ static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
point_t
p2
;
cord_t
h
=
lv_obj_get_height
(
obj_dp
);
uint16_t
i
;
uint8_t
us
=
1
;
if
(
ext_p
->
upscale
!=
0
)
{
us
=
LV_DOWNSCALE
;
}
/*Read all pints and draw the lines*/
for
(
i
=
0
;
i
<
line_p
->
point_num
-
1
;
i
++
)
{
p1
.
x
=
line_p
->
point_p
[
i
].
x
+
x_ofs
;
p2
.
x
=
line_p
->
point_p
[
i
+
1
].
x
+
x_ofs
;
for
(
i
=
0
;
i
<
ext_p
->
point_num
-
1
;
i
++
)
{
p1
.
x
=
ext_p
->
point_p
[
i
].
x
*
us
+
x_ofs
;
p2
.
x
=
ext_p
->
point_p
[
i
+
1
].
x
*
us
+
x_ofs
;
if
(
line
_p
->
y_inv
==
0
)
{
p1
.
y
=
line_p
->
point_p
[
i
].
y
+
y_ofs
;
p2
.
y
=
line_p
->
point_p
[
i
+
1
].
y
+
y_ofs
;
if
(
ext
_p
->
y_inv
==
0
)
{
p1
.
y
=
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
}
else
{
p1
.
y
=
h
-
line_p
->
point_p
[
i
].
y
+
y_ofs
;
p2
.
y
=
h
-
line_p
->
point_p
[
i
+
1
].
y
+
y_ofs
;
p1
.
y
=
h
-
ext_p
->
point_p
[
i
].
y
*
us
+
y_ofs
;
p2
.
y
=
h
-
ext_p
->
point_p
[
i
+
1
].
y
*
us
+
y_ofs
;
}
lv_draw_line
(
&
p1
,
&
p2
,
mask_p
,
lines_p
,
opa
);
}
...
...
lv_objx/lv_line.h
View file @
a50650ea
...
...
@@ -26,8 +26,9 @@ typedef struct
const
point_t
*
point_p
;
uint16_t
point_num
;
uint8_t
auto_size
:
1
;
uint8_t
y_inv
:
1
;
}
lv_line_t
;
uint8_t
y_inv
:
1
;
uint8_t
upscale
:
1
;
}
lv_line_ext_t
;
typedef
struct
{
...
...
@@ -53,8 +54,10 @@ lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p);
void
lv_line_set_points
(
lv_obj_t
*
obj_dp
,
const
point_t
*
point_a
,
uint16_t
point_num
);
void
lv_line_set_auto_size
(
lv_obj_t
*
obj_dp
,
bool
en
);
void
lv_line_set_y_inv
(
lv_obj_t
*
obj_dp
,
bool
en
);
void
lv_line_set_upscale
(
lv_obj_t
*
obj_dp
,
bool
en
);
bool
lv_line_get_auto_size
(
lv_obj_t
*
obj_dp
);
bool
lv_line_get_y_inv
(
lv_obj_t
*
obj_dp
);
bool
lv_line_get_upscale
(
lv_obj_t
*
obj_dp
);
/**********************
* MACROS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment