Firmware SDK
twr_dice

Helper library to determine dice (cube) face position from vectors. More...

Typedefs

typedef struct twr_dice_t twr_dice_t
 Dice instance.
 

Enumerations

enum  twr_dice_face_t {
  TWR_DICE_FACE_UNKNOWN = 0,
  TWR_DICE_FACE_1 = 1,
  TWR_DICE_FACE_2 = 2,
  TWR_DICE_FACE_3 = 3,
  TWR_DICE_FACE_4 = 4,
  TWR_DICE_FACE_5 = 5,
  TWR_DICE_FACE_6 = 6
}
 Dice faces. More...
 

Functions

void twr_dice_init (twr_dice_t *self, twr_dice_face_t start)
 Initialize dice. More...
 
void twr_dice_set_threshold (twr_dice_t *self, float threshold)
 Set threshold. More...
 
void twr_dice_feed_vectors (twr_dice_t *self, float x_axis, float y_axis, float z_axis)
 Feed dice with X/Y/Z axis vectors. More...
 
twr_dice_face_t twr_dice_get_face (twr_dice_t *self)
 Get calculated dice face. More...
 

Detailed Description

Helper library to determine dice (cube) face position from vectors.

Enumeration Type Documentation

◆ twr_dice_face_t

Dice faces.

Enumerator
TWR_DICE_FACE_UNKNOWN 

Unknown dice face.

TWR_DICE_FACE_1 

Dice face 1.

TWR_DICE_FACE_2 

Dice face 2.

TWR_DICE_FACE_3 

Dice face 3.

TWR_DICE_FACE_4 

Dice face 4.

TWR_DICE_FACE_5 

Dice face 5.

TWR_DICE_FACE_6 

Dice face 6.

Definition at line 12 of file twr_dice.h.

Function Documentation

◆ twr_dice_feed_vectors()

void twr_dice_feed_vectors ( twr_dice_t self,
float  x_axis,
float  y_axis,
float  z_axis 
)

Feed dice with X/Y/Z axis vectors.

Parameters
[in]selfInstance
[in]x_axisVector of X axis
[in]y_axisVector of Y axis
[in]z_axisVector of Z axis

Definition at line 31 of file twr_dice.c.

◆ twr_dice_get_face()

twr_dice_face_t twr_dice_get_face ( twr_dice_t self)

Get calculated dice face.

Parameters
[in]selfInstance
Returns
Dice face

Definition at line 82 of file twr_dice.c.

◆ twr_dice_init()

void twr_dice_init ( twr_dice_t self,
twr_dice_face_t  start 
)

Initialize dice.

Parameters
[in]selfInstance
[in]startDice initial face

Definition at line 17 of file twr_dice.c.

◆ twr_dice_set_threshold()

void twr_dice_set_threshold ( twr_dice_t self,
float  threshold 
)

Set threshold.

Parameters
[in]selfInstance
[in]threshold

Definition at line 26 of file twr_dice.c.