From 918943b46e9e93a848725c44fe6f6cfc6a60c798 Mon Sep 17 00:00:00 2001 From: Jan Delgado Date: Fri, 25 Dec 2020 15:52:05 +0100 Subject: include optimized sin/cos code for AVR only when on this platform --- src/lib8tion/trig8.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib8tion/trig8.h b/src/lib8tion/trig8.h index c5896ef8..bcb9f68a 100644 --- a/src/lib8tion/trig8.h +++ b/src/lib8tion/trig8.h @@ -16,9 +16,6 @@ #if defined(__AVR__) #define sin16 sin16_avr -#else -#define sin16 sin16_C -#endif /// Fast 16-bit approximation of sin(x). This approximation never varies more than /// 0.69% from the floating point value you'd get by doing @@ -78,6 +75,9 @@ LIB8STATIC int16_t sin16_avr( uint16_t theta ) return y; } +#else +#define sin16 sin16_C + /// Fast 16-bit approximation of sin(x). This approximation never varies more than /// 0.69% from the floating point value you'd get by doing /// @@ -109,6 +109,7 @@ LIB8STATIC int16_t sin16_C( uint16_t theta ) return y; } +#endif /// Fast 16-bit approximation of cos(x). This approximation never varies more than /// 0.69% from the floating point value you'd get by doing @@ -139,15 +140,11 @@ LIB8STATIC int16_t cos16( uint16_t theta) // // On Arduino/AVR, this approximation is more than // 20X faster than floating point sin(x) and cos(x) +// +const uint8_t b_m16_interleave[] = { 0, 49, 49, 41, 90, 27, 117, 10 }; #if defined(__AVR__) && !defined(LIB8_ATTINY) #define sin8 sin8_avr -#else -#define sin8 sin8_C -#endif - - -const uint8_t b_m16_interleave[] = { 0, 49, 49, 41, 90, 27, 117, 10 }; /// Fast 8-bit approximation of sin(x). This approximation never varies more than /// 2% from the floating point value you'd get by doing @@ -206,6 +203,8 @@ LIB8STATIC uint8_t sin8_avr( uint8_t theta) return y; } +#else +#define sin8 sin8_C /// Fast 8-bit approximation of sin(x). This approximation never varies more than /// 2% from the floating point value you'd get by doing @@ -243,6 +242,8 @@ LIB8STATIC uint8_t sin8_C( uint8_t theta) return y; } +#endif + /// Fast 8-bit approximation of cos(x). This approximation never varies more than /// 2% from the floating point value you'd get by doing /// -- cgit v1.2.3