Fast 8-bit approximation of sin(x).
This approximation never varies more than 2% from the floating point value you'd get by doing
float s = (sin(
x) * 128.0) + 128;
- Parameters
-
theta | input angle from 0-255 |
- Returns
- sin of theta, value between 0 and 255
Definition at line 226 of file trig8.h.
226 {
227 uint8_t offset = theta;
228 if (theta & 0x40) {
229 offset = (uint8_t)255 - offset;
230 }
231 offset &= 0x3F;
232
233 uint8_t secoffset = offset & 0x0F;
234 if (theta & 0x40)
235 ++secoffset;
236
237 uint8_t section = offset >> 4;
238 uint8_t s2 = section * 2;
244
245 uint8_t mx = (m16 * secoffset) >> 4;
246
248 if (theta & 0x80)
250
252
254}
const uint8_t b_m16_interleave[]
Pre-calculated lookup table used in sin8() and cos8() functions.
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
References b_m16_interleave, LIB8STATIC, p, and y.