Defines | Functions

Trigonometry functions returning 8-bit integer values

Defines

#define TRIGINT_SIN8_STATIC_TABLE   1
 Compile time macro that can be used to disable the static (compile-time) lookup table.

Functions

uint8_t trigint_sin8u (trigint_angle_t angle)
 Returns the sine of angle as an unsigned 8-bit integer.
int8_t trigint_sin8 (trigint_angle_t angle)
 Returns the sine of angle as a signed 8-bit integer.
int trigint_sin8u_table_size ()
 Returns the size of the lookup table used for unsigned 8-bit integers.
uint8_t trigint_sin8u_table_lookup (int index)
 Lookup a specific table entry for the given index.
void trigint_sin8_init ()
 Initialize the dynamic table.

Define Documentation

#define TRIGINT_SIN8_STATIC_TABLE   1

Compile time macro that can be used to disable the static (compile-time) lookup table.

This can be used to reduce compiled code size at the expense of requiring a call to trigint_sin8_init() at runtime.


Function Documentation

uint8_t trigint_sin8u ( trigint_angle_t  angle  ) 

Returns the sine of angle as an unsigned 8-bit integer.

It is scaled to an amplitude of 127 and offset by 128 thus values will range from 1 to 255.

Parameters:
angle the angle to compute the sine of
Returns:
the sine value, as an unsigned 8-bit integer
See also:
http://en.wikipedia.org/wiki/Offset_binary
int8_t trigint_sin8 ( trigint_angle_t  angle  )  [inline]

Returns the sine of angle as a signed 8-bit integer.

It is scaled to an amplitude of 127 thus values will range from -127 to 127.

Parameters:
angle the angle to compute the sine of
Returns:
the sine value, as an unsigned 8-bit integer
Note:
There is no table for signed 8-bit computations. It is computed from the unsigned sine value.
int trigint_sin8u_table_size (  ) 

Returns the size of the lookup table used for unsigned 8-bit integers.

Returns:
the size of the lookup table used for unsigned 8-bit integers
Note:
This is generally only needed for debugging purposes.
uint8_t trigint_sin8u_table_lookup ( int  index  )  [inline]

Lookup a specific table entry for the given index.

Parameters:
index a table index
Returns:
the 8-bit unsigned value at the table entry
Note:
This is generally only needed for debugging purposes.
void trigint_sin8_init (  ) 

Initialize the dynamic table.

Must be called before any calls to trigint_sin8u() or trigint_sin8(). This is only necessary and available if the TRIGINT_SIN8_STATIC_TABLE macro is set to 0.