Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_misc/lv_math.h
1476 views
1
/**
2
* @file math_base.h
3
*
4
*/
5
6
#ifndef LV_MATH_H
7
#define LV_MATH_H
8
9
#ifdef __cplusplus
10
extern "C" {
11
#endif
12
13
14
/*********************
15
* INCLUDES
16
*********************/
17
#include <stdint.h>
18
19
/*********************
20
* DEFINES
21
*********************/
22
#define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b))
23
#define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b))
24
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
25
26
#define LV_TRIGO_SIN_MAX 32767
27
#define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/
28
29
#define LV_BEZIER_VAL_MAX 1024 /*Max time in Bezier functions (not [0..1] to use integers) */
30
#define LV_BEZIER_VAL_SHIFT 10 /*log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/
31
32
/**********************
33
* TYPEDEFS
34
**********************/
35
36
/**********************
37
* GLOBAL PROTOTYPES
38
**********************/
39
/**
40
* Convert a number to string
41
* @param num a number
42
* @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements)
43
* @return same as `buf` (just for convenience)
44
*/
45
char * lv_math_num_to_str(int32_t num, char * buf);
46
47
/**
48
* Return with sinus of an angle
49
* @param angle
50
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
51
*/
52
int16_t lv_trigo_sin(int16_t angle);
53
54
/**
55
* Calculate a value of a Cubic Bezier function.
56
* @param t time in range of [0..LV_BEZIER_VAL_MAX]
57
* @param u0 start values in range of [0..LV_BEZIER_VAL_MAX]
58
* @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX]
59
* @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX]
60
* @param u3 end values in range of [0..LV_BEZIER_VAL_MAX]
61
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
62
*/
63
int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3);
64
65
/**********************
66
* MACROS
67
**********************/
68
69
#ifdef __cplusplus
70
} /* extern "C" */
71
#endif
72
73
#endif
74
75