mikroSDK Reference Manual
lv_math.h
Go to the documentation of this file.
1
6#ifndef LV_MATH_H
7#define LV_MATH_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17#include <stdint.h>
18
19/*********************
20 * DEFINES
21 *********************/
22#define LV_TRIGO_SIN_MAX 32767
23#define LV_TRIGO_SHIFT 15
25#define LV_BEZIER_VAL_MAX 1024
26#define LV_BEZIER_VAL_SHIFT 10
28/**********************
29 * TYPEDEFS
30 **********************/
31
32typedef struct {
33 uint16_t i;
34 uint16_t f;
36
37/**********************
38 * GLOBAL PROTOTYPES
39 **********************/
40
42
47LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle);
48
49static inline LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_cos(int16_t angle)
50{
51 return lv_trigo_sin(angle + 90);
52}
53
55
65uint32_t lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3);
66
73uint16_t lv_atan2(int x, int y);
74
76
87LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask);
88
90
97int64_t lv_pow(int64_t base, int8_t exp);
98
108int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out);
109
116uint32_t lv_rand(uint32_t min, uint32_t max);
117
118/**********************
119 * MACROS
120 **********************/
121#define LV_MIN(a, b) ((a) < (b) ? (a) : (b))
122#define LV_MIN3(a, b, c) (LV_MIN(LV_MIN(a,b), c))
123#define LV_MIN4(a, b, c, d) (LV_MIN(LV_MIN(a,b), LV_MIN(c,d)))
124
125#define LV_MAX(a, b) ((a) > (b) ? (a) : (b))
126#define LV_MAX3(a, b, c) (LV_MAX(LV_MAX(a,b), c))
127#define LV_MAX4(a, b, c, d) (LV_MAX(LV_MAX(a,b), LV_MAX(c,d)))
128
129#define LV_CLAMP(min, val, max) (LV_MAX(min, (LV_MIN(val, max))))
130
131#define LV_ABS(x) ((x) > 0 ? (x) : (-(x)))
132#define LV_UDIV255(x) (((x) * 0x8081U) >> 0x17)
133
134#define LV_IS_SIGNED(t) (((t)(-1)) < ((t)0))
135#define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))
136#define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL)))
137#define LV_MAX_OF(t) ((unsigned long)(LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t)))
138
139#ifdef __cplusplus
140} /*extern "C"*/
141#endif
142
143#endif
uint32_t lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3)
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
uint16_t lv_atan2(int x, int y)
uint32_t lv_rand(uint32_t min, uint32_t max)
int64_t lv_pow(int64_t base, int8_t exp)
Definition lv_math.h:32