# lv_math.h

Defines

LV_TRIGO_SIN_MAX
LV_TRIGO_SHIFT

LV_TRIGO_SHIFT to normalize

LV_BEZIER_VAL_SHIFT

log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values

LV_BEZIER_VAL_MAX

Max time in Bezier functions (not [0..1] to use integers)

LV_BEZIER_VAL_FLOAT(f)

Convert const float number cubic-bezier values to fix-point value

LV_ALIGN_UP(x, align)
LV_ROUND_UP(x, round)
LV_MIN(a, b)
LV_MIN3(a, b, c)
LV_MIN4(a, b, c, d)
LV_MAX(a, b)
LV_MAX3(a, b, c)
LV_MAX4(a, b, c, d)
LV_CLAMP(min, val, max)
LV_ABS(x)
LV_UDIV255(x)
LV_IS_SIGNED(t)
LV_UMAX_OF(t)
LV_SMAX_OF(t)
LV_MAX_OF(t)

Functions

int32_t lv_cubic_bezier(int32_t x, int32_t x1, int32_t y1, int32_t x2, int32_t y2)

Calculate the y value of cubic-bezier(x1, y1, x2, y2) function as specified x.

Parameters:
• x -- time in range of [0..LV_BEZIER_VAL_MAX]

• x1 -- x of control point 1 in range of [0..LV_BEZIER_VAL_MAX]

• y1 -- y of control point 1 in range of [0..LV_BEZIER_VAL_MAX]

• x2 -- x of control point 2 in range of [0..LV_BEZIER_VAL_MAX]

• y2 -- y of control point 2 in range of [0..LV_BEZIER_VAL_MAX]

Returns:

the value calculated

static inline int32_t lv_bezier3(int32_t t, int32_t u0, uint32_t u1, int32_t u2, int32_t u3)

Calculate a value of a Cubic Bezier function.

Parameters:
• t -- time in range of [0..LV_BEZIER_VAL_MAX]

• u0 -- must be 0

• u1 -- control value 1 values in range of [0..LV_BEZIER_VAL_MAX]

• u2 -- control value 2 in range of [0..LV_BEZIER_VAL_MAX]

• u3 -- must be LV_BEZIER_VAL_MAX

Returns:

the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]

uint16_t lv_atan2(int x, int y)

Calculate the atan2 of a vector.

Parameters:
• x --

• y --

Returns:

the angle in degree calculated from the given parameters in range of [0..360]

int32_t lv_sqrt32(uint32_t x)

Alternative (fast, approximate) implementation for getting the square root of an integer.

Parameters:

x -- integer which square root should be calculated

static inline int32_t lv_sqr(int32_t x)

Calculate the square of an integer (input range is 0..32767).

Parameters:

x -- input

Returns:

square

int64_t lv_pow(int64_t base, int8_t exp)

Calculate the integer exponents.

Parameters:
• base --

• exp --

Returns:

base raised to the power exponent

int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)

Get the mapped of a number given an input and output range

Parameters:
• x -- integer which mapped value should be calculated

• min_in -- min input range

• max_in -- max input range

• min_out -- max output range

• max_out -- max output range

Returns:

the mapped number

void lv_rand_set_seed(uint32_t seed)

Set the seed of the pseudo random number generator

Parameters:

seed -- a number to initialize the random generator

uint32_t lv_rand(uint32_t min, uint32_t max)

Get a pseudo random number in the given range

Parameters:
• min -- the minimum value

• max -- the maximum value

Returns:

return the random number. min <= return_value <= max

struct lv_sqrt_res_t

Public Members

uint16_t i
uint16_t f