FastLED 3.9.7
Loading...
Searching...
No Matches
math8.h File Reference

Detailed Description

Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.

Definition in file math8.h.

#include "scale8.h"
#include "lib8tion/lib8static.h"
#include "intmap.h"
#include "fl/namespace.h"

Go to the source code of this file.

Functions

LIB8STATIC_ALWAYS_INLINE uint8_t qadd8 (uint8_t i, uint8_t j)
 Add one byte to another, saturating at 0xFF.
 
LIB8STATIC_ALWAYS_INLINE int8_t qadd7 (int8_t i, int8_t j)
 Add one byte to another, saturating at 0x7F and -0x80.
 
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8 (uint8_t i, uint8_t j)
 Subtract one byte from another, saturating at 0x00.
 
LIB8STATIC_ALWAYS_INLINE uint8_t add8 (uint8_t i, uint8_t j)
 Add one byte to another, with 8-bit result.
 
LIB8STATIC_ALWAYS_INLINE uint16_t add8to16 (uint8_t i, uint16_t j)
 Add one byte to two bytes, with 16-bit result.
 
LIB8STATIC_ALWAYS_INLINE uint8_t sub8 (uint8_t i, uint8_t j)
 Subtract one byte from another, 8-bit result.
 
LIB8STATIC_ALWAYS_INLINE uint8_t avg8 (uint8_t i, uint8_t j)
 Calculate an integer average of two unsigned 8-bit integer values (uint8_t), rounded down.
 
LIB8STATIC_ALWAYS_INLINE uint16_t avg16 (uint16_t i, uint16_t j)
 Calculate an integer average of two unsigned 16-bit integer values (uint16_t), rounded down.
 
LIB8STATIC_ALWAYS_INLINE uint8_t avg8r (uint8_t i, uint8_t j)
 Calculate an integer average of two unsigned 8-bit integer values (uint8_t), rounded up.
 
LIB8STATIC_ALWAYS_INLINE uint16_t avg16r (uint16_t i, uint16_t j)
 Calculate an integer average of two unsigned 16-bit integer values (uint16_t), rounded up.
 
LIB8STATIC_ALWAYS_INLINE int8_t avg7 (int8_t i, int8_t j)
 Calculate an integer average of two signed 7-bit integers (int8_t).
 
LIB8STATIC_ALWAYS_INLINE int16_t avg15 (int16_t i, int16_t j)
 Calculate an integer average of two signed 15-bit integers (int16_t).
 
LIB8STATIC_ALWAYS_INLINE uint8_t mod8 (uint8_t a, uint8_t m)
 Calculate the remainder of one unsigned 8-bit value divided by anoter, aka A % M.
 
LIB8STATIC uint8_t addmod8 (uint8_t a, uint8_t b, uint8_t m)
 Add two numbers, and calculate the modulo of the sum and a third number, M.
 
LIB8STATIC uint8_t submod8 (uint8_t a, uint8_t b, uint8_t m)
 Subtract two numbers, and calculate the modulo of the difference and a third number, M.
 
LIB8STATIC_ALWAYS_INLINE uint8_t mul8 (uint8_t i, uint8_t j)
 8x8 bit multiplication, with 8-bit result.
 
LIB8STATIC_ALWAYS_INLINE uint8_t qmul8 (uint8_t i, uint8_t j)
 8x8 bit multiplication with 8-bit result, saturating at 0xFF.
 
LIB8STATIC_ALWAYS_INLINE int8_t abs8 (int8_t i)
 Take the absolute value of a signed 8-bit uint8_t.
 
LIB8STATIC uint8_t sqrt16 (uint16_t x)
 Square root for 16-bit integers.
 
LIB8STATIC_ALWAYS_INLINE uint8_t sqrt8 (uint8_t x)
 
LIB8STATIC uint8_t blend8 (uint8_t a, uint8_t b, uint8_t amountOfB)
 Blend a variable proportion (0-255) of one byte to another.