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 * INCLUDES 15 *********************/ 16 #include <stdint.h> 17 18 /********************* 19 * DEFINES 20 *********************/ 21 #define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) 22 #define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) 23 #define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) 24 25 #define LV_TRIGO_SIN_MAX 32767 26 #define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/ 27 28 #define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */ 29 #define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ 30 31 /********************** 32 * TYPEDEFS 33 **********************/ 34 35 /********************** 36 * GLOBAL PROTOTYPES 37 **********************/ 38 39 /** 40 * Return with sinus of an angle 41 * @param angle 42 * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 43 */ 44 int16_t lv_trigo_sin(int16_t angle); 45 46 /** 47 * Calculate a value of a Cubic Bezier function. 48 * @param t time in range of [0..LV_BEZIER_VAL_MAX] 49 * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 50 * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 51 * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 52 * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 53 * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 54 */ 55 int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); 56 57 /********************** 58 * MACROS 59 **********************/ 60 61 #ifdef __cplusplus 62 } /* extern "C" */ 63 #endif 64 65 #endif 66