diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2021-09-27 22:56:46 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2021-09-27 22:56:46 -0600 |
commit | 90eb3a0b79bfef67c70dc545b49c48928eea05f4 (patch) | |
tree | 66718a17063ce4fa5c32c4a8ac094d09f7fab6de /include/shared/math.h | |
parent | 5f1763ec87503527583cb1a7c6deb73604db0dfc (diff) | |
download | stm32l4-90eb3a0b79bfef67c70dc545b49c48928eea05f4.tar.gz stm32l4-90eb3a0b79bfef67c70dc545b49c48928eea05f4.tar.bz2 stm32l4-90eb3a0b79bfef67c70dc545b49c48928eea05f4.zip |
Completed ws2812b 2020 Christmas Lights.ir_leds
Diffstat (limited to 'include/shared/math.h')
-rw-r--r-- | include/shared/math.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/shared/math.h b/include/shared/math.h new file mode 100644 index 0000000..6aec0e7 --- /dev/null +++ b/include/shared/math.h @@ -0,0 +1,19 @@ +#ifndef _SHARED_MATH_H_ +#define _SHARED_MATH_H_ + +#include "kern/common.h" + +/* Returns round(sin(2πn / 256) * 127.5 + 127.5). */ +uint8_t byte_sin(uint8_t n); + +static inline uint8_t byte_scale(uint8_t n, uint8_t sc) { + return n * sc / 255; +} + +#define min(a, b) (a) < (b) ? (a) : (b) +#define max(a, b) (a) > (b) ? (a) : (b) + +/* returns (in / 256)^n * 256. */ +uint8_t amp(uint8_t in, uint8_t n); + +#endif /* _SHARED_MATH_H_ */ |