1#ifndef __INC_LIB8TION_TRIG_H
2#define __INC_LIB8TION_TRIG_H
23#if defined(USE_SIN_32)
25#define sin16 fl::sin16lut
26#define cos16 fl::cos16lut
33#define sin16 sin16_avr
44 static const uint8_t data[] = {
45 0, 0, 49, 0, 6393 % 256, 6393 / 256, 48, 0,
46 12539 % 256, 12539 / 256, 44, 0, 18204 % 256, 18204 / 256, 38, 0,
47 23170 % 256, 23170 / 256, 31, 0, 27245 % 256, 27245 / 256, 23, 0,
48 30273 % 256, 30273 / 256, 14, 0, 32137 % 256, 32137 / 256, 4 };
50 uint16_t offset = (theta & 0x3FFF);
63 offset = 2047 - offset;
66 sectionX4 = offset / 256;
80 u.blo = data[sectionX4];
81 u.bhi = data[sectionX4 + 1];
82 m = data[sectionX4 + 2];
84 uint8_t secoffset8 = (uint8_t)(offset) / 2;
86 uint16_t mx = m * secoffset8;
109 static const uint16_t base[] = {0, 6393, 12539, 18204,
110 23170, 27245, 30273, 32137};
111 static const uint8_t slope[] = {49, 48, 44, 38, 31, 23, 14, 4};
113 uint16_t offset = (theta & 0x3FFF) >> 3;
115 offset = 2047 - offset;
117 uint8_t section = offset / 256;
118 uint16_t b = base[section];
119 uint8_t m = slope[section];
121 uint8_t secoffset8 = (uint8_t)(offset) / 2;
123 uint16_t mx = m * secoffset8;
153#if defined(__AVR__) && !defined(LIB8_ATTINY)
166 uint8_t offset = theta;
168 asm volatile(
"sbrc %[theta],6 \n\t"
170 : [theta]
"+r"(theta), [offset]
"+r"(offset));
174 uint8_t secoffset = offset & 0x0F;
181 uint8_t section = offset >> 4;
182 uint8_t s2 = section * 2;
192 asm volatile(
"mul %[m16],%[secoffset] \n\t"
197 "andi %[mx],0x0F \n\t"
199 "andi %[xr1], 0xF0 \n\t"
200 "or %[mx], %[xr1] \n\t"
201 : [mx]
"=d"(mx), [xr1]
"=d"(xr1)
202 : [m16]
"d"(m16), [secoffset]
"d"(secoffset));
227 uint8_t offset = theta;
229 offset = (uint8_t)255 - offset;
233 uint8_t secoffset = offset & 0x0F;
237 uint8_t section = offset >> 4;
238 uint8_t s2 = section * 2;
245 uint8_t mx = (m16 * secoffset) >> 4;
LIB8STATIC int16_t cos16(uint16_t theta)
Fast 16-bit approximation of cos(x).
LIB8STATIC int16_t sin16_C(uint16_t theta)
Fast 16-bit approximation of sin(x).
LIB8STATIC uint8_t cos8(uint8_t theta)
Fast 8-bit approximation of cos(x).
LIB8STATIC uint8_t sin8_C(uint8_t theta)
Fast 8-bit approximation of sin(x).
#define sin16
Platform-independent alias of the fast sin implementation.
const uint8_t b_m16_interleave[]
Pre-calculated lookup table used in sin8() and cos8() functions.
#define sin8
Platform-independent alias of the fast sin implementation.
#define LIB8STATIC
Define a LIB8TION member function as static inline with an "unused" attribute.
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]