Finch C API  1
Documentation for the Finch's C Library
Macros | Functions
Finch.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "Finch.h"
#include <windows.h>
#include "hidapi.h"

Macros

#define SEND   0
 
#define SEND_RECV   1
 

Functions

void Fin_Thread (void *arg)
 
int Fin_Cmnd (int flag, char cmnd, unsigned char *buffer)
 
int Fin_Init (void)
 Fin_init(void).
 
int Fin_Exit (void)
 Fin_Exit(void).
 
int Fin_Motor (int tenth, int left, int right)
 Fin_Motor(tenth, left, right).
 
int Fin_Move (int tenth, int left, int right)
 Fin_Move(tenth, left, right).
 
int Fin_Speed (int *left, int *right)
 Fin_Speed(*left, *right).
 
int Fin_LED (int red, int green, int blue)
 Fin_LED(red, green, blue).
 
int Fin_Buzzer (int msec, int freq)
 Fin_Buzzer(msec, freq).
 
int Fin_Lights (int *left, int *right)
 Fin_Lights(*left, *right).
 
int Fin_Obstacle (int *left, int *right)
 Fin_Obstacle(*left, *right).
 
int Fin_Temp (float *temp)
 Fin_Temp(*temp).
 
int Fin_Accel (float *x, float *y, float *z, int *tap, int *shake)
 Fin_Accel(*x, *y, *z, *tap, *shake).
 
char * CheckForInput (void)
 

Macro Definition Documentation

#define SEND   0
#define SEND_RECV   1

Function Documentation

char* CheckForInput ( void  )
int Fin_Accel ( float *  x,
float *  y,
float *  z,
int *  tap,
int *  shake 
)

Fin_Accel(*x, *y, *z, *tap, *shake).

get acceleration values and tap/shaken flags

input: float *x/*y/*z = pointer where to return the acceleration for each axis returned value is in 'g' (in 1/1000 units) can be positive or negative int *tap/*shake = pointer where to return the tap/shaken flags returned value is 1 or 0 (0=not tap, not shaken) returns -1 if failure

int Fin_Buzzer ( int  msec,
int  freq 
)

Fin_Buzzer(msec, freq).

turn on the buzzer

input: int msec = duration in msecs int freq = frequency in hz use 0,0 to turn the buzzer off returns -1 if failure

int Fin_Cmnd ( int  flag,
char  cmnd,
unsigned char *  buffer 
)
int Fin_Exit ( void  )

Fin_Exit(void).

go back to idle mode close the connection

input: none returns: -1 if failure

int Fin_Init ( void  )

Fin_init(void).

initializes the interface to the finch robot launches a background thread to prevent the finch from timing out *Must be called prior to all other finch functions

input: none returns: -1 if failure

int Fin_LED ( int  red,
int  green,
int  blue 
)

Fin_LED(red, green, blue).

set the color and intensity of the beak LED

input: int red/green/blue = intensity of each color must be between +255 and 0 (0=off) returns -1 if failure

int Fin_Lights ( int *  left,
int *  right 
)

Fin_Lights(*left, *right).

get light sensor data

input: int *left/*right = pointer where to return the light sensor data returned values range 255 to 0 (0=dark) returns -1 if failure

int Fin_Motor ( int  tenth,
int  left,
int  right 
)

Fin_Motor(tenth, left, right).

set the speed (and duration) of the wheels

input: int tenth = motor on time (in tenths of a second) int left/right = speed of each wheel must be between +255 and -255 positive values are forward, negative is reverse use 0,0 to stop use -1 for time if you want to sets the wheels to a certain speed without turning them off at a predetermined time (example: Fin_Motor(-1, 200, -200)) returns -1 if failure

int Fin_Move ( int  tenth,
int  left,
int  right 
)

Fin_Move(tenth, left, right).

set the speed (and duration) of the wheels, and block the program from further execution until time is up

input: int tenth = motor on time (in tenths of a second), and block time int left/right = speed of each wheel must be between +255 and -255 positive values are forward, negative is reverse returns -1 if failure

int Fin_Obstacle ( int *  left,
int *  right 
)

Fin_Obstacle(*left, *right).

get obstacle sensor data

input: int *left/*right = pointer where to return the obstacle flags returned value is 1 or 0 (0=no obstacle) returns -1 if failure

int Fin_Speed ( int *  left,
int *  right 
)

Fin_Speed(*left, *right).

get the current speed of the wheels

input: int *left/*right = pointer where to return the speed of each wheel returns -1 if failure

int Fin_Temp ( float *  temp)

Fin_Temp(*temp).

get temperature sensor data

input: float *temp = pointer where to return the temperature returned value is in celsius (in 1/1000 units) returns -1 if failure

void Fin_Thread ( void *  arg)