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
eb376899
Commit
eb376899
authored
Mar 04, 2018
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove sprintf from lv_gauge the save ROM (custom BCD converter added to lv_math.c)
parent
2123ee02
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
1 deletion
+100
-1
lv_math.c
lv_misc/lv_math.c
+96
-0
lv_math.h
lv_misc/lv_math.h
+2
-0
lv_gauge.c
lv_objx/lv_gauge.c
+2
-1
No files found.
lv_misc/lv_math.c
0 → 100644
View file @
eb376899
/**
* @file lv_math.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_math.h"
#include <stdbool.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Convert a number to string
* @param num a number
* @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements)
*/
void
lv_math_num_to_str
(
int32_t
num
,
char
*
buf
)
{
char
*
buf_ori
=
buf
;
if
(
num
==
0
)
{
buf
[
0
]
=
'0'
;
buf
[
1
]
=
'\0'
;
return
;
}
else
if
(
num
<
0
)
{
(
*
buf
)
=
'-'
;
buf
++
;
num
=
LV_MATH_ABS
(
num
);
}
uint32_t
output
=
0
;
int8_t
i
;
for
(
i
=
31
;
i
>=
0
;
i
--
){
if
((
output
&
0xF
)
>=
5
)
output
+=
3
;
if
(((
output
&
0xF0
)
>>
4
)
>=
5
)
output
+=
(
3
<<
4
);
if
(((
output
&
0xF00
)
>>
8
)
>=
5
)
output
+=
(
3
<<
8
);
if
(((
output
&
0xF000
)
>>
12
)
>=
5
)
output
+=
(
3
<<
12
);
if
(((
output
&
0xF0000
)
>>
16
)
>=
5
)
output
+=
(
3
<<
16
);
if
(((
output
&
0xF00000
)
>>
20
)
>=
5
)
output
+=
(
3
<<
20
);
if
(((
output
&
0xF000000
)
>>
24
)
>=
5
)
output
+=
(
3
<<
24
);
if
(((
output
&
0xF0000000
)
>>
28
)
>=
5
)
output
+=
(
3
<<
28
);
output
=
(
output
<<
1
)
|
((
num
>>
i
)
&
1
);
}
uint8_t
digit
;
bool
leading_zero_ready
=
false
;
for
(
i
=
28
;
i
>=
0
;
i
-=
4
)
{
digit
=
((
output
>>
i
)
&
0xF
)
+
'0'
;
if
(
digit
==
'0'
&&
leading_zero_ready
==
false
)
continue
;
leading_zero_ready
=
true
;
(
*
buf
)
=
digit
;
buf
++
;
}
(
*
buf
)
=
'\0'
;
printf
(
"Input decimal or binary: %d
\n
Output BCD: %X
\n
Output str: %s
\n
"
,
num
,
output
,
buf_ori
);
}
/**********************
* STATIC FUNCTIONS
**********************/
lv_misc/lv_math.h
View file @
eb376899
...
...
@@ -14,6 +14,7 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include <stdint.h>
/*********************
* DEFINES
...
...
@@ -30,6 +31,7 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
void
lv_math_num_to_str
(
int32_t
num
,
char
*
buf
);
/**********************
* MACROS
...
...
lv_objx/lv_gauge.c
View file @
eb376899
...
...
@@ -353,7 +353,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
int16_t
scale_act
=
(
int32_t
)((
int32_t
)(
max
-
min
)
*
i
)
/
(
label_num
-
1
);
scale_act
+=
min
;
sprintf
(
scale_txt
,
"%d"
,
scale_act
);
lv_math_num_to_str
(
scale_act
,
scale_txt
);
// sprintf(scale_txt, "%d", scale_act);
lv_area_t
label_cord
;
lv_point_t
label_size
;
...
...
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