3#ifndef __INC_LIB8TION_TRIG_H
4#define __INC_LIB8TION_TRIG_H
37#if defined(USE_SIN_32)
39#define sin16 fl::sin16lut
40#define cos16 fl::cos16lut
47#define sin16 sin16_avr
58 static const uint8_t data[] = {
59 0, 0, 49, 0, 6393 % 256, 6393 / 256, 48, 0,
60 12539 % 256, 12539 / 256, 44, 0, 18204 % 256, 18204 / 256, 38, 0,
61 23170 % 256, 23170 / 256, 31, 0, 27245 % 256, 27245 / 256, 23, 0,
62 30273 % 256, 30273 / 256, 14, 0, 32137 % 256, 32137 / 256, 4 };
64 uint16_t
offset = (theta & 0x3FFF);
94 u.blo = data[sectionX4];
95 u.bhi = data[sectionX4 + 1];
96 m = data[sectionX4 + 2];
98 uint8_t secoffset8 = (uint8_t)(
offset) / 2;
100 uint16_t mx = m * secoffset8;
102 int16_t
y = mx + u.b;
123 static const uint16_t base[] = {0, 6393, 12539, 18204,
124 23170, 27245, 30273, 32137};
125 static const uint8_t slope[] = {49, 48, 44, 38, 31, 23, 14, 4};
127 uint16_t
offset = (theta & 0x3FFF) >> 3;
131 uint8_t section =
offset / 256;
132 uint16_t b = base[section];
133 uint8_t m = slope[section];
135 uint8_t secoffset8 = (uint8_t)(
offset) / 2;
137 uint16_t mx = m * secoffset8;
167#if defined(__AVR__) && !defined(LIB8_ATTINY)
182 asm volatile(
"sbrc %[theta],6 \n\t"
188 uint8_t secoffset =
offset & 0x0F;
195 uint8_t section =
offset >> 4;
196 uint8_t s2 = section * 2;
206 asm volatile(
"mul %[m16],%[secoffset] \n\t"
211 "andi %[mx],0x0F \n\t"
213 "andi %[xr1], 0xF0 \n\t"
214 "or %[mx], %[xr1] \n\t"
215 : [mx]
"=d"(mx), [xr1]
"=d"(xr1)
216 : [m16]
"d"(m16), [secoffset]
"d"(secoffset));
247 uint8_t secoffset =
offset & 0x0F;
251 uint8_t section =
offset >> 4;
252 uint8_t s2 = section * 2;
259 uint8_t mx = (m16 * secoffset) >> 4;
#define FL_DISABLE_WARNING_RETURN_TYPE
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_SIGN_CONVERSION
#define FL_DISABLE_WARNING_POP
#define FL_DISABLE_WARNING_UNUSED_PARAMETER
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
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.
Defines static inlining macros for lib8tion functions.