Final Project files for mBed development.

Dependencies:   m3pi mbed

Embed: (wiki syntax)

« Back to documentation index

main.h File Reference

main.h File Reference

Main header file for includes and defs. More...

Go to the source code of this file.

Functions

int retrieve_inst (char *buf, int *x, int *y, int *draw)
 get values of next PostScript instruction.
void forward (int amt)
 Driver forward for a time.
void backward (int amt)
 Drive backward for a time.
void right (float deg)
 Turn right by some angle.
void left (float deg)
 Turn left by some angle.
void timerWait (float amt)
 Wait for a number of seconds, possibly fractional.
int find_corner (int left)
 Follows the non-reflective line to a corner.
void find_line ()
 Turns towards the base line and moves to reach it.
float distance (int x1, int y1, int x2, int y2)
 Computes the Euclidean distance between two points.
void robot_printf (int line, const char *format,...)
 prints to the m3pi's screen
float compute_turn_angle (int last_x, int last_y, int x, int y, float angle)
 computes the angle to turn to face towards (x,y)
void pen_up ()
 sends the signal on the output pin for the led to turn it on
void pen_down ()
 turns off the signal to the led

Detailed Description

Main header file for includes and defs.

Author:
John Wilkey
Alec Guertin
Chester Chu

Definition in file main.h.


Function Documentation

void backward ( int  amt )

Drive backward for a time.

Parameters:
[in]amtAmount to drive backward. In milliseconds.

Definition at line 417 of file main.c.

float compute_turn_angle ( int  last_x,
int  last_y,
int  x,
int  y,
float  angle 
)

computes the angle to turn to face towards (x,y)

Parameters:
[in]last_xthe current x-coordinate
[in]last_ythe current y-coordinate
[in]xthe desired x-coordinate
[in]ythe desired y-coordinate
[in]anglethe current angle the m3pi is facing
Returns:
the angle to turn left

Definition at line 270 of file main.c.

float distance ( int  x1,
int  y1,
int  x2,
int  y2 
)

Computes the Euclidean distance between two points.

Parameters:
[in]x1the x-coordinate of the first point
[in]y1the y-coordinate of the first point
[in]x2the x-coordinate of the second point
[in]y2the y-coordinate of the second point
Returns:
the distance between points (x1,y1) and (x2,y2)

Definition at line 321 of file main.c.

int find_corner ( int  left )

Follows the non-reflective line to a corner.

Parameters:
[in]leftboolean specifying if the corner to look for is a left corner
Returns:
returns an error code

Definition at line 340 of file main.c.

void find_line (  )

Turns towards the base line and moves to reach it.

Definition at line 326 of file main.c.

void forward ( int  amt )

Driver forward for a time.

Parameters:
[in]amtAmount to drive forward. In milliseconds.

Definition at line 393 of file main.c.

void left ( float  deg )

Turn left by some angle.

Parameters:
[in]degDesired final turn angle in degrees from start. Note that a negative angle will turn in the opposite direction.

Definition at line 426 of file main.c.

void pen_down (  )

turns off the signal to the led

Definition at line 461 of file main.c.

void pen_up (  )

sends the signal on the output pin for the led to turn it on

Definition at line 466 of file main.c.

int retrieve_inst ( char *  buf,
int *  x,
int *  y,
int *  draw 
)

get values of next PostScript instruction.

Parameters:
bufBuffer with PS instructions.
xPointer to storage for x coordinate.
yPointer to storage for y coordinate.
drawPointer to storage for draw/move boolean.
Returns:
Success or failure code.

Definition at line 369 of file main.c.

void right ( float  deg )

Turn right by some angle.

Parameters:
[in]degDesired final turn angle in degrees from start. Note that a negative angle will turn in the opposite direction.

Definition at line 440 of file main.c.

void robot_printf ( int  line,
const char *  format,
  ... 
)

prints to the m3pi's screen

Parameters:
[in]linethe line on the screen to print to, in {0,1}
[in]formatthe format string to print
[in]...the arguments to pass into the format string

Definition at line 309 of file main.c.

void timerWait ( float  amt )

Wait for a number of seconds, possibly fractional.

Timer resolution is on the order of microseconds. A negative wait time does nothing.

Parameters:
[in]amtTime to wait, in seconds.

Definition at line 454 of file main.c.