#include <math.h>
#include <string.h>
#include <sys/time.h>
Go to the source code of this file.
Classes | |
struct | phantom_pos |
struct | phantom_info |
struct | phantom_device |
Defines | |
#define | PHM_LIB_MAX_FORCE (12.0f) |
#define | PHM_DEFAULT_MAX_FORCE (0.0f) |
#define | PHM_EBIGSPEED 2 |
#define | PHM_EBIGFORCE 4 |
#define | PHM_EOVERHEAT 8 |
#define | PHM_ERROR (PHM_EBIGSPEED|PHM_EBIGFORCE|PHM_EOVERHEAT) |
#define | PHM_BUTTON 16 |
Functions | |
struct phantom_device * | phm_open (const char *devname) |
int | phm_start (struct phantom_device *dev, unsigned int rate) |
void | phm_stop (struct phantom_device *dev) |
int | phm_reset (struct phantom_device *dev) |
void | phm_wait (struct phantom_device *dev) |
void | phm_force_clamp_max (float force[3], float max_force) |
struct phantom_info * | phm_switch (struct phantom_device *dev) |
static int | phm_button_state (const struct phantom_device *dev) |
float * | phm_to_spherical (float in[3], float out[3]) |
float * | phm_to_cartesian (float in[3], float out[3]) |
float * | phm_interpolate (float inB[3], float inE[3], float out[3], float alpha) |
void | phm_get_stylus_matrix (float *m, float a, float b, float x, float y, float z) |
void | phm_get_stylus_vector (float *vector_out, const float *m, const float *vector_in) |
void | phm_filter_force (float force_out[3], float force_in[3]) |
void | phm_filter_init (void) |
void | phm_filter_1D_recursive (float force_out[3], float alpha, float force_in[3], float force_old[3]) |
static void | phm_filter_2D_recursive (float force_out[3], float r, float k, float force_in[3], float force_old[3], float force_old1[3]) |
static void | phm_music_2D_recursive (float force_out[3], float k, float force_in[3], float force_old[3]) |
#define PHM_BUTTON 16 |
is the button pressed? (don't use this directly, use phm_button_state instead)
Referenced by phm_button_state().
#define PHM_DEFAULT_MAX_FORCE (0.0f) |
use this to get default value stored in the library
#define PHM_EBIGFORCE 4 |
force overflew
#define PHM_EBIGSPEED 2 |
speed overflew
#define PHM_EOVERHEAT 8 |
phantom is too hot
#define PHM_ERROR (PHM_EBIGSPEED|PHM_EBIGFORCE|PHM_EOVERHEAT) |
some error occured
#define PHM_LIB_MAX_FORCE (12.0f) |
max force -- 12 Newtons
Referenced by phm_force_clamp_max().
static int phm_button_state | ( | const struct phantom_device * | dev | ) | [inline, static] |
phm_button_state - get button state
dev | device returned by phm_start |
References PHM_BUTTON, and phantom_device::status.
void phm_force_clamp_max | ( | float | force[3], | |
float | max_force | |||
) |
clamps the force vector to some maximum value
force | forces to alter | |
max_force | what should be used as max force. If PHM_DEFAULT_MAX_FORCE, use internal PHM_LIB_MAX_FORCE |
References PHM_LIB_MAX_FORCE.
void phm_get_stylus_matrix | ( | float * | m, | |
float | a, | |||
float | b, | |||
float | x, | |||
float | y, | |||
float | z | |||
) |
get 3x3 rotational matrix for stylus
References phm_get_stylus_matrix().
Referenced by phm_get_stylus_matrix().
void phm_get_stylus_vector | ( | float * | vector_out, | |
const float * | m, | |||
const float * | vector_in | |||
) |
transform vector by rotational matrix for stylus
References phm_get_stylus_vector().
Referenced by phm_get_stylus_vector().
struct phantom_device* phm_open | ( | const char * | devname | ) | [read] |
Open phantom device and create memory maps
The complement, which should be called at the end of operation is phm_stop.
devname | phantom /dev device name |
int phm_reset | ( | struct phantom_device * | dev | ) |
reset phantom status
This should be called before operating with phantom, since its position is otherwise undefined and computing is bogus. Call this at least once after first open.
dev | pointer returned by phm_open |
int phm_start | ( | struct phantom_device * | dev, | |
unsigned int | unused | |||
) |
Interface to start force on phantom
dev | pointer returned by phm_open | |
unused | no longer used, for backward compatibility |
void phm_stop | ( | struct phantom_device * | dev | ) |
stop phantom and release resources
Call this, when you are finishing your work with phantom. It should be called to be clean.
It's safe to call this even if phm_start was not called, but phm_open was.
dev | pointer returned by phm_open |
struct phantom_info* phm_switch | ( | struct phantom_device * | dev | ) | [read] |
get info struct where to write to and read from
In most cases, this should be called *after* phm_wait returns.
dev | phantom_device which was returned by phm_open |
void phm_wait | ( | struct phantom_device * | dev | ) |
wait until timer wakes us up
This should be used in loop for waiting for new data. You probably might want to call phm_switch after this returns.
dev | return value of phm_open |